How can I monitor running processes on my Linux machine?
Monitoring processes in Linux
How can I monitor running processes on my Linux machine?
This article applies to PRTG Network Monitor 9 or later
Monitoring Running Processes in Linux
- Installed and configured NET-SNMP
In some cases it might be useful to monitor if (and how often) a process on a Linux system is running at the moment. This can be done via SNMP, but therefore you need to apply some modification to your system's SNMP configuration.
SNMP Configuration (on device)
- Open your "snmpd.conf" file in a text editor and navigate to the end of the file.
- Add the following:
proc <process name>
- Replace <process name> with the name of the desired process
- IMPORTANT: It has to be exact the the same name as in your process list. It might be necessary to use the process name as given in the sbin or bin directory.
- Run the command /bin/ps -e to get the process name to use.
- Restart your SNMP service to make the changes take effect.
Automatic Sensor creation with Device Template
This device template will poll the following:
- Status (prErrorFlag)
It will use the status for alerting by default. You can however define additional limits for the "Process Count" channel. The usage of the device templates makes the deployment of sensors easier, especially if there are several devices or processes that you would like to monitor.
Device template deployment and Usage
- Download the required zip archive here.
- Extract the archive to your PRTG program directory. By default, this is %Program Files (x86)%\PRTG Network Monitor\.
- In PRTG, restart the core server: open Setup | System Administration | Administrative Tools | Restart Core Server and click Go!. This ensures that the MIB and lookups are loaded before you run the auto-discovery.
- Create a new device in PRTG with the address (IP or FQDN) of the device that you want to monitor and configure the SNMP credentials accordingly.
- Right-click your new device, select Run Auto Discovery with Template, and select the Custom UCD-SNMP Linux Process v0.x from the list.
Note: Using the auto-discovery with a dedicated device template is convenient here because it automates the creation of the custom sensors in an organized fashion.
- The sensors are deployed after a couple of seconds.
- You can adjust the channel limits or lookups to your needs later.
Template Version History
|0.2||Fixed the snmp_prTable check|
Manual Sensor creation
You can also deploy the sensor's manually if you don't want to use the auto-discovery. Please proceed as follows:
- Open the PRTG web interface
- Add the device you want to monitor
- Add a new SNMP Library sensor, then choose Basic Linux Library
- The process, from the step above, will be shown somehow like this:
|Basic Linux Library (UCD-SNMP-MIB)||Processes: 1||Processes Index|
|Basic Linux Library (UCD-SNMP-MIB)||Processes: 1||Processes Count|
|Basic Linux Library (UCD-SNMP-MIB)||Processes: 1||Processes Error Flag|
Select the value you want to monitor (Example: "Processes Count" shows how often the process is running) and click on Continue
- Go to sensor's Settings tab and rename the sensor to match your process
If you want to add another process just follow the steps above, the new process will be in category "Processes: 2", and so on.
Basically this is how to monitor your processes on a Linux machine.
This has been tested on Ubuntu, but should also work for every other distribution using NET-SNMP.
Note: This is also possible using our Custom Table Sensor, and it will allow for better naming of sensors and improved Auto-Discovery support. Tip: The Table's OID is 18.104.22.168.4.1.2021.2.
I am going monitoring Linux process by snmpd.conf above the article. But, i have a doubt. i added a sensor, in my case 'process:1' process count -> 'actually its httpd'
- In this moment its stopped, so my sensor mak 0 in process count, ok. But its green. How to configure for when count ==0 sensor stay red?
tks a lot!
in the overview of the affected sensor, please switch to the "Channels" tab. There please choose the correct channel and enable the limits for this channel. There you may set your lower error limits.
this is not what was asked:
how can i monitor running processes on linux? the number of running processes, i.e. MIB 22.214.171.124.126.96.36.199.6.0
this is working on one host and not on another. both running same OS both using exactly the same snmpd.conf
@amirtal: May you please elaborate on the precise issue? What exactly is not working? Do you get any error messages?
When creating a sensor to monitor a Linux Process I select SNMP Library. I then select the Basic Linux Library (ucd-snmp-mib).oidlib library file. After selecting Basic Linux Library (ucd-snmp-mib).oidlib I do not get Category "Processes: 1" nor do I get anything with "Process Count" in the name list.
The only Categories that are available to select from are Memory, System Stats, and CPU Load.
I can monitor the system with other Linux SNMP Sensors.
I have modified snmpd.conf file with proc sshd as the last line in a very basic conf file.
#ASM SNMPD Config rocommunity public syslocation "Alpharetta, GA" proc sshd
What might I be missing when attempting to create a sensor to monitor a Linux Process? Are the Process Categories still available to chose from? Is the right Linux MIB File installed on the PRTG Server?
@jessev: Could you please run
ps -e |grep sshd
What results do you get? EDIT: Are you able to add other SNMP Sensors (e.g. Uptime)?
Hi I have the same problem! when monitor a process and it not running the sensor stay Green and not send notification !
please update us
@chikosan: The sensor above by default reads a value. It does not 'know' if this value is good or bad. So, to get a notification, please set a lower warning limit for the channel value in the Sensor Channel Settings of the Processes Count. The sensor should then go to an error state when the number drops to 0.
After following this article I had the same issue. I went to the sensor channel and in the lower error limit I entered 0 but the sensor will still show OK and stay green although the service on the box was stopped. What I did for it to work is instead of entering 0 in the lower error limit I entered .1 that seemed to fix the issue. PRTG is now showing error when the service is stopped and Green when it is started. Hopes this helps.
very useful article. thanks
It´s possible to monitor more then twelve processes? In the SNMP Lib there are only twelve process sensor, but I´ve thriteen processes on my linux system.
@Marc Boettcher: This seems to be a limitation of NET-SNMP itself. So monitoring 13 processes is not possible then. Sorry.
will this handle processes with spaces in them? like "bash /bin/something"?
If so, does it require quotes around it?
@chlsmith thank you for your inquiry. I'm unable to confirm that, the net-snmp documentation page does not mention/specify that:
I encourage you to give it a try.
Luciano Lingnau [Paessler Support]
Это мониторинг процессов, а необходимо именно именно служб. Как это сделать в версии 17.3?
This is the monitoring of processes, and it is the services that are needed. How to do this in version 17.3?
The above guide still applies to the most recent version and your version as well.
Process and service are different things.
Example: ps -e | grep postfix
Example: service postfix status
- postfix is running
Is it possible that the postfix has a different process name? Could you try the following command instead?
ps | grep [p]ostfix
# ps | grep p 58568 pts/3 00:00:00 sudo 58641 pts/3 00:00:00 su 58642 pts/3 00:00:00 bash 58755 pts/3 00:00:00 ps 58756 pts/3 00:00:00 grep
Nothing like this
As what user are you logged in? Is it possible that the postfix service runs a different user and you are not able to get the "ps"-output of other user accounts?
Full root rights
Might be worth to check what process listens on port 25:
# sudo lsof -i :25 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME master 5664 root 12u IPv4 13732 TCP *:smtp (LISTEN)
Afterwards check the returned PID like this:
# ps p 5664 PID TTY STAT TIME COMMAND 5664 ? Ss 0:12 /usr/lib/postfix/master
Example, I need to monitor exactly whether the services are running: amavis, clamav, mysql, postfix
This is clear. But the above procedure only applies to processes. So a process can have an entirely different name from the actual service.
Please specify the link where the service monitoring method is specified.
There is no guide or documented way to do this. The only way is documented above, by monitoring the process behind the service.
Sure, using a custom sensor via SSH is an option - but this is not an already in PRTG implemented option. If the script above helps you, great! :)
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.