What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Custom SSH sensor

Votes:

0

Hey

I'm trying to setup some custom SSH script sensors for a linux MySQL server.

This is how my first script looked:

  1. !/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:

  1. !/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)

mysql prtg script ssh

Created on Dec 1, 2016 12:56:11 PM



7 Replies

Votes:

0

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://kb.paessler.com/en/topic/70771 [kb.paessler.com].

Created on Dec 1, 2016 1:30:10 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

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

Created on Dec 1, 2016 1:38:11 PM



Votes:

0

Hi there,

But the script is responding with "2:500:Service is not running" as expected and as you described before, right?

Created on Dec 1, 2016 1:41:53 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

The problem is that the service is running, and when i run the script from the server itself, it also says its running

Created on Dec 1, 2016 1:44:20 PM



Votes:

0

Hi there,

Please stop the service (for testing). What sensor result do you get now in the logs?

Created on Dec 1, 2016 1:52:47 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

Cant do that, it's a production server.

Created on Dec 2, 2016 8:15:50 AM



Votes:

0

Hi there,

Can you test it with a "testing-file", placed in the same directory as the "mysqld.pid"?

Created on Dec 2, 2016 10:02:27 AM by  Dariusz Gorka [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.