Tryag File Manager
Home
-
Turbo Force
Current Path :
/
usr
/
local
/
sysadm
/
bin
/
Upload File :
New :
File
Dir
//usr/local/sysadm/bin/snmp_mod_vhost_map.pl
#!/usr/bin/perl # Grab the output of server-status for this virtual farm. @server_status = `/usr/sbin/snmp_scan 4001 2> /dev/null`; # Set this to your base OID: $baseOid = '.1.3.6.1.4.1.10025.3.2'; $reqMethod = $ARGV[0]; $reqOid = $ARGV[1]; # Set all vars to 0. my ($active, $positive, $negative) = (0,0,0); foreach $line (@server_status) { if ( $line =~ /number of active sites:\s+(\d+)/ ) { $active = int($1); } if ( $line =~ /number of positive domains.+:\s+(\d+)/ ) { $positive = int($1); } if ( $line =~ /number of negative domains.+:\s+(\d+)/ ) { $negative = int($1); } } # Actually print the SNMP data if ($reqMethod eq '-n') { # GETNEXT if ( $reqOid eq $baseOid ) { print "$baseOid.0\ninteger\n$active\n"; } if ( $reqOid eq $baseOid.".0" ) { print "$baseOid.1\ninteger\n$positive\n"; } if ( $reqOid eq $baseOid.".1" ) { print "$baseOid.2\ninteger\n$negative\n"; } } elsif ( $reqMethod eq '-g' ) { #GET if ( $reqOid eq $baseOid || $reqOid eq $baseOid.".0" ) { print "$baseOid.0\ninteger\n$active\n"; } if ( $reqOid eq $baseOid.".1" ) { print "$baseOid.1\ninteger\n$positive\n"; } if ( $reqOid eq $baseOid.".2" ) { print "$baseOid.2\ninteger\n$negative\n"; } } # Print nothing if the OID didn't match.