Browse Source

Small changes

master
Yavuz Aydın 2 months ago
parent
commit
73e0059139
  1. 9
      restart_service

9
restart_service

@ -21,12 +21,13 @@ if ( [ -z $servicestate ] || [ -z $servicestatetype ] || [ -z $serviceattempt ]
echo "USAGE: $0 -s servicestate -z servicestatetype -a serviceattempt -S service"
exit 3;
else
# Only restart on the third attempt of a critical event
if ( [ $servicestate == "CRITICAL" ] && [ $servicestatetype == "SOFT" ] && [ $serviceattempt -eq 3 ] ); then
if [ pidof systemd >/dev/null ]; then
# Only restart on the third attempt of a critical event in soft state and in first attempt of a critical event in hard state
if [ $servicestate == "CRITICAL" ] && ( ( [ $serviceattempt -eq 3 ] && [ $servicestatetype == "SOFT" ] ) || ( [ $serviceattempt -eq 1 ] && [ $servicestatetype == "HARD" ] ) ); then
pidof systemd >/dev/null
if [ $? -eq 0 ]; then
sudo systemctl restart $service
else
sudo service $service restart
fi
fi
fi
fi
Loading…
Cancel
Save