PRTG is a great Network monitoring tools for network admins. Out of box it works smoothly with Windows and Network devices. But for Linux service, which may be the core service for your company, it does not provide one-click monitor, you will need to do some extra work. Let’s start with a 3CX PBX Linux instance, and we will setup the monitoring for services such as 3CXPhoneSystem, 3CXSLDBServ, 3CXTunnel, 3CXMediaServer, etc.

Step 1. create a script file in 3CX Linux server

The first step we need to do is create a script in the Linux server, keep below in mind:

  • The script path must be /var/prtg/scripts.
  • Make sure the script has executable rights.
  • The name can be any you like with extension name sh.

We will create a script called query_process.sh

First create a folder for this:

sudo mkdir /var/prtg

sudo mkdir /var/prtg/scripts

Then we create a script file query_process.sh

sudo vi /var/prtg/scripts/query_process.sh

paste below:

#!/bin/sh

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

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

Note that the return value in the highlighted line can be:

Value Description
0 OK
1 WARNING
2 System Error (for example a network/socket error)
3 Protocol Error (for example a web server returns a 404)
4 Content Error (for example a web page does not contain a required word)

 

change the 2 to your situation in the table.

Make it executable:

sudo chmod +x /var/prtg/scripts/query_process.sh

Step 2. Get the service name:

ps -e | grep 3CX

  360 ?        00:00:09 3CXMediaServer

  364 ?        00:01:30 3CXTunnel

  547 ?        00:00:55 3CXSLDBServ

  574 ?        00:01:57 3CXPhoneSystem

  575 ?        00:06:09 3CXManagementCo

  577 ?        00:00:46 3CXAudioProvide

  738 ?        00:02:27 3CXIVR

  740 ?        00:00:07 3CXCallFlow

The names are the last column, which be used in step 3.

Step 3. create a sensor in PRTG

Logon the PRTG, create a Linux device, you must add a login username and password/private key.

Save this, create a sensor, make sure the parameters is the service name in step 2.

Save this sensor, now it should work.

 

Reference

https://www.paessler.com/manuals/prtg/ssh_script_sensor