Small changes

This commit is contained in:
Yavuz Aydın 2021-10-07 10:47:15 +02:00
parent 9e52f24654
commit 73e0059139
1 changed files with 5 additions and 4 deletions

View File

@ -21,9 +21,10 @@ 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