notify.log in OMD environments
Message-ID: <547f18f2./ao9zGjEm8H06Tu7%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 5e6780a84e0d0b0a1dc6d5c07974877c5e17a01a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5e6780a84e0d0b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 3 15:06:26 2014 +0100
#1606 FIX Moved notify.log to var/log/notify.log in OMD environments
The log was located in var/check_mk/notify.log but had no log rotation.
We moved it to var/log/notify.log now and added a log rotation. The
related configuration options have been changed to be enabled by default.
We also removed the option to totally disable this logfile because we'd
rather have some log information about eventual missing notifications
than no information at all.
---
.werks/1606 | 14 ++++++++++++++
ChangeLog | 1 +
modules/notify.py | 11 +++++------
notifications/debug | 2 +-
web/htdocs/wato.py | 8 ++++++++
web/plugins/wato/backup_domains.py | 1 -
web/plugins/wato/check_mk_configuration.py | 13 ++-----------
web/plugins/wato/globals_notification.py | 22 +++++++++++++---------
8 files changed, 44 insertions(+), 28 deletions(-)
diff --git a/.werks/1606 b/.werks/1606
new file mode 100644
index 0000000..3270af0
--- /dev/null
+++ b/.werks/1606
@@ -0,0 +1,14 @@
+Title: Moved notify.log to var/log/notify.log in OMD environments
+Level: 1
+Component: notifications
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417615456
+Class: fix
+
+The log was located in var/check_mk/notify.log but had no log rotation.
+We moved it to var/log/notify.log now and added a log rotation. The
+related configuration options have been changed to be enabled by default.
+We also removed the option to totally disable this logfile because we'd
+rather have some log information about eventual missing notifications
+than no information at all.
diff --git a/ChangeLog b/ChangeLog
index 8c4dc1e..dbc87cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -139,6 +139,7 @@
* 1514 FIX: Try harder to detect previous hard state in notification when using Nagios as core...
* 1582 FIX: Fixed missing graphs in mails when sending notifications to non-contacts...
* 1583 FIX: Can use contact groups without hosts/services assigned in RBN rules now...
+ * 1606 FIX: Moved notify.log to var/log/notify.log in OMD environments...
BI:
* 1435 FIX: Saving BI aggregations: No longer reports 'Request-URI Too Large'...
diff --git a/modules/notify.py b/modules/notify.py
index 87e94c9..871fb30 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -54,8 +54,8 @@ notification_logdir = var_dir + "/notify"
notification_spooldir = var_dir + "/notify/spool"
notification_bulkdir = var_dir + "/notify/bulk"
notification_core_log = var_dir + "/notify/nagios.log" # Fallback for history if no CMC running
-notification_log = notification_logdir + "/notify.log"
-notification_logging = 0
+notification_log = log_dir + "/notify.log"
+notification_logging = 1
notification_backlog = 10 # keep the last 10 notification contexts for reference
# Settings for new rule based notifications
@@ -133,7 +133,9 @@ Available commands:
# keepalive mode (used by CMC), sends out one notifications from
# several possible sources or sends out all ripe bulk notifications.
def do_notify(args):
- global notify_mode
+ global notify_mode, notification_logging
+ if notification_logging == 0:
+ notification_logging = 1 # transform deprecated value 0 to 1
try:
if not os.path.exists(notification_logdir):
os.makedirs(notification_logdir)
@@ -1230,9 +1232,6 @@ def notify_via_email(plugin_context):
else:
notify_log("No UTF-8 encoding found in your locale -a! Please provide C.UTF-8 encoding.")
- if notification_logging >= 2:
- file(var_dir + "/notify/body.log", "w").write(body.encode("utf-8"))
-
# Important: we must not output anything on stdout or stderr. Data of stdout
# goes back into the socket to the CMC in keepalive mode and garbles the
# handshake signal.
diff --git a/notifications/debug b/notifications/debug
index 8cf29ee..d68a3bb 100644
--- a/notifications/debug
+++ b/notifications/debug
@@ -14,7 +14,7 @@
# or notification_logging=2 in main.mk (or via WATO in the
# global settings: Notification -> Debug notifications, then
# you will see this output in the notitifcation log file.
-# Under OMD this file is in ~/var/check_mk/notify/notify.log.
+# Under OMD this file is in ~/var/log/notify.log.
# Please refer to the official documentation for more details.
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index a626574..d941df6 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -18179,6 +18179,14 @@ def is_a_checkbox(vs):
else:
return False
+def site_neutral_path(path):
+ if path.startswith('/omd'):
+ parts = path.split('/')
+ parts[3] = '<siteid>'
+ return '/'.join(parts)
+ else:
+ return path
+
#.
# .--Plugins-------------------------------------------------------------.
# | ____ _ _ |
diff --git a/web/plugins/wato/backup_domains.py b/web/plugins/wato/backup_domains.py
index 35bb452..02da707 100644
--- a/web/plugins/wato/backup_domains.py
+++ b/web/plugins/wato/backup_domains.py
@@ -182,7 +182,6 @@ else:
"prefix" : defaults.omd_root,
"paths" : [
("dir", "var/log"),
- ("file", "var/check_mk/notify/notify.log"),
("file", "var/nagios/livestatus.log"),
("dir", "var/pnp4nagios/log"),
],
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 29936a1..070f672 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -1138,27 +1138,18 @@ register_configvar(group,
"for the operation, but on the other hand will lead to a slightly higher load "
"of Nagios for the first couple of minutes after the restart. ")))
-def log_dir_path():
- path = defaults.log_dir
- if path.startswith('/omd'):
- parts = path.split('/')
- parts[2] = '<siteid>'
- return '/'.join(parts)
- else:
- return path
-
register_configvar(group,
"debug_log",
Transform(
Checkbox(
- label = _("Write exceptions to <tt>%s/crashed-checks.log</tt>" % log_dir_path()),
+ label = _("Write exceptions to <tt>%s/crashed-checks.log</tt>" % site_neutral_path(defaults.log_dir)),
),
title = _("Log exceptions in check plugins"),
help = _("If this option is enabled Check_MK will create a debug logfile at "
"<tt>%s/crashed-checks.log</tt> "
"containing details about failed checks (those which have the state <i>UNKNOWN "
"and the output UNKNOWN - invalid output from plugin</i>...) Per default no "
- "logfile is written.") % log_dir_path(),
+ "logfile is written.") % site_neutral_path(defaults.log_dir),
forth = lambda x: not not x,
),
need_restart = True)
diff --git a/web/plugins/wato/globals_notification.py b/web/plugins/wato/globals_notification.py
index 9d4927e..9b43932 100644
--- a/web/plugins/wato/globals_notification.py
+++ b/web/plugins/wato/globals_notification.py
@@ -84,16 +84,20 @@ register_configvar(group,
register_configvar(group,
"notification_logging",
- DropdownChoice(
- title = _("Notification logfile"),
- help = _("When notification debugging is on, additional information will be "
- "logged in the notification logfile <tt>%s</tt>." %
- (defaults.var_dir + "/notify/notify.log")),
- choices = [
- ( 0, _("No logging")),
- ( 1, _("One line per notification")),
- ( 2, _("Full dump of all variables and command"))]
+ Transform(
+ DropdownChoice(
+ choices = [
+ ( 1, _("Normal logging")),
+ ( 2, _("Full dump of all variables and command"))
+ ],
+ default_value = 1,
),
+ forth = lambda x: x == 0 and 1 or x, # transform deprecated value 0 (no logging) to 1
+ title = _("Notification log level"),
+ help = _("You can configure the notification mechanism to log more details about "
+ "the notifications into the notification log. These information are logged "
+ "into the file <tt>%s</tt>") % site_neutral_path(defaults.log_dir + "/notify.log"),
+ ),
domain = "check_mk")
register_configvar(group,
Module: check_mk
Branch: master
Commit: 7104b7963f82cf1403abfd9bdbf2923a0b74ea2b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7104b7963f82cf…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 3 15:06:17 2014 +0100
#1564 FIX check_mk_agent.linux: fix situation where async plugin is not executed after crash
When executing asynchronous sections or plugins the Check_MK Agent uses
<tt>run_cached()</tt> for putting them in the background. This function
creates a cachefile with the extension <tt>.new</tt> and removes that suffix
when the actual plugin has finished. If due to a server crash the file keeps
lying around the the plugin would not be executed anymore.
We now remove that file if it is older then twice the cache age <i>and
we kill</i> any process that still has open that file. That way we avoid
overlapping plugins in case of a real hanger.
---
.werks/1564 | 17 +++++++++++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 4 ++++
3 files changed, 22 insertions(+)
diff --git a/.werks/1564 b/.werks/1564
new file mode 100644
index 0000000..27feb51
--- /dev/null
+++ b/.werks/1564
@@ -0,0 +1,17 @@
+Title: check_mk_agent.linux: fix situation where async plugin is not executed after crash
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417615386
+Class: fix
+
+When executing asynchronous sections or plugins the Check_MK Agent uses
+<tt>run_cached()</tt> for putting them in the background. This function
+creates a cachefile with the extension <tt>.new</tt> and removes that suffix
+when the actual plugin has finished. If due to a server crash the file keeps
+lying around the the plugin would not be executed anymore.
+
+We now remove that file if it is older then twice the cache age <i>and
+we kill</i> any process that still has open that file. That way we avoid
+overlapping plugins in case of a real hanger.
diff --git a/ChangeLog b/ChangeLog
index f3d3dce..2680676 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,6 +60,7 @@
* 1602 FIX: dell_om_esmlog: Fixed typo in plugin output
* 1563 FIX: Reworked configuration of process monitoring...
NOTE: Please refer to the migration notes!
+ * 1564 FIX: check_mk_agent.linux: fix situation where async plugin is not executed after crash...
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index abb95f2..c734bb1 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -81,6 +81,10 @@ function run_cached () {
if [ -e "$CACHEFILE.new" ] ; then
local CF_ATIME=$(stat -c %X "$CACHEFILE.new")
if [ $((NOW - CF_ATIME)) -ge $((MAXAGE * 2)) ] ; then
+ # Kill the process still accessing that file in case
+ # it is still running. This avoids overlapping processes!
+ fuser -k -9 "$CACHEFILE.new" >/dev/null 2>&1
+ rm -f "$CACHEFILE.new"
return
fi
fi
Module: check_mk
Branch: master
Commit: c032b80d9b1f3c4a09ad90c513d95b006d955d68
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c032b80d9b1f3c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 3 14:47:09 2014 +0100
Updated bug entries #2099
---
.bugs/2099 | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/.bugs/2099 b/.bugs/2099
index a5ce780..183cc6f 100644
--- a/.bugs/2099
+++ b/.bugs/2099
@@ -1,23 +1,27 @@
-Title: ps check outputs wrong cpu usage
+Title: Rework ps check
Component: checks
State: open
Date: 2013-12-17 13:10:37
-Targetversion: 1.2.5i1
-Class: bug
+Targetversion: 1.2.7i1
+Class: todo
-The check uses the average cpu usage since start of the process:
+The ps check for Linux and Windows needs to be completely reworked.
+We need to write a real parse function using dicts that create a
+useful common structure for Linux and Windows and then remove lots
+of nasty special handlings.
+For Linux we need the content of /proc/[pid]/stat in order to
+correctly determine the CPU utilization. This can be done at
+this time - not further.
-***
- CODE HEADER DESCRIPTION
+Here is a suggested command line for the agent:
- %cpu %CPU cpu utilization of the process in "##.#" format.
- Currently, it is the CPU time used divided by the
- time the process has been running
- (cputime/realtime ratio), expressed as a
- percentage. It will not add up to 100% unless
- you are lucky. (alias pcpu).
-***
+echo '[proc_stat]'
+echo /proc/[0-9]*/stat | xargs awk '{ print $1 " " $14 " " $15; }' 2>/dev/null
+echo '[proc_stat_end]'
-This is totally wrong. Better would be to use the raw counter values from ps and
-keep an eye on the counters on our own.
+We might user further data from here and throw that away from the
+current bracket code.
+
+In order not to break compatibility we could implement a new section
+and a new check and the deprecate the existing one.
Module: check_mk
Branch: master
Commit: 8735f4798526400466ed9ec3ce03ee555e3063bc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8735f479852640…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 3 14:43:47 2014 +0100
Removed obsolete lnx_psperf plugin
---
agents/plugins/lnx_psperf | 48 ---------------------------------------------
1 file changed, 48 deletions(-)
diff --git a/agents/plugins/lnx_psperf b/agents/plugins/lnx_psperf
deleted file mode 100755
index c0946d2..0000000
--- a/agents/plugins/lnx_psperf
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-# +------------------------------------------------------------------+
-# | ____ _ _ __ __ _ __ |
-# | / ___| |__ ___ ___| | __ | \/ | |/ / |
-# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
-# | | |___| | | | __/ (__| < | | | | . \ |
-# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
-# | |
-# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
-# +------------------------------------------------------------------+
-#
-# This file is part of Check_MK.
-# The official homepage is at http://mathias-kettner.de/check_mk.
-#
-# check_mk is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation in version 2. check_mk is distributed
-# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
-# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE. See the GNU General Public License for more de-
-# ails. You should have received a copy of the GNU General Public
-# License along with GNU Make; see the file COPYING. If not, write
-# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
-# Boston, MA 02110-1301 USA.
-
-# Needed to get read CPU usage of processes (and other data) on Linux, since
-# ps only outputs the cumulated CPU usage since the process start
-
-# Configuration: /etc/check_mk/psperf.cfg
-# Each line contains one pattern for pgrep. Arguments of pgrep are supported
-# Example:
-# cups
-# -u ntp
-# This will find processes with the name 'cups' and processes owned by the user ntp.
-# The check ps will parse this additional information in order to compute
-# the current CPU utilization of a process.
-
-if [ -e "$MK_CONFDIR/psperf.cfg" ] ; then
- echo '<<<ps>>>'
- echo '[proc_stat]'
- egrep -v '^[[:space:]]*(#|$)' "$MK_CONFDIR/psperf.cfg" | \
- while read LINE
- do
- for pid in $(pgrep $LINE) ; do
- cat /proc/$pid/stat
- done
- done
-fi
Module: check_mk
Branch: master
Commit: 3f40fd9d0d1aeb426f33fbf5e85f70a8ad3b8fa2
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3f40fd9d0d1aeb…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 3 12:57:14 2014 +0100
#1563 FIX Reworked configuration of process monitoring
The configuration of the monitoring of processes has been reworked. This was
mainly to overcome a bug: when the process check was used on a cluster then
the check parameters would be taken randomly from one of the nodes.
The new process monitoring works like this:
H2:Static checks
Statically configured checks are like before. They are configured via the ruleset
<i>State and count of processes</i>.
H2:Checks created by service discovery
The ruleset <i>Process Inventory</i> now does not set parameters (levels)
for the created services anymore. Only the settings for matching process
names and user remain - and of course the service description.
The new ruleset <i>State and count of processes</i> in the section
<i>Parameters for inventorized checks</i> (please do not mix up with static
checks here) is used for defining levels for the count, CPU usage, averaging
and all of the other parameters. The default is to make the check OK if at
least one process is being found. So from now on if you are using process
inventory with custom levels, you need to make configurations in <i>both
rulesets</i>.
On the other hand that can make things easier for you. You might have a lot
of rulesets for detecting various processes but then only need a few rules
for setting levels for these services.
In order to make the migration easier services that have already been created
with previous versions of Check_MK will remain to work as they did. But
after a new service discovery the levels will vanish and then you have to
configure them in the new extra ruleset.
Please note: the ruleset <i>State and count of processes</i> does contain the
settings for matching the process and the user even when used for discovered
checks. The reason is that it is the same ruleset as for manual checks.
Setting these parameters do not make sense here in most cases. Simply leave
them unchecked.
H2:Performance data - ps versus ps.perf
The check <tt>ps.perf</tt> is now deprecated. The normal <tt>ps</tt> check now
does <i>always</i> create performance data. For compatibility reasons the old
<tt>ps.perf</tt> is still defined but does exactly the same as <tt>ps</tt>
---
.bugs/1003 | 6 +-
.werks/1563 | 55 +++++++
ChangeLog | 2 +
checks/domino_tasks | 2 +-
checks/ps | 19 ++-
checks/ps.include | 97 ++++++------
pnp-templates/check_mk-ps.php | 1 +
web/htdocs/valuespec.py | 3 +
web/plugins/perfometer/check_mk.py | 1 +
web/plugins/wato/check_parameters.py | 281 +++++++++++++++-------------------
10 files changed, 243 insertions(+), 224 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=3f40fd9d0d…
Module: check_mk
Branch: master
Commit: 0c4c75698d48d90f3b56420d66da0f14f882e1da
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0c4c75698d48d9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 3 12:00:58 2014 +0100
Fixed yesterdays bug: Always loading host tag painters now
---
web/htdocs/views.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 9c057d3..6ff18a2 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -61,6 +61,7 @@ def load_plugins():
config.declare_permission_section("action", _("Commands on host and services"), do_sort = True)
load_web_plugins("views", globals())
+ load_host_tag_painters()
# This must be set after plugin loading to make broken plugins raise
# exceptions all the time and not only the first time (when the plugins