2013-12-05 09:46:51 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
if [ ! -f /var/cache/icinga2/status.dat ];
|
|
|
|
then
|
|
|
|
sudo icinga2-enable-feature statusdata 1> /dev/null
|
|
|
|
sudo service icinga2 restart 1> /dev/null
|
|
|
|
|
|
|
|
n=0
|
|
|
|
while [ $n -lt 3 ]
|
|
|
|
do
|
|
|
|
sleep 15
|
|
|
|
|
|
|
|
if [ -f /var/cache/icinga2/status.dat ];
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
n=$(( $n + 1))
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $n -eq 3 ];
|
|
|
|
then
|
2014-02-14 16:05:58 +01:00
|
|
|
echo "[FAIL] Icinga2 status.dat not found"
|
2013-12-05 09:46:51 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-02-14 16:05:58 +01:00
|
|
|
echo "[OK] Icinga2 status.dat found"
|
2013-12-05 09:46:51 +01:00
|
|
|
|
|
|
|
if [ -f /var/cache/icinga2/objects.cache ];
|
|
|
|
then
|
2014-02-14 16:05:58 +01:00
|
|
|
echo "[OK] Icinga2 objects.cache found"
|
2013-12-05 09:46:51 +01:00
|
|
|
else
|
2014-02-14 16:05:58 +01:00
|
|
|
echo "[FAIL] Icinga2 objects.cache not found"
|
2013-12-05 09:46:51 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2013-12-10 12:37:51 +01:00
|
|
|
|
|
|
|
status_time=$(stat --format="%Y" /var/cache/icinga2/status.dat)
|
|
|
|
|
|
|
|
now=$(date +"%s")
|
|
|
|
sleep $(((15 + 5) - ($now - $status_time)))
|
|
|
|
|
|
|
|
new_status_time=$(stat --format="%Y" /var/cache/icinga2/status.dat)
|
|
|
|
|
|
|
|
if [ $new_status_time -eq $status_time ];
|
|
|
|
then
|
2014-02-14 16:05:58 +01:00
|
|
|
echo "[FAIL] Icinga2 status.dat is not being updated"
|
2013-12-10 12:37:51 +01:00
|
|
|
exit 1
|
|
|
|
else
|
2014-02-14 16:05:58 +01:00
|
|
|
echo "[OK] Icinga2 status.dat is being updated"
|
2013-12-10 12:37:51 +01:00
|
|
|
fi
|