in reply to SNMP RemotePort
Example output is:use strict; use Data::Dumper; use Net::SNMP; my ($session, $error) = Net::SNMP->session( -hostname => shift || 'localhost', -community => shift || 'public', -port => shift || 161 ); if (!defined($session)) { printf("ERROR: %s.\n", $error); exit 1; } my $sysUpTime = '1.3.6.1.2.1.1.3.0'; my $result = $session->get_request( -varbindlist => [$sysUpTime] ); if (!defined($result)) { printf("ERROR: %s.\n", $session->error); $session->close; exit 1; } printf("sysUpTime for host '%s' is %s\n", $session->hostname, $result->{$sysUpTime} ); #print Dumper($result); $session->close; exit 0;
$ ./snmp-uptime.pl 172.19.1.2 my_community_string sysUpTime for host '172.19.1.2' is 263 days, 14:47:49.58
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SNMP RemotePort
by vortmax (Acolyte) on Apr 10, 2008 at 20:12 UTC |