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.
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.
Dec, 2021 - Permalink