Module: check_mk
Branch: master
Commit: 176d9cdfc22b69adf69540d79b7cc8488d061f53
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=176d9cdfc22b69…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Mar 5 14:45:40 2013 +0100
FIX: fix deadlock due to lock on contacts.mk
---
ChangeLog | 1 +
web/htdocs/index.py | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8b70289..c7a6884 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -96,6 +96,7 @@
* FIX: sidebar snapins which refresh do not register for restart detection anymore
* FIX: fix user database corruption in case of a race condition
* FIX: added checks wether or not a contactgroup can be deleted
+ * FIX: Avoid deadlock due to lock on contacts.mk in some situations
* Changed sidebar snapin reload to a global interval (option:
sidebar_update_interval), defaults to 30 seconds
* Sidebar snapins are now bulk updated with one HTTP request each interval
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index ffd836c..81fd8a8 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -236,6 +236,7 @@ def handler(req, profiling = True):
retcode = cProfile.run("import index; from mod_python import apache; index.handler(apache._profiling_req, False)", profilefile)
file(profilefile + ".py", "w").write("#!/usr/bin/python\nimport pstats\nstats = pstats.Stats(%r)\nstats.sort_stats('time').print_stats()\n" % profilefile)
os.chmod(profilefile + ".py", 0755)
+ release_all_locks()
return apache.OK
# Make sure all plugins are avaiable as early as possible. At least
@@ -271,6 +272,7 @@ def handler(req, profiling = True):
handler()
except Exception, e:
html.write(str(e))
+ release_all_locks()
return apache.OK
# Prepare output format
@@ -300,6 +302,7 @@ def handler(req, profiling = True):
req.myfile = req.uri.split("/")[-1][:-3]
handler = pagehandlers.get(req.myfile, page_not_found)
else:
+ release_all_locks()
return result
# Call userdb page hooks which are executed on a regular base to e.g. syncronize
Module: check_mk
Branch: master
Commit: 494fc39c32de77f435195abb05c6c6fea0577668
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=494fc39c32de77…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Mar 4 21:43:19 2013 +0100
Fixed typo
---
checkman/apache_status | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/checkman/apache_status b/checkman/apache_status
index b5648f9..5f35356 100644
--- a/checkman/apache_status
+++ b/checkman/apache_status
@@ -12,7 +12,7 @@ description:
but it fetches interesting performance data.
As a preparation you need to install the agent plugin {apache_status}
- into you agent's plugins directory (usually {/usr/lib/check_mk_agent/plugins}).
+ into your agent's plugins directory (usually {/usr/lib/check_mk_agent/plugins}).
The plugin tries to autodetect all running apache servers. If that fails
for some reason you need to create the configuration file
{/etc/check_mk/apache_status.cfg} and list your servers here. Write
Module: check_mk
Branch: master
Commit: d43cda4f4e4f11fe02652c9ffa18bce6719b3522
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d43cda4f4e4f11…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Mar 4 21:47:21 2013 +0100
Added README for cached agent plugins
---
agents/plugins/README | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/agents/plugins/README b/agents/plugins/README
new file mode 100644
index 0000000..8072aff
--- /dev/null
+++ b/agents/plugins/README
@@ -0,0 +1,17 @@
+These plugins can be installed in the plugins directory of the
+Linux agent in /usr/lib/check_mk_agent/plugins/. Please only install
+the plugins that you really need.
+
+If you want a plugin to be run asynchronously and also in
+a larger interval then the normal check interval, then you can
+copy it to a subdirectory named after a number of seconds,
+e.g.:
+
+/usr/lib/check_mk_agent/plugins/3600/mk_zypper
+
+In that case the agent will:
+
+ - Run this plugin in the background and wait not for it to finish.
+ - Store the result of the plugin in a cache file below /etc/check_mk/cache.
+ - Use that file for 300 seconds before running the script again.
+
Module: check_mk
Branch: master
Commit: 96f52f9bd3d097ee3b65756708687e09d90c607e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=96f52f9bd3d097…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Mar 4 21:28:23 2013 +0100
Linux agent: allow cached local/plugins checks (see docu)
---
ChangeLog | 1 +
agents/check_mk_agent.linux | 128 ++++++++++++++++++++++--------------------
2 files changed, 68 insertions(+), 61 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3824518..e9324bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,7 @@
new param post can now be configured via int and float, now
supports percentage values
* mounts: ignore multiple occurrances of the same device
+ * Linux agent: allow cached local/plugins checks (see docu)
Livestatus:
* Table statehist: Improved detection of vanished hosts and services.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index c5ebbfe..5eb5e6f 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -52,6 +52,33 @@ else
exec <&- 2>/dev/null
fi
+# Runs a command asynchronous by use of a cache file
+function run_cached () {
+ if [ "$1" = -s ] ; then local section="echo '<<<$2>>>' ; " ; shift ; fi
+ local NAME=$1
+ local MAXAGE=$2
+ shift 2
+ local CMDLINE="$section$@"
+
+ if [ ! -d $MK_CONFDIR/cache ]; then mkdir -p $MK_CONFDIR/cache ; fi
+ CACHEFILE="$MK_CONFDIR/cache/$NAME.cache"
+
+ # Check if cache file exists and is recent enough
+ if [ -s "$CACHEFILE" ] ; then
+ local NOW=$(date +%s)
+ local MTIME=$(stat -c %Y "$CACHEFILE")
+ if [ $((NOW - MTIME)) -le $MAXAGE ] ; then local USE_CACHEFILE=1 ; fi
+ # Output the file in any case, even if it is
+ # outdated. The new file will not yet be available
+ cat "$CACHEFILE"
+ fi
+
+ # Cache file outdated and new job not yet running? Start it
+ if [ -z "$USE_CACHEFILE" -a ! -e "$CACHEFILE.new" ] ; then
+ echo "$CMDLINE" | setsid bash -o noclobber > $CACHEFILE.new && mv $CACHEFILE.new $CACHEFILE || rm -f $CACHEFILE $CACHEFILE.new &
+ fi
+}
+
echo '<<<check_mk>>>'
echo Version: 1.2.3i1
echo AgentOS: linux
@@ -224,39 +251,10 @@ date +%s
sed -e 1,2d -e 's/:/ /g' < /proc/net/dev
-if type ipmitool >/dev/null
+# Hardware sensors via IPMI (need ipmitool)
+if type ipmitool > /dev/null
then
- echo '<<<ipmi>>>'
- IPMI_FILE=$MK_CONFDIR/ipmitool_sensors.cache
- if [ ! -d $MK_CONFDIR ]; then
- mkdir -p $MK_CONFDIR
- fi
-
- # Do not use cache file after 20 minutes
- IPMI_MAXAGE=1200
-
- # Check if file exists and is recent enough
- if [ -s $IPMI_FILE ]
- then
- NOW=$(date +%s)
- MTIME=$(stat -c %Y $IPMI_FILE)
- if [ $((NOW - MTIME)) -le $IPMI_MAXAGE ] ; then
- USE_IPMI_FILE=1
- fi
- fi
-
- if [ -s "$IPMI_FILE" ]
- then
- grep -v 'command failed' "$IPMI_FILE" \
- | sed -e 's/ *| */|/g' -e "s/ /_/g" -e 's/_*$//' -e 's/|/ /g' \
- | egrep -v '^[^ ]+ na ' \
- | grep -v ' discrete '
- fi
-
- if [ -z "$USE_IPMI_FILE" -a ! -e "$IPMI_FILE.new" ]
- then
- setsid bash -c "set -o noclobber ; ipmitool sensor list > $IPMI_FILE.new && mv $IPMI_FILE.new $IPMI_FILE || rm -f $IPMI_FILE*" &
- fi
+ run_cached -s ipmi 300 "ipmitool sensor list | grep -v 'command failed' | sed -e 's/ *| */|/g' -e 's/ /_/g' -e 's/_*"'$'"//' -e 's/|/ /g' | egrep -v '^[^ ]+ na ' | grep -v ' discrete '"
fi
@@ -358,9 +356,8 @@ if [ -e /etc/openvpn/openvpn-status.log ] ; then
fi
if type ntpq > /dev/null 2>&1 ; then
- echo '<<<ntp>>>'
- # remote heading, make first column space separated
- waitmax 2 ntpq -p | sed -e 1,2d -e 's/^\(.\)/\1 /' -e 's/^ /%/'
+ # remove heading, make first column space separated
+ run_cached -s ntp 30 "waitmax 5 ntpq -p | sed -e 1,2d -e 's/^\(.\)/\1 /' -e 's/^ /%/'"
fi
if type nvidia-settings >/dev/null && [ -S /tmp/.X11-unix/X0 ]
@@ -431,8 +428,7 @@ fi
# Check status of OMD sites
if type omd >/dev/null
then
- echo '<<<omd_status>>>'
- omd status --bare --auto
+ run_cached omd_status 60 "echo '<<<omd_status>>>' ; omd status --bare --auto"
fi
@@ -467,30 +463,6 @@ then
done
fi
-
-# Einbinden von lokalen Plugins, die eine eigene Sektion ausgeben
-if cd $PLUGINSDIR
-then
- for skript in $(ls)
- do
- if [ -x "$skript" ] ; then
- ./$skript
- fi
- done
-fi
-
-# Lokale Einzelchecks
-echo '<<<local>>>'
-if cd $LOCALDIR
-then
- for skript in $(ls)
- do
- if [ -x "$skript" ] ; then
- ./$skript
- fi
- done
-fi
-
# MK's Remote Plugin Executor
if [ -e "$MK_CONFDIR/mrpe.cfg" ]
then
@@ -504,3 +476,37 @@ then
echo
done
fi
+
+
+# Local checks
+echo '<<<local>>>'
+if cd $LOCALDIR ; then
+ for skript in $(ls) ; do
+ if [ -f "$skript" -a -x "$skript" ] ; then
+ ./$skript
+ fi
+ done
+ # Call some plugins only every X'th minute
+ for skript in [1-9]*/* ; do
+ if [ -x "$skript" ] ; then
+ run_cached local_${skript//\//\\} ${skript%/*} "$skript"
+ fi
+ done
+fi
+
+# Plugins
+if cd $PLUGINSDIR ; then
+ for skript in $(ls) ; do
+ if [ -f "$skript" -a -x "$skript" ] ; then
+ ./$skript
+ fi
+ done
+ # Call some plugins only every X'th minute
+ for skript in [1-9]*/* ; do
+ if [ -x "$skript" ] ; then
+ run_cached plugins_${skript//\//\\} ${skript%/*} "$skript"
+ fi
+ done
+fi
+
+