Module: check_mk
Branch: master
Commit: bff8c88142c5059ef1a92caaa618cee6925ec087
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bff8c88142c505…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Sep 29 09:59:06 2017 +0200
5338 fileinfo: date variables can be defined in fileinfo.cfg
This werk adds the possibility to define date variables in the file
fileinfo.cfg either directly or via the corresponding rule Count,
size and age of files. Date variables can be used on linux and solaris
hosts and have the form $DATE:format-spec$ where format-spec is a list
of time format directives of the unix date command. Example:
$DATE:%Y%m%d$ is todays date in the format YYYYMMDD.
Using this option the agent will only send files containing the
current date. Date variables can be used together with the rules
File Grouping Patterns and Size, age count of file groups to monitor
if files are created in a directory on a dayly basis. Note that the
option Only check during the folling times of the day should be set.
Otherwise a warning may be displayed if the file of the current day
is not present yet.
Change-Id: I6b8487fba3a59c704d667ade8840106165e559cd
---
.werks/5338 | 22 ++++++++++++++++++++++
agents/check_mk_agent.linux | 17 +++++++++++++++++
agents/check_mk_agent.solaris | 18 ++++++++++++++++++
3 files changed, 57 insertions(+)
diff --git a/.werks/5338 b/.werks/5338
new file mode 100644
index 0000000..6927dad
--- /dev/null
+++ b/.werks/5338
@@ -0,0 +1,22 @@
+Title: fileinfo: date variables can be defined in fileinfo.cfg
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1506670399
+Class: feature
+
+This werk adds the possibility to define date variables in the file
+fileinfo.cfg either directly or via the corresponding rule Count,
+size and age of files. Date variables can be used on linux and solaris
+hosts and have the form $DATE:format-spec$ where format-spec is a list
+of time format directives of the unix date command. Example:
+$DATE:%Y%m%d$ is todays date in the format YYYYMMDD.
+Using this option the agent will only send files containing the
+current date. Date variables can be used together with the rules
+File Grouping Patterns and Size, age count of file groups to monitor
+if files are created in a directory on a dayly basis. Note that the
+option Only check during the folling times of the day should be set.
+Otherwise a warning may be displayed if the file of the current day
+is not present yet.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index a3b3518..ec7af26 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -745,6 +745,22 @@ fi
# Fileinfo-Check: put patterns for files into /etc/check_mk/fileinfo.cfg
+function replace_datevariable()
+{
+ # Replace the date variable of the input, e.g. $DATE:%Y%m%d$, by
+ # the current date. If there's no match just return the input.
+ local file_name="$1"
+ local pattern='(\$DATE:(.*)\$)'
+
+ if [[ ! $file_name =~ $pattern ]]; then
+ echo "$file_name"
+ else
+ date_variable="${BASH_REMATCH[1]}"
+ format_string="${BASH_REMATCH[2]}"
+ echo "${file_name/$date_variable/$(date +$format_string)}"
+ fi
+}
+
if [ -r "$MK_CONFDIR/fileinfo.cfg" ] ; then
echo '<<<fileinfo:sep(124)>>>'
date +%s
@@ -752,6 +768,7 @@ if [ -r "$MK_CONFDIR/fileinfo.cfg" ] ; then
do
# only work on lines containing files, skip e.g. comments and blank lines
if [ ${line:0:1} = "/" ]; then
+ line="$(replace_datevariable $line)"
stat -c "%n|%s|%Y" "${line}" 2>/dev/null
if [ $? -ne 0 ]; then
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index 57bd19c..05134d1 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -348,6 +348,22 @@ fi
# Fileinfo-Check: put patterns for files into $MK_CONFDIR/fileinfo.cfg
+function replace_datevariable()
+{
+ # Replace the date variable of the input, e.g. $DATE:%Y%m%d$, by
+ # the current date. If there's no match just return the input.
+ local file_name="$1"
+ local pattern='(\$DATE:(.*)\$)'
+
+ if [[ ! $file_name =~ $pattern ]]; then
+ echo "$file_name"
+ else
+ date_variable="${BASH_REMATCH[1]}"
+ format_string="${BASH_REMATCH[2]}"
+ echo "${file_name/$date_variable/$(date +$format_string)}"
+ fi
+}
+
if [ -f "$MK_CONFDIR/fileinfo.cfg" ]
then
echo '<<<fileinfo:sep(124)>>>'
@@ -357,7 +373,9 @@ then
do
# only work on lines containing files, skip e.g. comments and blank lines
if [ ${file:0:1} = "/" ]; then
+ file="$(replace_datevariable $file)"
ls $file > /dev/null 2>&1
+
if [ $? -eq 0 ]; then
echo $file | \
/usr/bin/perl -e '
Module: check_mk
Branch: master
Commit: b470765f6120c9ec815dece95a7f2b4c41e902c1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b470765f6120c9…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Sep 29 15:49:26 2017 +0200
5339 postfix_mailq_status: Now reports if PID file is not readable
Change-Id: I00e85f75cd1bcbd70812a3e7e2c0b02b8382fc57
---
.werks/5339 | 10 ++++++++++
agents/check_mk_agent.linux | 12 ++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/.werks/5339 b/.werks/5339
new file mode 100644
index 0000000..217d13a
--- /dev/null
+++ b/.werks/5339
@@ -0,0 +1,10 @@
+Title: postfix_mailq_status: Now reports if PID file is not readable
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1506692807
+Class: feature
+
+
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 37c12de..a3b3518 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -660,11 +660,15 @@ if type postfix >/dev/null ; then
for i in $(ls -d /var/spool/postfix*)
do
if [ -e "$i/pid/master.pid" ]; then
- postfix_pid=$(cat $i/pid/master.pid | sed 's/ //g') # handle possible spaces in output
- if readlink -- "/proc/$postfix_pid/exe" | grep -q ".*postfix/\(sbin/\)\?master.*"; then
- echo "$i:the Postfix mail system is running:PID:$postfix_pid" | sed 's/\/var\/spool\///g'
+ if [ -r "$i/pid/master.pid" ]; then
+ postfix_pid=$(cat $i/pid/master.pid | sed 's/ //g') # handle possible spaces in output
+ if readlink -- "/proc/$postfix_pid/exe" | grep -q ".*postfix/\(sbin/\)\?master.*"; then
+ echo "$i:the Postfix mail system is running:PID:$postfix_pid" | sed 's/\/var\/spool\///g'
+ else
+ echo "$i:PID file exists but instance is not running!" | sed 's/\/var\/spool\///g'
+ fi
else
- echo "$i:PID file exists but instance is not running!" | sed 's/\/var\/spool\///g'
+ echo "$i:PID file exists but is not readable"
fi
else
echo "$i:the Postfix mail system is not running" | sed 's/\/var\/spool\///g'
Module: check_mk
Branch: master
Commit: 979cd19e97b0ff473c23bd5918a5500ba9b3c7d4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=979cd19e97b0ff…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Sep 29 12:20:56 2017 +0200
5216 FIX Failed notification checking is now limited to 7 days
This change fixes a GUI (sidebar) rendering performance issue which
was caused by the check for failed notifications. For individual
admin users the GUI could be very slow because the core was searching
far in the past of the monitoring history.
The failed notification checking is now being limited by a configurable
"Failed notification horizon" which is set to 7 days be default. You can
configure this value according to your needs in the Global settings.
Change-Id: If372bc9560343432c00376a3f983ec1df68c0a33
---
.werks/5216 | 18 ++++++++++++++++++
web/htdocs/default_permissions.py | 8 ++++----
web/htdocs/notifications.py | 12 ++++++++++--
web/plugins/config/builtin.py | 2 ++
web/plugins/wato/globals_notification.py | 13 +++++++++++++
5 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/.werks/5216 b/.werks/5216
new file mode 100644
index 0000000..0c8a0bb
--- /dev/null
+++ b/.werks/5216
@@ -0,0 +1,18 @@
+Title: Failed notification checking is now limited to 7 days
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1506680272
+
+This change fixes a GUI (sidebar) rendering performance issue which
+was caused by the check for failed notifications. For individual
+admin users the GUI could be very slow because the core was searching
+far in the past of the monitoring history.
+
+The failed notification checking is now being limited by a configurable
+"Failed notification horizon" which is set to 7 days be default. You can
+configure this value according to your needs in the Global settings.
diff --git a/web/htdocs/default_permissions.py b/web/htdocs/default_permissions.py
index 4fe4b53..fe89f56 100644
--- a/web/htdocs/default_permissions.py
+++ b/web/htdocs/default_permissions.py
@@ -150,7 +150,7 @@ def load_plugins(force):
config.declare_permission("general.see_failed_notifications_24h",
_("See failed Notifications (last 24 hours)"),
- _("If check_mk is unable to notify users about problems, the site will warn about this situation "
+ _("If Check_MK is unable to notify users about problems, the site will warn about this situation "
"very visibly inside the UI (both in the Tactical Overview and the Dashboard). This affects only "
"users with this permission. Users with this permission will only see failed notifications "
"that occured within the last 24 hours."),
@@ -158,10 +158,10 @@ def load_plugins(force):
config.declare_permission("general.see_failed_notifications",
_("See failed Notifications (all)"),
- _("If check_mk is unable to notify users about problems, the site will warn about this situation "
+ _("If Check_MK is unable to notify users about problems, the site will warn about this situation "
"very visibly inside the UI (both in the Tactical Overview and the Dashboard). This affects only "
- "users with this permission. Users with this permission will also see failed notifications "
- "older than 24 hours."),
+ "users with this permission. Users with this permission will see failed notifications between now "
+ "and the configured <a href=\"wato.py?mode=edit_configvar&varname=failed_notification_horizon\">Failed notification horizon</a>."),
[ "admin" ])
loaded_with_language = current_language
diff --git a/web/htdocs/notifications.py b/web/htdocs/notifications.py
index 65386e5..d6e217b 100644
--- a/web/htdocs/notifications.py
+++ b/web/htdocs/notifications.py
@@ -106,8 +106,14 @@ def load_failed_notifications(before=None, after=None, stat_only=False, extra_he
query_filters.append("time <= %d" % before)
if after is not None:
query_filters.append("time >= %d" % after)
- if may_see_notifications and not config.user.may("general.see_failed_notifications"):
- query_filters.append("time > %d" % (int(time.time()) - 86400))
+
+ if may_see_notifications:
+ if config.user.may("general.see_failed_notifications"):
+ horizon = config.failed_notification_horizon
+ else:
+ horizon = 86400
+
+ query_filters.append("time > %d" % (int(time.time()) - horizon))
query = ["GET log"]
if stat_only:
@@ -119,6 +125,8 @@ def load_failed_notifications(before=None, after=None, stat_only=False, extra_he
query = "\n".join(query)
+ html.debug(query)
+
if extra_headers is not None:
query += extra_headers
diff --git a/web/plugins/config/builtin.py b/web/plugins/config/builtin.py
index 32e6963..e66a917 100644
--- a/web/plugins/config/builtin.py
+++ b/web/plugins/config/builtin.py
@@ -87,6 +87,8 @@ quicksearch_dropdown_limit = 80
# Quicksearch search order
quicksearch_search_order = [("h", "continue"), ("al", "continue"), ("ad", "continue"), ("s", "continue")]
+failed_notification_horizon = 7 * 60 * 60 * 24
+
# _ _ _ _
# | | (_)_ __ ___ (_) |_ ___
# | | | | '_ ` _ \| | __/ __|
diff --git a/web/plugins/wato/globals_notification.py b/web/plugins/wato/globals_notification.py
index 3f8e3ef..abcaa76 100644
--- a/web/plugins/wato/globals_notification.py
+++ b/web/plugins/wato/globals_notification.py
@@ -150,3 +150,16 @@ register_configvar(group,
allow_reset = False,
)
+
+register_configvar(group,
+ "failed_notification_horizon",
+ Age(
+ title = _("Failed notification horizon"),
+ help = _("The tactical overview snapin is reporing about notifications that could not be sent "
+ "by Check_MK. Users with the permission \"See failed Notifications (all)\" get the number "
+ "of failed notification within the configured horizon."),
+ default_value = 60*60*24*7,
+ display = ["days"],
+ minvalue = 60*60*24,
+ ),
+ domain = "multisite")