lists.checkmk.com
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
List overview
Download
Checkmk git commits
February 2013
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
checkmk-commits@lists.checkmk.com
3 participants
346 discussions
Start a n
N
ew thread
Check_MK Git: check_mk: FIX: Fixed exception when logging actions exectuted by mkeventd
by Lars Michelsen
Module: check_mk Branch: master Commit: c8d39a2f795e00a452714ddc68307e9245324842 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c8d39a2f795e00…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Feb 12 12:08:21 2013 +0100 FIX: Fixed exception when logging actions exectuted by mkeventd --- ChangeLog | 3 +++ mkeventd/bin/mkeventd | 2 +- 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index 084289d..fb04c54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ BI: * FIX: fix exception in BI-Boxes views of host groups + Event Console: + * FIX: Fixed exception when logging actions exectuted by mkeventd + 1.2.2b1: Core: * cmk --notify: added notification script to generate HTML mails including diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd index 5ba25a1..1d165ea 100755 --- a/mkeventd/bin/mkeventd +++ b/mkeventd/bin/mkeventd @@ -2296,7 +2296,7 @@ def do_rule_action(action, event, user=""): log_event_history(event, "EMAIL", user, "%s|%s" % (to, subject)) elif action_type == 'script': execute_script(substitute_event_tags(settings["script"], event)) - log_event_history(event, "SCRIPT", user, action) + log_event_history(event, "SCRIPT", user, action['id']) else: log("Cannot execute action %s: invalid action type %s" % (action["id"], action_type)) except Exception, e:
11 years, 9 months
1
0
0
0
Check_MK Git: check_mk: mknotifyd: OMD integration
by Mathias Kettner
Module: check_mk Branch: master Commit: 6d52fcfa0a38ee9a87d4807e2bd7795617b9567f URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6d52fcfa0a38ee…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Tue Feb 12 11:49:19 2013 +0100 mknotifyd: OMD integration --- {mknotifyd/bin => doc/treasures}/mknotifyd | 0 mknotifyd/.f12 | 22 --------- mknotifyd/.gitignore | 4 -- mknotifyd/omd/.f12 | 34 -------------- mknotifyd/omd/MKNOTIFYD.hook | 25 ---------- mknotifyd/omd/Makefile | 18 ------- mknotifyd/omd/logrotate.conf | 7 --- mknotifyd/omd/mknotifyd.init | 54 ---------------------- mknotifyd/web/.f12 | 8 --- {mknotifyd/web => web}/plugins/wato/mknotifyd.py | 4 +- 10 files changed, 2 insertions(+), 174 deletions(-) diff --git a/mknotifyd/bin/mknotifyd b/doc/treasures/mknotifyd similarity index 100% rename from mknotifyd/bin/mknotifyd rename to doc/treasures/mknotifyd diff --git a/mknotifyd/.f12 b/mknotifyd/.f12 deleted file mode 100644 index c6255e4..0000000 --- a/mknotifyd/.f12 +++ /dev/null @@ -1,22 +0,0 @@ -SITE=${SITE:-$(omd sites --bare | sort | head -n 1)} -OMD_ROOT=/omd/sites/${SITE} - -for dir in web -do - if [ -e "$dir" ] ; then - sudo rsync -var $dir/ $OMD_ROOT/share/check_mk/$dir/ - fi -done -sudo install -m 755 bin/mknotifyd $OMD_ROOT/bin/ -sudo touch $OMD_ROOT/share/check_mk/web/htdocs/*.py -sudo install -m 755 omd/mknotifyd.init $OMD_ROOT/etc/init.d/mknotifyd -sudo sed -i "s@###ROOT###@$OMD_ROOT@g" $OMD_ROOT/etc/init.d/mknotifyd -sudo ln -sfn ../init.d/mknotifyd $OMD_ROOT/etc/rc.d/10-mknotifyd -sudo install -m 755 omd/MKNOTIFYD.hook $OMD_ROOT/lib/omd/hooks/MKNOTIFYD -sudo touch $OMD_ROOT/etc/check_mk/mknotifyd.mk - -sudo chown -R $SITE.$SITE $OMD_ROOT/{etc,local,var} -sudo omd restart $SITE apache -# sudo omd status $SITE mknotifyd && sudo omd restart $SITE mknotifyd - - diff --git a/mknotifyd/.gitignore b/mknotifyd/.gitignore deleted file mode 100644 index 29ee6d9..0000000 --- a/mknotifyd/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.*.swp -mknotifyd-*.*.*.tar.gz -mknotifyd-*.*.* - diff --git a/mknotifyd/omd/.f12 b/mknotifyd/omd/.f12 deleted file mode 100644 index 187b833..0000000 --- a/mknotifyd/omd/.f12 +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -SITE=${SITE:-ev} - -# MAKE dist tarball -cd .. -VERSION=$(sed -rn '/^VERSION="(.*)"/s//\1/p' < bin/mknotifyd) -DIRNAME=mknotifyd-$VERSION -rm -rf $DIRNAME -mkdir -p $DIRNAME -rm -f src/mknotify -cp -r web bin $DIRNAME -tar cvzf $DIRNAME.tar.gz --exclude=.git* --exclude=.f12 --exclude=.*.swp $DIRNAME - -# Integrate into CMK+OMD -OMD=../../cmk-omd/packages/mknotifyd -mkdir -p $OMD -cp -v $DIRNAME.tar.gz $OMD -sed "s/^VERSION = .*/VERSION = $VERSION/" omd/Makefile > $OMD/Makefile -mkdir -p $OMD/skel/etc/init.d -install -m 755 omd/mknotifyd.init $OMD/skel/etc/init.d/mknotifyd -install -m 755 omd/MKNOTIFYD.hook $OMD -mkdir -p $OMD/skel/etc/check_mk/mknotifyd.d/wato -echo '# Configuration of mknotifyd' > $OMD/skel/etc/check_mk/mknotifyd.mk -echo 'etc/init.d/mknotifyd 755' > $OMD/skel.permissions -mkdir -p $OMD/skel/etc/rc.d -ln -sfn ../init.d/mknotifyd $OMD/skel/etc/rc.d/10-mknotifyd - -# Directly put into our test site -if [ -n "$SITE" -a -e "/omd/sites/$SITE" ] ; then - sudo install -o $SITE -g $SITE -v -m 755 omd/mknotifyd.init /omd/sites/$SITE/etc/init.d/mknotifyd - sudo install -o $SITE -g $SITE -v -m 644 omd/logrotate.conf /omd/sites/$SITE/etc/logrotate.d/mknotifyd - sudo sed -i "s@###ROOT###@/omd/sites/$SITE@g" /omd/sites/$SITE/etc/logrotate.d/mknotifyd - sudo install -d -o $SITE -g $SITE /omd/sites/$SITE/var/log/mknotifyd -fi diff --git a/mknotifyd/omd/MKNOTIFYD.hook b/mknotifyd/omd/MKNOTIFYD.hook deleted file mode 100755 index 7d0409c..0000000 --- a/mknotifyd/omd/MKNOTIFYD.hook +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Alias: Start Check_MK Notification Spooler -# Menu: Addons -# Description: -# This option enables the Check_MK notification spooler - -case "$1" in - default) - echo "off" - ;; - choices) - echo "on: enable" - echo "off: disable" - ;; - set) - if [ "$2" = on ] ; then - enabled=True - else - enabled=False - fi - echo -e "# Set by OMD hook MKNOTIFYD, do not change here!\nmknotifyd_enabled = $enabled" \ - > $OMD_ROOT/etc/check_mk/multisite.d/mknotifyd.mk - ;; -esac diff --git a/mknotifyd/omd/Makefile b/mknotifyd/omd/Makefile deleted file mode 100644 index 4e71750..0000000 --- a/mknotifyd/omd/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -include ../../Makefile.omd - -NAME = mknotifyd -VERSION = foobar -DIR = $(NAME)-$(VERSION) - -build: - tar xzf $(DIR).tar.gz - -install: - mkdir -p $(DESTDIR)$(OMD_ROOT)/bin - install -m 755 $(DIR)/bin/* $(DESTDIR)$(OMD_ROOT)/bin - mkdir -p $(DESTDIR)$(OMD_ROOT)/share/check_mk/web - cp -pr $(DIR)/web/* $(DESTDIR)$(OMD_ROOT)/share/check_mk/web - -clean: -# rm -rf mk-notifyd-*.*.* - diff --git a/mknotifyd/omd/logrotate.conf b/mknotifyd/omd/logrotate.conf deleted file mode 100644 index bca3d9c..0000000 --- a/mknotifyd/omd/logrotate.conf +++ /dev/null @@ -1,7 +0,0 @@ -###ROOT###/var/log/mknotifyd.log { - missingok - rotate 52 - compress - delaycompress - notifempty -} diff --git a/mknotifyd/omd/mknotifyd.init b/mknotifyd/omd/mknotifyd.init deleted file mode 100755 index 2bb814a..0000000 --- a/mknotifyd/omd/mknotifyd.init +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -unset LANG - -PIDFILE=$OMD_ROOT/tmp/run/mknotifyd/pid -STATUS_SOCKET=$OMD_ROOT/tmp/run/mknotifyd/status -DAEMON=$OMD_ROOT/bin/mknotifyd -STATEFILE=$OMD_ROOT/var/mknotifyd/status -THE_PID=$(cat $PIDFILE 2>/dev/null) -# OPTS="--debug" -OPTS="" - -. $OMD_ROOT/etc/omd/site.conf -if [ "$CONFIG_MKNOTIFYD" != on ] ; then - exit 5 -fi - -case "$1" in - start) - echo -n 'Starting mknotifyd...' - $DAEMON $OPTS - echo OK - ;; - stop) - echo -n 'Stopping mknotifyd...' - if [ -z "$THE_PID" ] ; then - echo 'Not running.' - else - echo "killing $THE_PID..." - kill $THE_PID - fi - ;; - restart) - $0 stop - $0 start - ;; - - status) - echo -n 'Checking status of mknotifyd...' - if [ -z "$THE_PID" ] ; then - echo "not running (PID file missing)" - exit 1 - elif ! kill -0 $THE_PID ; then - echo "not running (PID file orphaned)" - exit 1 - else - echo "running" - exit 0 - fi - ;; - *) - echo "Usage: $0 {start|stop|restart|status}" - ;; -esac diff --git a/mknotifyd/web/.f12 b/mknotifyd/web/.f12 deleted file mode 100644 index 2c8d957..0000000 --- a/mknotifyd/web/.f12 +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -SITE=${SITE:-$(omd sites --bare | head -n 1)} -C=$(sudo cp --preserve=mode -rv * /omd/versions/default/share/check_mk/web/ | wc -l) -#C=$(sudo cp --preserve=mode -rv htdocs/*.{css,py} /omd/versions/default/share/check_mk/web/htdocs/ | wc -l) -echo "$C files copied" -if [ "$SITE" != - ] ; then - sudo omd restart $SITE apache -fi diff --git a/mknotifyd/web/plugins/wato/mknotifyd.py b/web/plugins/wato/mknotifyd.py similarity index 98% rename from mknotifyd/web/plugins/wato/mknotifyd.py rename to web/plugins/wato/mknotifyd.py index f7d90a1..9ee6dd5 100644 --- a/mknotifyd/web/plugins/wato/mknotifyd.py +++ b/web/plugins/wato/mknotifyd.py @@ -29,8 +29,8 @@ import config try: mknotifyd_enabled = config.mknotifyd_enabled except: - # Non OMD-users: always show Spooling options - mknotifyd_enabled = True + # Non OMD-users: must enable this explicitely, sorry + mknotifyd_enabled = False config_dir = defaults.default_config_dir + "/mknotifyd.d/wato/"
11 years, 9 months
1
0
0
0
Check_MK Git: check_mk: Remove unused variable in mknotifyd
by Mathias Kettner
Module: check_mk Branch: master Commit: 07083ef1f8ce38e60783265042acecde65703202 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=07083ef1f8ce38…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Mon Feb 11 11:56:01 2013 +0100 Remove unused variable in mknotifyd --- mknotifyd/bin/mknotifyd | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/mknotifyd/bin/mknotifyd b/mknotifyd/bin/mknotifyd index e8ecdb4..258ae54 100755 --- a/mknotifyd/bin/mknotifyd +++ b/mknotifyd/bin/mknotifyd @@ -178,7 +178,6 @@ class SpoolfilesHandler: class TcpServer: def __init__(self): self._tcp_socket = None - self._reopen_sockets = False self._should_terminate = False self._is_running = False self.open_sockets()
11 years, 9 months
1
0
0
0
Check_MK Git: check_mk: mknotifyd: now uses separate threads
by Andreas Boesl
Module: check_mk Branch: master Commit: 1022b4a439ce8501da87e49cf56d6be9a212ec3c URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1022b4a439ce85…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Thu Jan 31 14:34:04 2013 +0100 mknotifyd: now uses separate threads --- mknotifyd/bin/mknotifyd | 380 +++++++++++++++++++++++++++++++---------------- 1 files changed, 250 insertions(+), 130 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=1022b4a439…
11 years, 9 months
1
0
0
0
Check_MK Git: check_mk: mknotifyd initial version
by Andreas Boesl
Module: check_mk Branch: master Commit: a601c08d4d5888079a8439f7da604a010505b86a URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a601c08d4d5888…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Thu Jan 31 09:06:24 2013 +0100 mknotifyd initial version --- mknotifyd/.f12 | 22 ++ mknotifyd/.gitignore | 4 + mknotifyd/bin/clienttest | 32 +++ mknotifyd/bin/mknotifyd | 394 +++++++++++++++++++++++++++++++ mknotifyd/omd/.f12 | 31 +++ mknotifyd/omd/MKNOTIFYD.hook | 25 ++ mknotifyd/omd/Makefile | 18 ++ mknotifyd/omd/mknotifyd.init | 54 +++++ mknotifyd/web/.f12 | 8 + mknotifyd/web/plugins/wato/mknotifyd.py | 99 ++++++++ modules/check_mk.py | 4 +- modules/notify.py | 320 +++++++++++++++++-------- 12 files changed, 903 insertions(+), 108 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=a601c08d4d…
11 years, 9 months
1
0
0
0
Check_MK Git: check_mk: notify.py: fixed creation of spoolsfiles
by Andreas Boesl
Module: check_mk Branch: master Commit: 47f9a73b0056e38ecb23db839e0f1f4da8ad6b59 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=47f9a73b0056e3…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Thu Jan 31 14:35:41 2013 +0100 notify.py: fixed creation of spoolsfiles --- modules/notify.py | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/modules/notify.py b/modules/notify.py index 15a9685..be1116e 100644 --- a/modules/notify.py +++ b/modules/notify.py @@ -200,8 +200,7 @@ def create_spoolfile(data): file_path = "%s/%0.2f_%s" % (target_dir, time.time(), uuid.uuid1()) notify_log("Creating spoolfile: %s" % file_path) # TODO: pprint entfernen - # file(file_path,"w").write(pprint.pformat(data)) - file(file_path,"w").write(data) + file(file_path,"w").write(pprint.pformat(data)) def get_readable_rel_date(timestamp): try:
11 years, 9 months
1
0
0
0
Check_MK Git: check_mk: mknotifyd update
by Andreas Boesl
Module: check_mk Branch: master Commit: bcd7187e21b353f1b3151849969dc64c26805c79 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bcd7187e21b353…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Mon Feb 4 11:44:48 2013 +0100 mknotifyd update --- checks/oracle_tablespaces | 13 ++++++ mknotifyd/.f12 | 2 +- mknotifyd/omd/.f12 | 3 + mknotifyd/omd/logrotate.conf | 12 +++++ mknotifyd/web/plugins/wato/mknotifyd.py | 69 ++++++++++++++++++++---------- modules/notify.py | 32 ++++++++------- notifications/opcmsg | 2 +- web/plugins/wato/check_parameters.py | 37 ++++++++++++++++- 8 files changed, 129 insertions(+), 41 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=bcd7187e21…
11 years, 9 months
1
0
0
0
Check_MK Git: check_mk: opcmsg notification plugin
by Andreas Boesl
Module: check_mk Branch: master Commit: 27a6d76b3fed76399eaf8a0d402ff6161bf27ace URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=27a6d76b3fed76…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Thu Jan 31 14:33:35 2013 +0100 opcmsg notification plugin --- notifications/opcmsg | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-) diff --git a/notifications/opcmsg b/notifications/opcmsg new file mode 100755 index 0000000..8d953cf --- /dev/null +++ b/notifications/opcmsg @@ -0,0 +1,68 @@ +#!/usr/bin/python +# Create message for HPOpenView +# This plugin forwards the notification to the +# local HPOpenView instance + +import os, sys, re + +def substitute_context(template, context): + # First replace all known variables + for varname, value in context.items(): + template = template.replace('$'+varname+'$', value) + + # Remove the rest of the variables and make them empty + template = re.sub("\$[A-Z]+\$", "", template) + return template + +def main(): + try: + opcmsg_bin = "/opt/OV/bin/opcmsg" + + # gather all options from env + context = dict([ + (var[7:], value.decode("utf-8")) + for (var, value) + in os.environ.items() + if var.startswith("NOTIFY_")]) + + + # Severity and message text + if context["WHAT"] == "HOST": + msg_t = context["HOSTOUTPUT"] + severity = context["HOSTSTATEID"] == "0" and "ok" or "critical" + else: + msg_t = context["SERVICEOUTPUT"] + state_map = { "0": "normal", "1": "warning", "2": "critical", "3": "warning" } + try: + severity = state_map[context["SERVICESTATEID"]] + except: + severity = "normal" + + # application + application = "RWWS4.0" + + # object + # Wichtig: " escapen + the_object = context["HOSTNAME"] + if context["WHAT"] == "SERVICE": + the_object += ":" + context["SERVICEDESC"] + + # msg_grp + msg_grp = os.getenv("NOTIFY_PARAMETER_1") + + # node + node = context['MONITORING_HOST'] + + # Assemble the command + command = "%s severity=%s application=%s object=\"%s\" msg_grp=\"%s\" msg_t=\"%s\" node=%s" % ( + opcmsg_bin, severity, application, the_object, msg_grp, msg_t, node) + + # Execute the command + print "executing command" , command + file("/tmp/opc","w").write(command) + # return os.system(command) + except Exception, e: + sys.stdout.write("ERROR %r" % e) + sys.exit(1) + +main()
11 years, 9 months
1
0
0
0
Check_MK Git: check_mk: mknotifyd: now able to reload on config changes
by Andreas Boesl
Module: check_mk Branch: master Commit: 5977752692e37c1d60c831e94bd54448e57f1b44 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5977752692e37c…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Mon Feb 11 19:05:11 2013 +0100 mknotifyd: now able to reload on config changes --- mknotifyd/bin/mknotifyd | 96 ++++++++++++++++++++---------- mknotifyd/web/plugins/wato/mknotifyd.py | 10 ++- modules/notify.py | 9 +-- 3 files changed, 75 insertions(+), 40 deletions(-) diff --git a/mknotifyd/bin/mknotifyd b/mknotifyd/bin/mknotifyd index 258ae54..bdb101f 100755 --- a/mknotifyd/bin/mknotifyd +++ b/mknotifyd/bin/mknotifyd @@ -88,6 +88,7 @@ class SpoolfilesHandler: self._is_running = False def run(self): + log("Starting SpoolfilesHandler") self._is_running = True try: while not self._should_terminate: @@ -180,25 +181,33 @@ class TcpServer: self._tcp_socket = None self._should_terminate = False self._is_running = False - self.open_sockets() + self._reopen_sockets = False def open_sockets(self): - if opt_verbose: - verbose("open tcp sockets", 2) - - self._tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self._tcp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self._tcp_socket.bind(("0.0.0.0", g_config["notification_daemon_listen_port"])) - # TODO: listen limit ? - self._tcp_socket.listen(200) + listen_port = g_config["notification_daemon_listen_port"] + log("Listen for remote notifications at port %d" % listen_port) + try: + self._tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self._tcp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + self._tcp_socket.bind(("0.0.0.0", listen_port)) + # TODO: listen limit ? + self._tcp_socket.listen(200) + except: + log("Error opening socket.\n%s" % format_exception()) + self._should_terminate = True def close_sockets(self): if self._tcp_socket: self._tcp_socket.close() self._tcp_socket = None + log("No longer listen for remote notificiations") def run(self): + self._should_terminate = False self._is_running = True + log("Starting TcpServer") + self.open_sockets() + handled_connections = 0 # Debug info while not self._should_terminate: readable = select.select([self._tcp_socket], [], [], 0.5)[0] @@ -214,15 +223,14 @@ class TcpServer: if "context" in content: context = content["context"] if not context["CONTACTNAME"]: - log("ERROR: Unable to process data from %s %d" % (addr_info[0], addr_info[1])) + log("Error: Unable to process data from %s %d" % (addr_info[0], addr_info[1])) client_socket.send("ERROR") else: contact_dir = "%s/%s" % (g_spool_dir, context["CONTACTNAME"]) if not os.path.exists(contact_dir): os.makedirs(contact_dir) spoolfile = "%s/%0.2f_%s" % (contact_dir, time.time(), uuid.uuid1()) - file(spoolfile,"w").write("%r" % content) - #file(spoolfile,"w").write(pprint.pformat(content)) + file(spoolfile,"w").write(pprint.pformat(content)) verbose("client data processed - sending OK", 2) client_socket.send("OK") except Exception, e: @@ -236,6 +244,11 @@ class TcpServer: pass # TODO: wirklich ohne socket.close() client_socket = None + if self._reopen_sockets: + log("Reopen tcp socket") + self.close_sockets() + self.open_sockets() + self._reopen_sockets = False log("Stopping TcpServer") self.close_sockets() @@ -303,22 +316,18 @@ def daemonize(user=0, group=0): def load_configuration(): - global g_config, g_config_last_reload - g_config = { - "notification_daemon_listen_port": 6555, - "notification_deferred_retention_time": 180, - "notification_forward_to": "", - } - - list_of_files = reduce(lambda a,b: a+b, - [ [ "%s/%s" % (d, f) for f in fs if f.endswith(".mk")] - for d, sb, fs in os.walk(g_config_dir + "/mknotifyd.d" ) ], []) + global g_config, g_config_changed + last_config = g_config.copy() + config_file = "%s/mknotifyd.d/wato/global.mk" % g_config_dir + try: + execfile(config_file, {}, g_config) + except: + g_config = last_config - list_of_files.sort() - for path in list_of_files: - execfile(path, g_config, g_config) + if last_config != g_config: + log("Configuration has changed") + g_config_changed = True - g_last_config_reload = time.time() def usage(): sys.stdout.write("""Usage: mknotifyd [OPTIONS] @@ -346,6 +355,7 @@ def run_thread(run_function, args=()): def run_notifyd(): global g_tpc_server, g_spoolfiles_handler global g_spool_dir, g_deferred_dir + global g_config_changed g_spool_dir = "%s/notify/spool" % g_var_dir g_deferred_dir = "%s/notify/deferred" % g_var_dir @@ -357,17 +367,33 @@ def run_notifyd(): os.makedirs(g_deferred_dir) # Start worker threads - run_thread(g_tcp_server.run) + if g_config["notification_daemon_listen_port"]: + run_thread(g_tcp_server.run) + run_thread(g_spoolfiles_handler.run) while True: try: - time.sleep(2) + time.sleep(1) + # Read configuration again an check for changes + # Our tcp server might need a restart after its config has changed + load_configuration() + if g_config_changed: + if g_config["notification_daemon_listen_port"]: + if not g_tcp_server._is_running: + run_thread(g_tcp_server.run) + else: + g_tcp_server._reopen_sockets = True + else: + g_tcp_server._should_terminate = True + g_config_changed = False + time.sleep(0.2) + # Check if worker threads are still running - # and restart them if something strange happened - if not g_tcp_server._is_running: + if g_config["notification_daemon_listen_port"] and not g_tcp_server._is_running: log("TcpServer thread crashed. Restarting...") run_thread(g_tcp_server.run) + if not g_spoolfiles_handler._is_running: log("SpoolfilesHandler thread crashed. Restarting...") run_thread(g_spoolfiles_handler.run) @@ -429,8 +455,12 @@ else: g_pid_file = "/var/run/mknotifyd.pid" g_logfile_path = "/var/log/mknotifyd.log" -tcp_socket = None -reopen_sockets = False + +g_config = { + "notification_daemon_listen_port": None, + "notification_deferred_retention_time": 180, + "notification_forward_to": "", +} short_options = "hVvgs" long_options = [ "help", "version", "verbose", "foreground", "single" ] @@ -464,6 +494,7 @@ try: log("mknotifyd version %s starting" % VERSION) load_configuration() + g_config_changed = False # Of course its changed on startup... if os.path.exists(g_pid_file): old_pid = int(file(g_pid_file).read()) @@ -475,6 +506,7 @@ try: # Make sure paths exist make_parentdirs(g_logfile_path) + make_parentdirs(g_pid_file) # Create worker classes g_tcp_server = TcpServer() diff --git a/mknotifyd/web/plugins/wato/mknotifyd.py b/mknotifyd/web/plugins/wato/mknotifyd.py index 04b88bc..f7d90a1 100644 --- a/mknotifyd/web/plugins/wato/mknotifyd.py +++ b/mknotifyd/web/plugins/wato/mknotifyd.py @@ -100,14 +100,18 @@ if mknotifyd_enabled: # Daemon var register_configvar(group, "notification_daemon_listen_port", + Optional( Integer( - title = _("Port for receiving notifications"), - help = _("Here you can set port at which the notification spooler listens for forwarded" - "notification messages from spoolers on remote sites."), minvalue = 1, maxvalue = 65535, default_value = 6555, ), + help = _("Here you can set the port at which the notification spooler listens for forwarded" + "notification messages from spoolers on remote sites."), + title = _("Port for receiving notifications"), + label = _("Receive notifications from remote sites"), + none_label = _("(Do not receive notifications)"), + ), domain = "mknotifyd" ) diff --git a/modules/notify.py b/modules/notify.py index 3f093fb..8ede4bd 100644 --- a/modules/notify.py +++ b/modules/notify.py @@ -363,12 +363,11 @@ def do_notify(args): "that are prefixed with NOTIFY_\n") sys.exit(1) - notify_log("forward mode %s" % notification_forward_mode) - # TODO: Umbauen auf neue Parameter - if notification_forward_mode in ["forward", "forward_exclusive"]: + if notification_spooling: # Create spoolfile - create_spoolfile({"context": context, "forward": notification_forward_to}) - if notification_forward_mode == "forward_only": + target_site = "%s:%s" % notification_spool_to[0:2] + create_spoolfile({"context": context, "forward": target_site}) + if not notification_spool_to[2]: return 0 process_context(context, notification_spooling)
11 years, 9 months
1
0
0
0
Check_MK Git: check_mk: add mknotifyd tar.gz and subfolder to .gitignore
by Andreas Boesl
Module: check_mk Branch: master Commit: b5057ee5f8a0ad8cc9f90fcf2eb60f11a2e574ef URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b5057ee5f8a0ad…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Mon Feb 11 16:34:07 2013 +0100 add mknotifyd tar.gz and subfolder to .gitignore --- mknotifyd/.gitignore | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mknotifyd/.gitignore b/mknotifyd/.gitignore index fc91262..29ee6d9 100644 --- a/mknotifyd/.gitignore +++ b/mknotifyd/.gitignore @@ -1,4 +1,4 @@ .*.swp -mkeventd-*.*.*.tar.gz -mkeventd-*.*.* +mknotifyd-*.*.*.tar.gz +mknotifyd-*.*.*
11 years, 9 months
1
0
0
0
← Newer
1
...
21
22
23
24
25
26
27
...
35
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Results per page:
10
25
50
100
200