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

SSH Script sensor - monitor process/service uptime

Votes:

0

I would like to use SSH script sensor to monitor process uptime. I have created a script under /var/prtg/scripts:

#!/bin/sh

ps -C java -o etimes= 2>&1 1>/dev/null

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

and i get 0:1:OK as the result which is fine because the service/process is running but the command: ps -C java -o etimes= gives service/process uptime in seconds and i would like that number in my result. Something like "0:25444:uptime in seconds". I guess that is doable but i'm doing something wrong.

Ty.

linux prtg ssh ssh-script ubuntu uptimr

Created on Dec 7, 2021 10:04:59 AM

Last change on Dec 7, 2021 3:03:41 PM by  Felix Wiesneth [Paessler Support]



1 Reply

Votes:

0

Hello,

Thank you for your message.

According to what you would like to achieve, I'm afraid that we do not provide official support for customizations however I invite you to create a variable in which the uptime value only should be stored. Here is an article which might help you in this regards: https://linuxhint.com/bash-substring-after-character/.

Then, you can use the variable in the response sent to PRTG by replacing $? with $variable.

If you have questions, do not hesitate.

Regards.

Created on Dec 9, 2021 1:55:47 PM by  Florian Lesage [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.