Tryag File Manager
Home
-
Turbo Force
Current Path :
/
proc
/
self
/
root
/
usr
/
local
/
sysadm
/
bin
/
Upload File :
New :
File
Dir
//proc/self/root/usr/local/sysadm/bin/snmp_apache.pl
#!/usr/bin/perl # Grab the output of server-status @server_status = `/usr/bin/curl -HHost:healthtest.f5 'http://localhost/server-status?auto' 2>/dev/null`; # Set this to your base OID: $baseOid = '.1.3.6.1.4.1.10025.3.1'; $reqMethod = $ARGV[0]; $reqOid = $ARGV[1]; # Set all vars to 0. my ($accesses, $kbytes, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers) = (0, 0, 0, 0, 0, 0, 0, 0, 0); foreach $line (@server_status) { if ( $line =~ /Total Accesses:\s+(\d+)/ ) { $accesses = int($1); } if ( $line =~ /Total kBytes:\s+(\d+)/ ) { $kbytes = int($1); } if ( $line =~ /CPULoad:\s+(\d+)/ ) { $cpuload = int($1); } if ( $line =~ /Uptime:\s+(\d+)/ ) { $uptime = int($1); } if ( $line =~ /ReqPerSec:\s+(\d+)/ ) { $reqpersec = int($1); } if ( $line =~ /BytesPerSec:\s+(\d+)/ ) { $bytespersec = int($1); } if ( $line =~ /BytesPerReq:\s+(\d+)/ ) { $bytesperreq = int($1); } if ( $line =~ /BusyWorkers:\s+(\d+)/ ) { $busyworkers = int($1); } if ( $line =~ /IdleWorkers:\s+(\d+)/ ) { $idleworkers = int($1); } } # Actually print the SNMP data if ($reqMethod eq '-n') { # GETNEXT if ( $reqOid eq $baseOid ) { print "$baseOid.0\ninteger\n$accesses\n"; } if ( $reqOid eq $baseOid.".0" ) { print "$baseOid.1\ninteger\n$kbytes\n"; } if ( $reqOid eq $baseOid.".1" ) { print "$baseOid.2\ninteger\n$cpuload\n"; } if ( $reqOid eq $baseOid.".2" ) { print "$baseOid.3\ninteger\n$uptime\n"; } if ( $reqOid eq $baseOid.".3" ) { print "$baseOid.4\ninteger\n$reqpersec\n"; } if ( $reqOid eq $baseOid.".4" ) { print "$baseOid.5\ninteger\n$bytespersec\n"; } if ( $reqOid eq $baseOid.".5" ) { print "$baseOid.6\ninteger\n$bytesperreq\n"; } if ( $reqOid eq $baseOid.".6" ) { print "$baseOid.7\ninteger\n$busyworkers\n"; } if ( $reqOid eq $baseOid.".7" ) { print "$baseOid.8\ninteger\n$idleworkers\n"; } } elsif ( $reqMethod eq '-g' ) { #GET if ( $reqOid eq $baseOid || $reqOid eq $baseOid.".0" ) { print "$baseOid.0\ninteger\n$accesses\n"; } if ( $reqOid eq $baseOid.".1" ) { print "$baseOid.1\ninteger\n$kbytes\n"; } if ( $reqOid eq $baseOid.".2" ) { print "$baseOid.2\ninteger\n$cpuload\n"; } if ( $reqOid eq $baseOid.".3" ) { print "$baseOid.3\ninteger\n$uptime\n"; } if ( $reqOid eq $baseOid.".4" ) { print "$baseOid.4\ninteger\n$reqpersec\n"; } if ( $reqOid eq $baseOid.".5" ) { print "$baseOid.5\ninteger\n$bytespersec\n"; } if ( $reqOid eq $baseOid.".6" ) { print "$baseOid.6\ninteger\n$bytesperreq\n"; } if ( $reqOid eq $baseOid.".7" ) { print "$baseOid.7\ninteger\n$busyworkers\n"; } if ( $reqOid eq $baseOid.".8" ) { print "$baseOid.7\ninteger\n$idleworkers\n"; } } # Print nothing if the OID didn't match.