|
System | : | Linux MiraNet 3.0.0-14-generic-pae #23-Ubuntu SMP Mon Nov 21 22:07:10 UTC 2011 i686 |
Software | : | Apache. PHP/5.3.6-13ubuntu3.10 |
ID | : | uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
|
|
Safe Mode | : | OFF |
Open_Basedir | : | OFF |
Freespace | : | 24.69 GB of 70.42 GB (35.07%) |
|
MySQL: ON MSSQL: OFF Oracle: OFF PostgreSQL: OFF Curl: OFF Sockets: ON Fetch: OFF Wget: ON Perl: ON |
Disabled Functions: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
|
[ System Info ]
[ Processes ]
[ SQL Manager ]
[ Eval ]
[ Encoder ]
[ Mailer ]
[ Back Connection ]
[ Backdoor Server ]
[ Kernel Exploit Search ]
[ MD5 Decrypter ]
[ Reverse IP ]
[ Kill Shell ]
[ FTP Brute-Force ]
|
|
/
usr/
share/
doc/
libsnmp-session-perl/
examples/
- drwxr-xr-x
|
Viewing file: snmpwalkh.pl (2.23 KB) -rwxr-xr-xSelect action/file-type:  ( +) |  ( +) |  ( +) | Code ( +) | Session ( +) |  ( +) | SDB ( +) |  ( +) |  ( +) |  ( +) |  ( +) |  ( +) |
#!/usr/bin/perl # # File_________: snmpwalkh_test.pl # Date_________: 12.11.2001 # Author_______: Laurent Girod / Philip Morris Products S.A. / Neuchatel / Switzerland # Description__: Example of uses of the new snmpwalkhash function in SNMP_util # With snmpwalkhash, you can customize as you like your # results, in a hash of hashes, # by oid names, oid numbers, instances, like: # $hash{$host}{$name}{$inst} = $value; # $hash{$host}{$oid}{$inst} = $value; # $hash{$name}{$inst} = $value; # $hash{$oid}{$inst} = $value; # $hash{$oid.'.'.$inst} = $value; # $hash{$inst} = $value; # ... # Needed_______: ActiveState Perl 620 from www.perl.com # Modifications: # ########################################################################################################
use BER; use SNMP_util "0.90";
$BER::pretty_print_timeticks = 0; # Uptime in absolute value
my $host = shift @ARGV || &usage; my $community = shift @ARGV || 'public'; &usage if $#ARGV >= 0; $host = "$community\@$host" if !($host =~ /\@/);
# # Example 1: # my $oid_name = 'system';
print "\nCollecting [$oid_name]\n"; @ret = &snmpwalk($host, $oid_name); foreach $desc (@ret) { ($oid, $desc) = split(':', $desc, 2); print "$oid = $desc\n"; }
# # Example 2: snmpwalk # my @oid_names = ('ifType', 'ifMtu', 'ifSpeed', 'ifPhysAddress',); print "\nCollecting "; map { print "[$_]\t" } @oid_names; print "\n";
@ret = &snmpwalk($host, @oid_names); foreach $desc (@ret) { ($oid, $desc) = split(':', $desc, 2); print "$oid = $desc\n"; }
# # Example 3: snmpwalkhash #
my %ret_hash = &snmpwalkhash($host, \&my_simple_hash, @oid_names); foreach $oid (keys %ret_hash) { foreach my $inst (sort { $a <=> $b } keys %{$ret_hash{$oid}}) { printf("%15s %3s = %s\n", $oid, $inst, $ret_hash{$oid}{$inst}); } }
sub my_simple_hash { my ($h_ref, $host, $name, $oid, $inst, $value) = @_; $inst =~ s/^\.+//; if ($name =~/ifPhysAddress/) { my $mac = ''; map { $mac .= sprintf("%02X",$_) } unpack "CCCCCC", $value; $value = $mac; } $h_ref->{$name}->{$inst} = $value; }
sub usage { die "usage: $0 hostname [community]"; }
|