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