icinga2/test/jenkins/statusdata.test

55 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2013-12-05 09:46:51 +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
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
if [ -f $statusdata_path ];
2013-12-05 09:46:51 +01:00
then
break
fi
n=$(( $n + 1))
done
if [ $n -eq 3 ];
then
echo "[FAIL] Icinga2 status.dat not found ($statusdata_path)"
2013-12-05 09:46:51 +01:00
exit 1
fi
fi
echo "[OK] Icinga2 status.dat found ($statusdata_path)"
2013-12-05 09:46:51 +01:00
if [ -f $objectscache_path ];
2013-12-05 09:46:51 +01:00
then
echo "[OK] Icinga2 objects.cache found ($objectscache_path)"
2013-12-05 09:46:51 +01:00
else
echo "[FAIL] Icinga2 objects.cache not found ($objectscache_path)"
2013-12-05 09:46:51 +01:00
exit 1
fi
status_time=$(stat --format="%Y" $statusdata_path)
now=$(date +"%s")
sleep $(((15 + 5) - ($now - $status_time)))
new_status_time=$(stat --format="%Y" $statusdata_path)
if [ $new_status_time -eq $status_time ];
then
echo "[FAIL] Icinga2 status.dat is not being updated (Last update: $(date -r $statusdata_path '+%x %X'))"
exit 1
else
echo "[OK] Icinga2 status.dat is being updated (Last update: $(date -r $statusdata_path '+%x %X'))"
fi