Monitoring Individual Programs

Al Tobey albert.tobey at priority-health.com
Mon Aug 19 16:10:57 CEST 2002


On Thu, 2002-08-15 at 16:39, blange wrote:
> As Quoted By Darren:
> If you want to take it to the next level, you can use the NET-SNMP agent to
> see how many hosts are running on any local or remote machine via SNMP
> (you'll need to configure the agent for each specific process) which is
> fairly easy to do.  We use this very heavily here.
> 
> I am wondering how to actually do this.  For instance, lets take Windows 2000 . . . Using SNMP I can look at the current processes running and if I know the PID I can use ./check_snmp to match the string of the service running.  However, everytime the machine would be rebooted I would have to configure Nagios with the new OID.  I am wondering if there is a way to check all running services and see if there is a string to match the program in question.  Is this possible?  If not, what are you referring to above?
  Well, there is an easy way to do it.  Use perl and the
$session->bulkwalk() to gather the list of process names, which will
include the index.  I've written a plugin for my installation of nagios,
but I don't have permission to release that code.  Here is an example
snippet of what you have to do with the Net-SNMP module to achieve what
you desire.  I use a similar method to get information about disk space
on all of my machines.  (names and values have been changed to protect
the innocent)

# use the host-resources mib that is available on
# Net-SNMP, W2K, and Novell to get process information
use SNMP;
$session = new SNMP::Session(
	DestHost => 'localhost',
	Community => 'public',
	Version => '2c'
);
# get the total number of processes for the bulkwalk
$var = SNMP::VarBind->new( ['hrSystemProcesses', 0] );
$session->get( $var );

# retrieve a list of process names a'la `ps -e`
$proc_list = $session->bulkwalk( 0, $var->val, [[hrSWRunName]] );
# cycle through the list and print it out
%statistics = ();
foreach my $proc ( @$proc_list ) {
	# keep track of how many processes and what their iid's are
	# for later processing
	push( @{$statistics{$proc->val}->{index}}, $proc->iid );
	print "process ",$proc->val," has index of ",$proc->iid,"\n";
}
exit 0;

Combined with my patch to manage snmp community names in the nagios
configs, and I have a fairly nice way to get lots of host information
without installing any special software, since Net-SNMP is standard with
most linux distributions.

-Al Tobey



********************************************************************
This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity
to whom they are addressed.  If you have received this 
email in error please notify the Priority Health Information
Services Department at (616) 942-0954.
********************************************************************



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390




More information about the Users mailing list