Module: check_mk
Branch: master
Commit: 6792e20d14de548547ee8fe4a5d9f316d762f4ac
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6792e20d14de54…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 9 13:38:23 2014 +0100
ipmi_sensors: Radicale simplification of agent code - hopefully more robust
---
agents/check_mk_agent.linux | 42 +++++++-----------------------------------
1 file changed, 7 insertions(+), 35 deletions(-)
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 049b740..34f9b32 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -278,50 +278,22 @@ fi
# IPMI data via ipmi-sensors (of freeipmi). Please make sure, that if you
# have installed freeipmi that IPMI is really support by your hardware.
-# The agent tries to avoid hanging forever by setting a limit of 300 seconds
-# for the first run (where the cache is created). If ipmi-sensors runs into
-# that timeout, it leaves and empty cache file. We skip this check forever
-# if we find that empty cache file.
-sdrcache=/var/cache/.freeipmi/sdr-cache/sdr-cache-$(hostname | cut -d. -f1).127.0.0.1
-if type ipmi-sensors >/dev/null && [ ! -e "$sdrcache" -o -s
"$sdrcache" ]
+if type ipmi-sensors >/dev/null
then
echo '<<<ipmi_sensors>>>'
- # No cache file existing? => Impose a high time limit. We do not suffice
- # in creating the cache we most probably run on a hardware where this tool
- # is hanging forever. We make sure that we never try again in that case!
- if [ ! -e "$sdrcache" ]
- then
- WAITMAX="waitmax 300"
- elif tail --bytes 2 < "$sdrcache" | od -t x2 | grep -q 0a0a
- then
- WAITMAX="waitmax 3"
- else
- # Cache file corrupt. Must end with two linefeeds.
- rm -f $sdrcache
- WAITMAX=
- fi
# Newer ipmi-sensors version have new output format; Legacy format can be used
if ipmi-sensors --help | grep -q legacy-output; then
IPMI_FORMAT="--legacy-output"
else
IPMI_FORMAT=""
fi
- # On first run, before ipmi-sensors was first executed, the base directory is not
- # available. Make sure it exists, otherwise the following subshell creation will
fail
- mkdir -p "${sdrcache%/*}"
- # Aquire lock with flock in order to avoid multiple runs of ipmi-sensors
- # in case of parallel or overlapping calls of the agent.
- (
- flock -n 200 --wait 60
- # At least with ipmi-sensoirs 0.7.16 this group is Power_Unit instead of
"Power Unit"
- for class in Temperature Power_Unit Fan
- do
- $WAITMAX ipmi-sensors $IPMI_FORMAT --sdr-cache-directory /var/cache -g
"$class" | sed -e 's/ /_/g' -e 's/:_\?/ /g' -e 's@
\([^(]*\)_(\([^)]*\))@ \2_\1@'
- # In case of a timeout immediately leave loop.
+ # At least with ipmi-sensoirs 0.7.16 this group is Power_Unit instead of "Power
Unit"
+ run_cached -s ipmi_sensors 300 "for class in Temperature Power_Unit Fan
+ do
+ ipmi-sensors $IPMI_FORMAT --sdr-cache-directory /var/cache -g "$class"
| sed -e 's/ /_/g' -e 's/:_\?/ /g' -e 's@ \([^(]*\)_(\([^)]*\))@
\2_\1@'
+ # In case of a timeout immediately leave loop.
if [ $? = 255 ] ; then break ; fi
- WAITMAX="waitmax 3"
- done
- ) 200>>"$sdrcache"
+ done"
fi
# RAID status of Linux software RAID