Module: check_mk
Branch: master
Commit: 730d4f8d877935f9f627e61abec039fc134fcbc0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=730d4f8d877935…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Dec 4 16:23:41 2014 +0100
#1599 check_mk_agent.aix: Simple run_cached Feature for plugins
Like in the Linux and Solaris Agent, it's no possible to create subfolders in the
plugin folder with a number as name, who represents the cache time for
the contained plugins in minutes.
---
.werks/1599 | 11 +++++++++++
ChangeLog | 7 ++++---
agents/check_mk_agent.aix | 47 +++++++++++++++++++++++++++++++++++++++++----
3 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/.werks/1599 b/.werks/1599
new file mode 100644
index 0000000..1b36048
--- /dev/null
+++ b/.werks/1599
@@ -0,0 +1,11 @@
+Title: check_mk_agent.aix: Simple run_cached Feature for plugins
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417706510
+Class: feature
+
+Like in the Linux and Solaris Agent, it's no possible to create subfolders in the
plugin folder with a number as name, who represents the cache time for
+the contained plugins in minutes.
+
diff --git a/ChangeLog b/ChangeLog
index dbb37c0..7d13f6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,11 +48,12 @@
* 1616 drbd: Added support for Ahead/Behind cluster states (DRBD >= 8.3.10)
* 1626 Renamed service descriptions of filesystem, process and logwatch checks...
* 1627 megaraid_ldisks: Warn if current cache or write policy differs from logical
drive default policy...
- * 1597 bluecat_dhcp, bluecat_dns: Checks can now be used in Check_MK Cluster Mode
* 1629 check_mk_agent.freebsd: several new features and improvements, now only use
statgrab...
* 1630 smart: update in plugin that also outputs information about disks attached to
a MegaRAID controller...
* 1631 juniper_bgp_state: check now detects and supports more differen device
models...
* 1645 Added basic kernel section to FreeBSD agent...
+ * 1597 bluecat_dhcp, bluecat_dns: Checks can now be used in Check_MK Cluster Mode
+ * 1599 check_mk_agent.aix: Simple run_cached Feature for plugins...
* 1478 FIX: kernel.util, statgrab_cpu: fix computation of utilization...
* 1480 FIX: brocade_vdx_status: disable check on some devices that do not support
it...
* 1485 FIX: dell_om_disks, dell_om_esmlog, dell_om_mem, dell_om_processors,
dell_om_sensors: detect more devices...
@@ -95,12 +96,12 @@
* 1617 FIX: lnx_if: Deal with data provided by cluster host
* 1618 FIX: ad_replication: Output of timeLastSuccess and timeLastFailure was
inverted...
* 1623 FIX: hp_proliant_mem: support for some yet unhandled status situations
- * 1598 FIX: bluecat_dhcp: Check is not longer found in inventory if dhcp service is
not activated
* 1640 FIX: check_jolokia_metrics_serv_req: Fixed wrong levels shown for upper
thresholds
- * 1453 FIX: drbd.stats: tried to send non-numeric write order parameter to rrd...
* 1632 FIX: hr_fs: remove ugly "mounted on:" information appearing on
Juniper devices
* 1646 FIX: hyperv_vms: Plugin garbles following plugin output when no VMs exist...
* 1647 FIX: agent_ipmi: Check_MK service gets critical now when ipmi-sensors command
fails
+ * 1453 FIX: drbd.stats: tried to send non-numeric write order parameter to rrd...
+ * 1598 FIX: bluecat_dhcp: Check is not longer found in inventory if dhcp service is
not activated
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/agents/check_mk_agent.aix b/agents/check_mk_agent.aix
index 7ae1c61..5f92d63 100755
--- a/agents/check_mk_agent.aix
+++ b/agents/check_mk_agent.aix
@@ -27,8 +27,8 @@
export LC_ALL=C
unset LANG
-export MK_LIBDIR="/to/be/changed"
-export MK_CONFDIR="/to/be/changed"
+export MK_LIBDIR="/usr/check_mk/lib"
+export MK_CONFDIR="/usr/check_mk/conf"
# All executables in PLUGINSDIR will simply be executed and their
# ouput appended to the output of the agent. Plugins define their own
@@ -54,7 +54,7 @@ fi
# Shell version of the waitmax utility, that limits the runtime of
# commands. This version does not conserve the original exit code
# of the command. It is successfull if the command terminated
-# in time.
+ # in time.
function waitmax
{
TIMEOUT=${1}0
@@ -81,8 +81,36 @@ function waitmax
return 255
}
+function run_cached {
+ NAME=$1
+ MAXAGE=$2
+ shift 2
+ CMDLINE=$*
+ MAXAGE=$MAXAGE*60
+
+ CACHE_FILE=/tmp/$NAME.cache
+
+ USE_CACHE_FILE=""
+ # Check if file exists and is recent enough
+ if [ -s $CACHE_FILE ]
+ then
+ MTIME=$(/usr/bin/perl -e 'if (! -f $ARGV[0]){die
"0000000"};$mtime=(stat($ARGV[0]))[9];print ($^T-$mtime);' $CACHE_FILE )
+ if (( $MTIME < $MAXAGE )) ; then
+ USE_CACHE_FILE=1
+ fi
+ fi
+ if [ -s "$CACHE_FILE" ]
+ then
+ cat $CACHE_FILE
+ fi
+ if [ -z "$USE_CACHE_FILE" -a ! -e "$CACHE_FILE.new" ]
+ then
+ nohup sh -c $CMDLINE > $CACHE_FILE.new 2> /dev/null && mv
$CACHE_FILE.new $CACHE_FILE &
+ fi
+}
+
echo '<<<check_mk>>>'
-echo Version: 1.2.5i7
+echo Version: 2014.12.01
echo AgentOS: aix
echo '<<<df>>>'
@@ -189,6 +217,13 @@ then
./$skript
fi
done
+
+ # Call some plugins only every X'th second
+ for skript in [1-9]*/* ; do
+ if [ -x "$skript" ] ; then
+ run_cached plugins_${skript//\//\#} ${skript%/*} "$skript"
+ fi
+ done
fi
@@ -201,6 +236,7 @@ then
./$skript
fi
done
+
fi
# MK's Remote Plugin Executor
@@ -215,3 +251,6 @@ then
echo "(${PLUGIN##*/}) $descr $? $OUTPUT"
done
fi
+
+
+