#!/usr/local/bin/perl
# Perl script for retrieving actcalls from a Bay 5399/8000 ... John Kougoulos kugjon@panteion.gr
$racaddr = $ARGV[0];
$raccommunity = $ARGV[1];
$miblocation = "/export/home/kugjon/ucdsnmp/ucd-snmp-3.5.3/MIBS" ;
$ucdsnmp = "/export/home/kugjon/ucdsnmp/ucd-snmp-3.5.3/apps" ;
if(open(TABLE, "$ucdsnmp/snmpwalk -M $miblocation $racaddr $raccommunity .1.3.6.1.4.1.15.2.16.1 |grep actCall > ras.snmp.out;cat ras.snmp.out |"))
{
$start = 0;
$oldvar = "";
$newvar = 0;
while (
)
{
# /actCall/;
chop;
@fields = split(/\=/,$_);
$fields[0] =~ s/\.1\./\./;
# print $fields[0]."\n";
@semifields = split(/\./,$fields[0]);
if ( $semifields[7] ne $oldvar )
{
$oldvar = $semifields[7];
$newvar++;
# print $newvar." ".$semifields[7]."\n";
}
$fields[1] =~ s/\"//g;
$fields[1] =~ s/\s+(.*)/\1/;
# print $semifields[8]."lala \n";
$semifields[8] =~ s/(\d+).*/\1/;
# print $semifields[8]."foufou \n";
$calldata{$semifields[8]}[$newvar] = $fields[1];
# print $fields[1]."\n";
if(($start eq 0) && ($semifields[8] gt 0))
{
$start = $semifields[8];
}
}
}
close(TABLE);
if(open(STATSFILE,">ras.stats"))
{
$start = 1;
$end = 62;
# $end = $start+62;
# print $start." upto ".$end;
for( $i=$start ;$i<=$end;$i++)
{
#Post Processing
$calldata{$i}[2] =~ s/(\w+).*/\1/;
# $aa = $calldata{$i." "}[1];
$user = $calldata{$i}[2];
$user =~ s/(\w+).*/\1/;
# print $user."\n";
$ip = $calldata{$i}[11];
$duration = int($calldata{$i}[9]/60)."m ".($calldata{$i}[9]%60)."s";
$currrxspeed = $calldata{$i}[26];
$currtxspeed = $calldata{$i}[28];
$currmodulation = $calldata{$i}[59];
$currSNR = $calldata{$i}[49];
$RX = $calldata{$i}[38];
$RXerr = $calldata{$i}[39];
$TX = $calldata{$i}[36];
$TXerr = $calldata{$i}[37];
$callingno = $calldata{$i}[3];
$old = select(STATSFILE);
$= = 2000;
select($old);
if($user ne "")
{
write STATSFILE;
}
}
}
close(STATSFILE);
system("cat ras.stats");
format STATSFILE_TOP =
A/A Username IP Address Duration RxSpeed TxSpeed Modula SNR Tx TxErr Rx RxErr Calling No
----- ------------- ----------------- -------- ---------------- --------------- -------- ---- ------ ------ ------ ------ ----------
.
format STATSFILE =
@<<<< @<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<< @<<<<<<<<<<<<<<< @<<<<<<<<<<<<<< @<<<<<<< @<<< @<<<<< @<<<<< @<<<<< @<<<<< @<<<<<<<<<
$i, $user, $ip, $duration, $currrxspeed, $currtxspeed, $currmodulation, $currSNR, $TX, $TXerr, $RX, $RXerr, $callingno
.