/usr/share/doc/libsnmp-session-perl/examples/sun-find-process is in libsnmp-session-perl 1.13-1.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/usr/bin/perl -w
##
## Usage: find-process name host [community]
##
## List the PID(s) of processes of a given NAME running on a given
## HOST, using SNMP community COMMUNITY.
##
## Uses the "sun-snmp" MIB according to /var/snmp/mibs/sun.mib in
## Solstice Enterprise Agents.
##
use strict;
use SNMP_Session;
use BER;
my $proc_name = shift @ARGV || usage (1);
my $host = shift @ARGV || usage (1);
my $community = shift @ARGV || 'public';
my $psProcessID = [1,3,6,1,4,1,42,3,12,1,1,1];
my $psProcessProcessName = [1,3,6,1,4,1,42,3,12,1,1,10];
my $session = SNMP_Session->open ($host, $community, 161);
$session->map_table ([$psProcessProcessName],
sub
{
my ($index, $name);
$index = shift @_;
grep (defined $_ && ($_=pretty_print $_), @_);
($name) = @_;
print STDOUT $index,"\n" if $name eq $proc_name;
})
|| warn "Problem walking process table";
$session->close ()
|| warn "Problem closing SNMP_Session";
1;
sub usage ($) {
warn "usage: $0 host [community]\n";
exit $_[0] if $_[0];
}
|