mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
fixed watchdog, so plugin restarts automatically if killed
This commit is contained in:
parent
962d614286
commit
ad72df158f
@ -17,26 +17,19 @@ style="AREA"
|
|||||||
cpus=$(grep -c ^processor /proc/cpuinfo)
|
cpus=$(grep -c ^processor /proc/cpuinfo)
|
||||||
|
|
||||||
run_watchdog() { # should also trap kill and term signals
|
run_watchdog() { # should also trap kill and term signals
|
||||||
while :; do
|
kill -0 $(cat $pidfile) 2> /dev/null || rm -f $pidfile
|
||||||
sleep ${watchdog:-600}
|
|
||||||
touch -d now-${timeout:-1200}sec $cache
|
|
||||||
[ $pidfile -nt $cache ] || break
|
|
||||||
done
|
|
||||||
[ -f $pidfile ] || exit # may have been removed by terminating daemon
|
|
||||||
kill $(cat $pidfile)
|
|
||||||
rm -f $pidfile $cache
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
run_acquire() {
|
run_acquire() {
|
||||||
echo "$$" > $pidfile
|
echo "$$" > $pidfile
|
||||||
$pluginfull watchdog &
|
|
||||||
mpstat -P ALL $interval |
|
mpstat -P ALL $interval |
|
||||||
awk -v cpus=$cpus '$2>=0&&$2<10 {print $2, systime(), (100-$11)/cpus}' >> $cache
|
awk -v cpus=$cpus '$2>=0&&$2<10 {print $2, systime(), (100-$11)/cpus}' >> $cache
|
||||||
rm -f $pidfile $cache
|
rm -f $pidfile $cache
|
||||||
}
|
}
|
||||||
|
|
||||||
run_daemon() {
|
run_daemon() {
|
||||||
|
run_watchdog
|
||||||
if [ -f $pidfile ]; then
|
if [ -f $pidfile ]; then
|
||||||
touch $pidfile
|
touch $pidfile
|
||||||
else
|
else
|
||||||
@ -92,4 +85,3 @@ exit 0
|
|||||||
# acquire which needs a different pid than watchdog, otherwise watchdog
|
# acquire which needs a different pid than watchdog, otherwise watchdog
|
||||||
# could/will kill itself when expiring before the watched process is killed.
|
# could/will kill itself when expiring before the watched process is killed.
|
||||||
# not a POSIX feature.
|
# not a POSIX feature.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user