#!/usr/bin/perl # ---------------------------------------------------------------------------- # "THE BEER-WARE LICENSE" (Revision 42) : # wrote this file. As long as you retain this notice you # can do whatever you want with this stuff. If we meet some day, and you think # this stuff is worth it, you can buy me a beer in return - Kim Winther # ---------------------------------------------------------------------------- # Retrieves # of current calls from a Vega100T1E1 for mrtg # v0.1 - 20041123/kimw # v0.2 - 20041124/kimw - fixed readerror if output twarted by LOG messages.... use Net::Telnet (); $argc = @ARGV; if ($argc < 3) { print "Usage - vegastat.pl ipOfVega100 username password\n"; exit 0; } $host = $ARGV[0]; $username = $ARGV[1]; $password = $ARGV[2]; $debug = $ARGV[3]; $calls=0; $uptime=" I dont know how long...."; $t = new Net::Telnet (); $t->open(Host=>$host); $t->waitfor('/Username: /i'); $t->print($username); $t->waitfor('/Password: /i'); $t->print($password); $t->waitfor('/>/i'); $t->print('show calls'); $lc=0; while ($lc<10) { ($output) = $t->waitfor('/>/i'); @lines = split(/\n/, $output); $lc=scalar(@lines); } foreach $l (@lines) { if ($l=~ /End-to-end (.*)$/) { $calls=$1; } if ($l=~ /has been running for (.*)$/) {$uptime = $1;} } $calls =~ s/^\s+//; print $calls."\n".$calls."\n"; print $uptime."\n"; print $host."\n";