Hey
I'm trying to setup some custom SSH script sensors for a linux MySQL server.
This is how my first script looked:
- !/bin/bash if ps -p $(cat /var/run/mysqld/mysqld.pid) > /dev/null 2>&1 then echo "0:200:Service is running." #return code 0 = Sætter prtg sensor i OK mode else echo "2:500:Service not running." #return code 2 = Sætter prtg sensor i DOWN mode fi
Looks like the script worked as it was outputting the "2:500:Service not running." But when I ran the script on the server, it was outputting the "0:200:Service is running."
I previously used this script to monitor another service, and the .pid file there had a [noeol] tag. The mysql.pid doesent.
So I changed my script to look like this:
- !/bin/bash if ps -p $(sudo sed -e 's/^\(.\{4\}\).*/\1/' /var/run/mysqld/mysqld.pid) > /dev/null 2>&1 then echo "0:200:$service is running." #return code 0 = Sætter prtg sensor i OK mode else echo "2:500:$service not running." #return code 2 = Sætter prtg sensor i DOWN mode fi
This change would just return the first 4 characters of the .pid file (only 4 chars long)
But none of these scripts are working. Can anyone help with this issue? Permissions are sat to 777 for testing purposes. (And I have other scripts working with PRTG on the same server)
Add comment