check_asr (for VOIP app GNUGK)

This script is used to monitor and calculate ASR’s from the raw logfile of GNUGK (gnugk.org). It greps the raw log file (gatekeeper_acct.log) and calcualtes the success rate based off the gateway i.p ,. when i first started writing it i called it getto_asr now its renamed to ./check_asr .

#!/usr/bin/perl
#Written by Humberto Cabrera, simple script used to grep traffic of a
#specific gateway from a raw log and calculate the ASR
#free of use, for any questions humbe[at]bey0nd.net

$STATE_OK=0;
$STATE_WARNING=1;
$STATE_CRITICAL=2;
$STATE_UNKNOWN=3;
$STATE_DEPENDENT=4;

if ($#ARGV != 0) {
print “usage: ./check_asr ip_address\n”;
exit;
}

$log="/var/log/gatekeeper/gatekeeper_acct.log";

$gateway=$ARGV[0];

$check=cat $log | grep $gateway;

if ($check eq “”)
{
system(“clear”);
print “The IP $gateway, was not found in $log.\n”;
exit $STATE_UNKNOWN;
}

$total= cat $log | grep $gateway | wc -l;
$unconnected= cat $log | grep $gateway | grep unconnected | wc -l;

$asr=($total-$unconnected) * 100 / $total;
print “The current ASR for $gateway is $asr\n”;

if ($asr >= 40) {
exit $STATE_OK;
}
elsif (($asr) < 40 and ($asr) >= 31) {
exit $STATE_WARNING;
}
elsif ($asr <= 30) {
exit $STATE_CRITICAL;
}

Edited ]