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.


Article Comments

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.


May, 2020 - Permalink

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 ?


May, 2020 - Permalink

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.


May, 2020 - Permalink

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.


May, 2020 - Permalink

Dear jerem87,

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


May, 2020 - Permalink