Here is a perl script that determines the number of HTTP connections on a server, and displays the rusults on one of the seven segment displays on the NetAdminWorld console:
open (HC, "ssh -p <port> root\@example.com 'netstat | grep http | wc -l '|"); while (<HC>){ $count=$_/6 } use IO::Socket; my $sock = new IO::Socket::INET ( PeerAddr => 'localhost', PeerPort => '27183', Proto => 'tcp', ); die "Error: $!\n" unless $sock; print $sock "g01r1Primary External Web.."; print $sock "g01t3HTTPC/6.."; $answer=<$sock>; if ($count << 1){ printf $sock ("g01s316.."); $answer=<$sock>; printf $sock ("led010.."); } elsif ($count > 15){ printf $sock ("g01s317.."); $answer=<$sock>; printf $sock ("led013.."); } elsif ($count < 10){ printf $sock ("g01s3%.1u..",$count); $answer=<$sock>; printf $sock ("led010.."); } else { printf $sock ("g01s317.."); $answer=<$sock>; printf $sock ("led012.."); } $answer=<$sock>; close($sock); |
This is what the result looks like:
For results higher than 9, an H is written, and the LED flashes slowly as an alert. For results lower than 1, an L is written, and for results higher than 15, an H is written, and the LED flashes quickly. This can be tailored specifically to what you want to monitor. Really, the scale of anything should be 1-9, with alerts at either end that escalate. Further logic could be built in for alerting, etc. If you find canned packages to be too limiting in your scrappy environment, perhaps this will help.