Monitoring processes on Linux

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
sapg
Posts: 22
Joined: Thu Aug 19, 2004 11:41 am
Location: UK
Contact:

Monitoring processes on Linux

Post by sapg »

Hello, I've just managed to get Cacti 0.8.6f with thold and monitor working on Linux! I love it. I have one question though, can I monitor processes? I've seen the example for monitoring processes on win32 (http://forums.cacti.net/about6661-0-asc-0.html) and I plan to use that but does anyone have any example for doing the same on linux?

Thanks,

Sapan
User avatar
fmangeant
Cacti Guru User
Posts: 2345
Joined: Fri Sep 19, 2003 8:36 am
Location: Sophia-Antipolis, France
Contact:

Post by fmangeant »

With UCD/Net-SNMP, you can add this to snmpd.conf :

Code: Select all

#  Make sure at least one top, but less than or equal to 3 are running.
proc top 3 1
Try running this command without a 'top' process running :

Code: Select all

$ snmpwalk -v 1 -c public localhost ucdavis.prTable
UCD-SNMP-MIB::prIndex.1 = INTEGER: 1
UCD-SNMP-MIB::prNames.1 = STRING: top
UCD-SNMP-MIB::prMin.1 = INTEGER: 1
UCD-SNMP-MIB::prMax.1 = INTEGER: 3
UCD-SNMP-MIB::prCount.1 = INTEGER: 0
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: 1
UCD-SNMP-MIB::prErrMessage.1 = STRING: Too few top running (# = 0)
UCD-SNMP-MIB::prErrFix.1 = INTEGER: 0
UCD-SNMP-MIB::prErrFixCmd.1 = STRING:
And then with one 'top' process running :

Code: Select all

$ snmpwalk -v 1 -c public localhost ucdavis.prTable
UCD-SNMP-MIB::prIndex.1 = INTEGER: 1
UCD-SNMP-MIB::prNames.1 = STRING: top
UCD-SNMP-MIB::prMin.1 = INTEGER: 1
UCD-SNMP-MIB::prMax.1 = INTEGER: 3
UCD-SNMP-MIB::prCount.1 = INTEGER: 1
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: 0
UCD-SNMP-MIB::prErrMessage.1 = STRING:
UCD-SNMP-MIB::prErrFix.1 = INTEGER: 0
UCD-SNMP-MIB::prErrFixCmd.1 = STRING:
You could then use the prErrorFlag.1 to know if your processes are up/down[/b]
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
sapg
Posts: 22
Joined: Thu Aug 19, 2004 11:41 am
Location: UK
Contact:

Post by sapg »

Cool! How do I graph the number of processes? I know it won't change much but it will make it easy for other people to load up my cacti page and see that the processes that are supposed to be running are running.
User avatar
fmangeant
Cacti Guru User
Posts: 2345
Joined: Fri Sep 19, 2003 8:36 am
Location: Sophia-Antipolis, France
Contact:

Post by fmangeant »

Here's an example :

Code: Select all

proc apache2
in /etc/snmp/snmpd.conf

Here are the apache processes :

Code: Select all

$ ps -fu apache
UID        PID  PPID  C STIME TTY          TIME CMD
apache    6364  6292  0 Aug17 ?        00:00:00 /usr/sbin/apache2 -k start -D SS
apache   20646  6292  0 Aug17 ?        00:00:02 /usr/sbin/apache2 -k start -D SS
apache   22859  6292  0 Aug17 ?        00:00:04 /usr/sbin/apache2 -k start -D SS
apache   23684  6292  0 Aug17 ?        00:00:02 /usr/sbin/apache2 -k start -D SS
apache   26929  6292  0 Aug17 ?        00:00:02 /usr/sbin/apache2 -k start -D SS
apache   28791  6292  0 Aug17 ?        00:00:04 /usr/sbin/apache2 -k start -D SS
apache     609  6292  0 Aug17 ?        00:00:03 /usr/sbin/apache2 -k start -D SS
apache    9756  6292  0 Aug17 ?        00:00:02 /usr/sbin/apache2 -k start -D SS
apache   13977  6292  0 Aug17 ?        00:00:00 /usr/sbin/apache2 -k start -D SS
apache   30285  6292  0 Aug17 ?        00:00:01 /usr/sbin/apache2 -k start -D SS
apache    5537  6292  0 Aug17 ?        00:00:02 /usr/sbin/apache2 -k start -D SS
You can then query them with snmp :

Code: Select all

$ snmpwalk -v 1 -c public localhost ucdavis.prTable
UCD-SNMP-MIB::prIndex.1 = INTEGER: 1
UCD-SNMP-MIB::prNames.1 = STRING: apache2
UCD-SNMP-MIB::prMin.1 = INTEGER: 0
UCD-SNMP-MIB::prMax.1 = INTEGER: 0
UCD-SNMP-MIB::prCount.1 = INTEGER: 12
UCD-SNMP-MIB::prErrorFlag.1 = INTEGER: 0
UCD-SNMP-MIB::prErrMessage.1 = STRING:
UCD-SNMP-MIB::prErrFix.1 = INTEGER: 0
UCD-SNMP-MIB::prErrFixCmd.1 = STRING:
If you want to graph the number of apache processes, use the OID prCount.1

You can also take a look at this extension "ApacheStats version 0.4": http://forums.cacti.net/viewtopic.php?t=4028
It allows you to graph the apache threads :

Image
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
sapg
Posts: 22
Joined: Thu Aug 19, 2004 11:41 am
Location: UK
Contact:

Post by sapg »

Excellent! Thanks very much, I'm going to give that a try for the web servers.

Have you ever used Nino? I tried it a while ago, it seemed to be able to get information about running processes without adding anything to snmpd.conf. Do you know how to do that?

It would be great if I could build some kind of wizard that would get a list of running processes and then I could just select the ones I want to graph and monitor.
User avatar
fmangeant
Cacti Guru User
Posts: 2345
Joined: Fri Sep 19, 2003 8:36 am
Location: Sophia-Antipolis, France
Contact:

Post by fmangeant »

I didn't konw Nino, looks interesting.
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
sapg
Posts: 22
Joined: Thu Aug 19, 2004 11:41 am
Location: UK
Contact:

Post by sapg »

I've found that this will give me a list of all running processes in a simple format, now all I need to do it write a script :-) -

snmpwalk -OQ -Ov -v1 -c public localhost .1.3.6.1.2.1.25.4.2.1.2
Last edited by sapg on Tue Oct 21, 2008 10:35 pm, edited 1 time in total.
sapg
Posts: 22
Joined: Thu Aug 19, 2004 11:41 am
Location: UK
Contact:

Post by sapg »

Hmm....I have no idea how to turn that into a graph!
sapg
Posts: 22
Joined: Thu Aug 19, 2004 11:41 am
Location: UK
Contact:

Post by sapg »

OK, I have a little script that gives me what I want, can anyone help me get this into Cacti? I'm not quite sure what I need to do.

#!/bin/bash

RCOMMUNITY=$1
HOST=$2


snmpwalk -OQ -Ov -v1 -c $RCOMMUNITY $HOST .1.3.6.1.2.1.25.4.2.1.2 |sort |uniq -c -w 4

Thanks,
Sapan
anmomin1
Cacti User
Posts: 63
Joined: Mon May 29, 2017 4:14 pm

Re: Monitoring processes on Linux

Post by anmomin1 »

Anyone able to get linux process or TOp into cacti graph
User avatar
camerabob
Cacti User
Posts: 386
Joined: Fri Feb 10, 2017 2:45 pm
Location: Long Island, New York, USA
Contact:

Re: Monitoring processes on Linux

Post by camerabob »

This is probably the biggest stretch between posts. 14 years???
Prod: Cacti 1.2.15 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Maint @ 1.2
Monitor @ 2.3.6
Thold @ 1.2.4

Temp: Cacti 1.2.3 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Flowview @ 2.1
Mactrack @ 4.2
Maint @ 1.2
Monitor @ 2.3.6
Router Configs @ 1.3.4
Syslog Monitoring @ 2.1
Thold @ 1.2.4
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests