def main():
failure = test_host_comments('localhost')
- #failure &= test_host_comments('nsca-ng') # Cannot work without a hostcheck!
+ #failure |= test_host_comments('nsca-ng') # Cannot work without a hostcheck!
- failure &= test_service_comments('localhost', 'disk')
- failure &= test_service_comments('nsca-ng', 'PassiveService1')
+ failure |= test_service_comments('localhost', 'disk')
+ failure |= test_service_comments('nsca-ng', 'PassiveService1')
- failure &= test_host_downtimes('localhost')
- #failure &= test_host_downtimes('nsca-ng')
+ failure |= test_host_downtimes('localhost')
+ #failure |= test_host_downtimes('nsca-ng')
- failure &= test_service_downtimes('localhost', 'disk')
- failure &= test_service_downtimes('nsca-ng', 'PassiveService1')
+ failure |= test_service_downtimes('localhost', 'disk')
+ failure |= test_service_downtimes('nsca-ng', 'PassiveService1')
- failure &= test_host_problem_acknowledgements('localhost')
- failure &= test_remove_host_acknowledgements('localhost')
- failure &= test_expiring_host_acknowledgements('localhost')
+ failure |= test_host_problem_acknowledgements('localhost')
+ failure |= test_remove_host_acknowledgements('localhost')
+ failure |= test_expiring_host_acknowledgements('localhost')
- failure &= test_change_host_check_command('localhost', 'disk')
- failure &= test_change_service_check_command('localhost', 'disk', 'ping4')
- failure &= test_change_host_check_timeperiod('localhost', 'none')
- failure &= test_change_service_check_timeperiod('localhost', 'disk', 'none')
- failure &= test_change_host_max_check_attempts('localhost')
- failure &= test_change_service_max_check_attempts('localhost', 'disk')
- failure &= test_change_host_normal_check_interval('localhost')
- failure &= test_change_service_normal_check_interval('localhost', 'disk')
- failure &= test_change_host_retry_check_interval('localhost')
- failure &= test_change_service_retry_check_interval('localhost', 'disk')
- failure &= test_change_host_modified_attributes('localhost')
+ failure |= test_change_host_check_command('localhost', 'disk')
+ failure |= test_change_service_check_command('localhost', 'disk', 'ping4')
+ failure |= test_change_host_check_timeperiod('localhost', 'none')
+ failure |= test_change_service_check_timeperiod('localhost', 'disk', 'none')
+ failure |= test_change_host_max_check_attempts('localhost')
+ failure |= test_change_service_max_check_attempts('localhost', 'disk')
+ failure |= test_change_host_normal_check_interval('localhost')
+ failure |= test_change_service_normal_check_interval('localhost', 'disk')
+ failure |= test_change_host_retry_check_interval('localhost')
+ failure |= test_change_service_retry_check_interval('localhost', 'disk')
+ failure |= test_change_host_modified_attributes('localhost')
- failure &= test_delay_service_notification('localhost', 'disk')
- failure &= test_delay_host_notification('localhost')
+ failure |= test_delay_service_notification('localhost', 'disk')
+ failure |= test_delay_host_notification('localhost')
- failure &= test_disabling_scheduling_host_checks('localhost')
- failure &= test_disabling_scheduling_service_checks('localhost', 'disk')
+ failure |= test_disabling_scheduling_host_checks('localhost')
+ failure |= test_disabling_scheduling_service_checks('localhost', 'disk')
- failure &= test_shutdown_restart_process()
+ failure |= test_shutdown_restart_process()
- failure &= test_passive_host_checkresult_processing('localhost')
- failure &= test_passive_svc_checkresult_processing('localhost', 'disk')
+ failure |= test_passive_host_checkresult_processing('localhost')
+ failure |= test_passive_svc_checkresult_processing('localhost', 'disk')
- failure &= test_process_file('localhost')
+ failure |= test_process_file('localhost')
- failure &= test_custom_host_notifications('localhost')
- failure &= test_custom_svc_notifications('localhost', 'disk')
+ failure |= test_custom_host_notifications('localhost')
+ failure |= test_custom_svc_notifications('localhost', 'disk')
- failure &= test_hostgroup_commands()
- failure &= test_servicegroup_commands()
+ failure |= test_hostgroup_commands()
+ failure |= test_servicegroup_commands()
return 1 if failure else 0
-#!/bin/sh
+#!/bin/bash
-if [ ! -f /var/cache/icinga2/status.dat ];
+statusdata_path="/var/cache/icinga2/status.dat"
+objectscache_path="/var/cache/icinga2/objects.cache"
+
+if [ ! -f $statusdata_path ];
then
sudo icinga2-enable-feature statusdata 1> /dev/null
sudo service icinga2 restart 1> /dev/null
do
sleep 15
- if [ -f /var/cache/icinga2/status.dat ];
+ if [ -f $statusdata_path ];
then
break
fi
if [ $n -eq 3 ];
then
- echo "[FAIL] Icinga2 status.dat not found"
+ echo "[FAIL] Icinga2 status.dat not found ($statusdata_path)"
exit 1
fi
fi
-echo "[OK] Icinga2 status.dat found"
+echo "[OK] Icinga2 status.dat found ($statusdata_path)"
-if [ -f /var/cache/icinga2/objects.cache ];
+if [ -f $objectscache_path ];
then
- echo "[OK] Icinga2 objects.cache found"
+ echo "[OK] Icinga2 objects.cache found ($objectscache_path)"
else
- echo "[FAIL] Icinga2 objects.cache not found"
+ echo "[FAIL] Icinga2 objects.cache not found ($objectscache_path)"
exit 1
fi
-status_time=$(stat --format="%Y" /var/cache/icinga2/status.dat)
+status_time=$(stat --format="%Y" $statusdata_path)
now=$(date +"%s")
sleep $(((15 + 5) - ($now - $status_time)))
-new_status_time=$(stat --format="%Y" /var/cache/icinga2/status.dat)
+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"
+ 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"
+ echo "[OK] Icinga2 status.dat is being updated (Last update: $(date -r $statusdata_path '+%x %X'))"
fi