icinga2/test/jenkins/nsca-ng.test

30 lines
942 B
Bash
Executable File

#!/bin/sh
pid_before_restart=`ps -U icinga | grep icinga2 | awk '{print $1}'`
echo 'RESTART_PROCESS' | sudo send_nsca -C
sleep 3
pid_after_restart=`ps -U icinga | grep icinga2 | awk '{print $1}'`
if [ $pid_after_restart -eq $pid_before_restart ]; then
echo "Failed to send 'RESTART_PROCESS' to icinga2"
exit 1
else
echo "Successfully sent 'RESTART_PROCESS' to icinga2"
fi
printf "localhost\t0\tA passive result returning OK\n" | sudo send_nsca
if [ $? -gt 0 ]; then
echo "Failed to send passive check result for host 'localhost'"
exit 1
else
echo "Successfully sent a passive check result for host 'localhost'"
fi
printf "localhost\tdisk\t2\tA passive result not returning OK\n" | sudo send_nsca
if [ $? -gt 0 ]; then
echo "Failed to send passive check result for service 'disk' on host 'localhost'"
exit 1
else
echo "Successfully sent a passive check result for service 'disk' on host 'localhost'"
fi