]> granicus.if.org Git - icinga2/blob - test/jenkins/statusdata.test
Update consolecommand.cpp
[icinga2] / test / jenkins / statusdata.test
1 #!/bin/bash
2
3 statusdata_path="/var/cache/icinga2/status.dat"
4 objectscache_path="/var/cache/icinga2/objects.cache"
5
6 if [ ! -f $statusdata_path ];
7 then
8     sudo icinga2 feature enable statusdata 1> /dev/null
9     sudo service icinga2 restart 1> /dev/null
10
11     n=0
12     while [ $n -lt 3 ]
13     do
14         sleep 15
15
16         if [ -f $statusdata_path ];
17         then
18             break
19         fi
20
21         n=$(( $n + 1))
22     done
23
24     if [ $n -eq 3 ];
25     then
26         echo "[FAIL] Icinga2 status.dat not found ($statusdata_path)"
27         exit 1
28     fi
29 fi
30
31 echo "[OK] Icinga2 status.dat found ($statusdata_path)"
32
33 if [ -f $objectscache_path ];
34 then
35     echo "[OK] Icinga2 objects.cache found ($objectscache_path)"
36 else
37     echo "[FAIL] Icinga2 objects.cache not found ($objectscache_path)"
38     exit 1
39 fi
40
41 status_time=$(stat --format="%Y" $statusdata_path)
42
43 now=$(date +"%s")
44 sleep $(((15 + 5) - ($now - $status_time)))
45
46 new_status_time=$(stat --format="%Y" $statusdata_path)
47
48 if [ $new_status_time -eq $status_time ];
49 then
50     echo "[FAIL] Icinga2 status.dat is not being updated (Last update: $(date -r $statusdata_path '+%x %X'))"
51     exit 1
52 else
53     echo "[OK] Icinga2 status.dat is being updated (Last update: $(date -r $statusdata_path '+%x %X'))"
54 fi