Hi,

Can I monitor if a service is running or not, on a Linux machine, without installing an agent, or SNMP or anything? Just by using an SSH sensor?

Thanks


Article Comments

Dear aristosv

Yes – as long as you can put the according shell script to check the status of that service on the machine you wish to monitor.

The script must be located in /var/prtg/scripts

Now that script can be run using the SSH Script sensor.


May, 2015 - Permalink

I found 3 scripts on this thread, and i tried all of them but no luck.

https://helpdesk.paessler.com/en/support/solutions/articles/76000063557-is-there-a-shell-script-example-for-prtg-s-ssh-script-sensor

The difference is that I am not trying to monitor a service, but a running process. (i made a mistake on the title of this thread)

So none of the commands for processes work.

Is there something for monitoring processes, rather than services?

Thanks


May, 2015 - Permalink

Dear aristosv

I am not aware of a ready-to-use script in our knowledge base.

On many Unix-like systems you get a process list with ps. Using command options like ps -aux provides a more detailed list. Using grep or other string filter commands you can check if a particular process is running. If you can create a script which works, please post it into this KB thread for others to use.


May, 2015 - Permalink

I'm new to PRTG but did get this going with a bit of help from Andrew Jones post on https://helpdesk.paessler.com/en/support/solutions/articles/76000063557-is-there-a-shell-script-example-for-prtg-s-ssh-script-sensor ,

As per above. Create the folder /var/prtg/scripts Make a new script file eg. vi query_process.sh Add the lines below;

#!/bin/sh

pgrep $1  2>&1 1>/dev/null

if [ $? -ne 0 ]; then 
  echo "1:$?:$1 Down"
else
  echo "0:$?:OK"
fi

Save the file and make it executable with: chmod +x query_process.sh If not executable, the sensor wont allow you add the script by name when adding the sensor.

Add the ssh script sensor in PRTG to the device (make sure your SSH Credentials have been set correctly) Set the parameter field of the sensor to the process name -eg. ntpd

ps -e

will give you a list of available processes to query.

Cheers


Aug, 2016 - Permalink

Thanks for sharing! :)


Aug, 2016 - Permalink

One more, thanks for sharing, this is what worked best to monitor linux processes in PRTG. One note, I was trying to monitor if Node-Red was running, but using "node-red" as parameter for the process name didn't work. It happens that for some reason under "ps -e" Node-Red shows as "node".


Feb, 2021 - Permalink

Hello Tales,

After a short verification, on Ubuntu the service is indeed called node-red. How do you have installed Node-Red ? On which OS ? How do you run it ? With which command ?

Regards.


Feb, 2021 - Permalink

Hi there,

Replying, better late than never: I'm running NR on an Ubuntu machine, and I installed it using the script built for the Raspberry Pi that can be found here:

https://nodered.org/docs/getting-started/raspberrypi

The install script makes available a series of scripts to handle the application, like node-red-start, node-red-stop and so on. In my case I run node-red as a system service.

The original server was running node-red v1.x. Yesterday I deployed an updated server and installed node-red v3. Now the service name is node-red as one would expect.


Jan, 2024 - Permalink