sub sipshowpeers()
{
### SIP Show Peers
# build the var that holds the command
$command="Action: command\nCommand: sip show peers\n\n";
@lines=run_command($command);
#OK, run through the array elements, and try to make sense of it.
foreach $line (@lines)
{
#get rid of the pesky \n or whatever else is playing clingon
chomp($line);
#If it holds a : , we don't want it
next if ($line =~ ":");
#Ditto for the header line
next if ($line =~ "Host");
#Blanks too
next if ($line eq "");
# Hmm. I have to have this here, since I get junk if the system has a ch
#or down while this is reading. Gotta look at flushing the $tn buffer...
next unless (!($line =~ "UNKNOWN") || !($line =~ "OK"));
#Allllrrriiiighty then! We have useable data!
if ($line =~ "UNKNOWN")
{
#Dammit, they're dead, Jim
#Split it up on the whitespace
($name1,$host,$junk,$mask,$port,$status)=split(/\s+/,$line);
#Split name1 on the /
($name,$junk)=split(/\//,$name1);
#
#For the beginners reading this, 'replace into' is the same as
# 'if the primary keys match, delete first, then insert, else just i
$mysql->query("replace INTO sipstatus(name,status) values (\"$name\"
}
else
{
# It's alive... ALIVE!!!
($name1,$host,$junk,$mask,$port,$status,$lag)=split(/\s+/,$line);
($name,$hunk)=split(/\//,$name1);
$mysql->query("replace INTO sipstatus(name,status) values (\"$name\"
}
}
}