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)
Article Comments
This is the result of the log file
[INFO][01-12-2016 13:36:25] Opening Connection
[INFO][01-12-2016 13:36:25] Shell: $SHELL = /bin/bash16939 ? 00:00:00 bash
[INFO][01-12-2016 13:36:25] Sending command /var/prtg/scripts/mysql.sh
[INFO][01-12-2016 13:36:25] Sending EOF
[INFO][01-12-2016 13:36:25] Reading PaeSSH result
[INFO][01-12-2016 13:36:25] [STDOUT] 2:500:Service is not running.
[INFO][01-12-2016 13:36:25] [STDERR] sudo: no tty present and no askpass program specified
[INFO][01-12-2016 13:36:25] Sending exit
[INFO][01-12-2016 13:36:25] Sending EOF
Dec, 2016 - Permalink
Hi there,
But the script is responding with "2:500:Service is not running" as expected and as you described before, right?
Dec, 2016 - Permalink
The problem is that the service is running, and when i run the script from the server itself, it also says its running
Dec, 2016 - Permalink
Hi there,
Please stop the service (for testing). What sensor result do you get now in the logs?
Dec, 2016 - Permalink
Hi there,
Can you test it with a "testing-file", placed in the same directory as the "mysqld.pid"?
Dec, 2016 - Permalink
Hi there,
Please activate the "Write Sensor result to Disk" option within the sensor settings, what is the content of the log files? (They are located on the according remote probe under "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensor)\").
Perhaps the following guide could help you too, to monitor a process under Linux and report its status back to PRTG: https://helpdesk.paessler.com/en/support/solutions/articles/70771 [kb.paessler.com].
Dec, 2016 - Permalink