Use of uninitialized value at netsnmpTinker.pl line 34 sysDescr for host 'localhost' is Use of unitialized value at netsnmpTinker.pl line 34. sysUpTime for host 'localhost' is Use of unitialized value at netsnmpTinker.pl line 34. ifNumber for host 'localhost' is Use of unitialized value at netsnmpTinker.pl line 34. ifTable for host 'localhost' is #### #! /usr/bin/perl -w # netsnmpTinker.pl # ybiC 2001-05-18 # derived from Net::SNMP example1.pl use strict; use Net::SNMP; use Tie::IxHash; my %snmp; ($snmp{session}, $snmp{error}) = Net::SNMP->session( -hostname => shift || 'localhost', -community => shift || 'public', -port => shift || 161 ); print "\n"; unless (defined($snmp{session})) { printf("ERROR: %s.\n", $snmp{error}); exit 1; } # =cut tie my %mib, "Tie::IxHash"; %mib = ( sysDescr => '1.3.6.1.2.1.1.1.0', sysUpTime => '1.3.6.1.2.1.1.3.0', ifNumber => '1.3.6.1.2.1.2.1.0', ifTable => '1.3.6.1.2.1.2.2.0', ); foreach my $key (keys %mib) { if (defined($snmp{response} = $snmp{session}->get_request($mib{key}))) { printf("$key for host '%s' is %s\n", $snmp{session} ->hostname(), $snmp{response}->{$mib{key}}, ); } else { printf("ERROR: %s.\n", $snmp{session}->error()) } } $snmp{session}->close(); print "\n"; exit 0; =cut my $sysDescr = '1.3.6.1.2.1.1.1.0'; my $sysUpTime = '1.3.6.1.2.1.1.3.0'; my $ifNumber = '1.3.6.1.2.1.2.1.0'; my $ifTable = '1.3.6.1.2.1.2.2.0'; if (defined($snmp{response} = $snmp{session}->get_request($sysDescr))) { printf("sysDescr for host '%s' is %s\n", $snmp{session}->hostname(), $snmp{response}->{$sysDescr} ); } else { printf("ERROR: %s.\n", $snmp{session}->error()) } if (defined($snmp{response} = $snmp{session}->get_request($sysUpTime))) { printf("sysUpTime for host '%s' is %s\n", $snmp{session}->hostname(), $snmp{response}->{$sysUpTime} ); } else { printf("ERROR: %s.\n", $snmp{session}->error()) } if (defined($snmp{response} = $snmp{session}->get_request($ifNumber))) { printf("ifNumber for host '%s' is %s\n", $snmp{session}->hostname(), $snmp{response}->{$ifNumber} ); } else { printf("ERROR: %s.\n", $snmp{session}->error()); } if (defined($snmp{response} = $snmp{session}->get_request($ifTable))) { printf("ifTable for host '%s' is %s\n", $snmp{session}->hostname(), $snmp{response}->{$ifTable} ); } else { printf("ERROR: %s.\n", $snmp{session}->error()); } print "\n"; $snmp{session}->close(); exit 0; =cut