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

I would like, via the SSH sensor, to retrieve the number contained in the response of an order

Votes:

0

Hello,

Objective: to know the number of users connected to an OpenVPN Access Server.

What I want to do seems very simple: I would like, via the SSH sensor, to retrieve the number contained in the response of an order.

The original order: ./sacli VPNSummary

The result is: {   "n_clients": 1 }

I found 2 ways to get out that number but PRTG can't read it.

1st solution tried: creation of a script with my order which filters only the figures:

  1. ! / bin / bash  ./sacli VPNSummary | grep -o '[0-9] \ +'

The result is: 1

Observation with SSH console: the script works: it displays only the number. Observation with PRTG: it finds an empty answer

2nd solution tried: creation of a script with my order which filters only the figures:

  1. ! / bin / bash $ NUMBER = $. / Sacli VPNSummary | grep -o '[0-9] \ +' $ echo $ NUMBER

The result is: 1

Observation with SSH console: the script works: it displays only the number. Observation with PRTG: it finds an empty answer

Finally, I thought of sending my result with a cron task in a text file but by default, PRTG is not able to read a file under Linux without SMB.

Do you have an idea ?

Thank you in advance.

openvpn ssh ssh-script

Created on May 21, 2020 12:13:34 PM



5 Replies

Votes:

0

Dear jerem87,

in order to get a PRTG compatible result, please use the format returncode:value:message, like

0:1:1 container(s) found

You find the full documentation here.

Created on May 21, 2020 2:38:54 PM by  Arne Seifert [Paessler Support]



Votes:

0

Thank you very much for your answer.

I tried doing this:

NUMBER=$(./sacli VPNSummary | grep -o '[0-9]\+') echo 0:$NUMBER:$NUMBER

But PRTG cannot read the number. Error : "PRTG could not execute the script, or the output could not be interpreted (: ). (code: PE129)

However, the result of this command from a console is good: 0:3:3

What do you think ?

Created on May 21, 2020 7:02:30 PM



Votes:

0

Dear jerem87,

please enable the "Write result to disk" option in the sensor. After the next scan, you find the logs in "C:\ProgramData\Paessler\PRTG Network Monitor\Logs\sensors", they contain the output of the script when run through PRTG.

Created on May 22, 2020 12:40:12 PM by  Arne Seifert [Paessler Support]



Votes:

0

The logs helped me a lot. Which allowed me to see that I had to put myself in the right folder to run the script with a "cd".

Thanks for your help.

The functional script is:

  1. !/bin/bash cd /var/prtg/scripts/ NUMBER=$(./sacli VPNSummary | grep -o '[0-9]\+') echo 0:$NUMBER:$NUMBER

In detail, for those who would be interested in installing this sensor to monitor the number of simultaneous users of an OpenVPN Access server:

1 °) It is necessary to recover the script "sacli" of OpenVPN located in the folder: "/usr/local/openvpn_as/scripts/" and put it in the folder "/var/prtg/scripts/". This "sacli" script allows with the VPNSummary argument to know the connected users: "./sacli VPNSummary"

2 °) You must create a custom script and put it on the server in the "/ var / prtg / scripts /" folder on the monitored Linux:

  1. !/bin/bash cd /var/prtg/scripts/ NUMBER=$(./sacli VPNSummary | grep -o '[0-9]\+') echo 0:$NUMBER:$NUMBER

3 °) Then create an "SSH script" sensor in PRTG.

SSH authentication must also be configured so that PRTG can connect to it.

An alert threshold can be configured to monitor the use of server licenses.

Created on May 22, 2020 2:51:33 PM



Votes:

0

Dear jerem87,

thank you for the detailed follow-up, this might be helpful for other custom sensor creators.

Created on May 22, 2020 6:37:04 PM by  Arne Seifert [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.