Apache-WebSNMP
view release on metacpan or search on metacpan
lib/Apache/WebSNMP.pm view on Meta::CPAN
'icmpInEchos' => '1.3.6.1.2.1.5.8',
'icmpInEchoReps' => '1.3.6.1.2.1.5.9',
'icmpInTimestamps' => '1.3.6.1.2.1.5.10',
'icmpInTimestampsReps' => '1.3.6.1.2.1.5.11',
'icmpInAddrMasks' => '1.3.6.1.2.1.5.12',
'icmpInAddrMaskReps' => '1.3.6.1.2.1.5.13',
'icmpOutMsgs' => '1.3.6.1.2.1.5.14',
'icmpOutErrors' => '1.3.6.1.2.1.5.15',
'icmpOutDestUnreachs' => '1.3.6.1.2.1.5.16',
'icmpOutTimeExcds' => '1.3.6.1.2.1.5.17',
'icmpOutParmProbs' => '1.3.6.1.2.1.5.18',
'icmpOutSrcQuenchs' => '1.3.6.1.2.1.5.19',
'icmpOutRedirects' => '1.3.6.1.2.1.5.20',
'icmpOutEchos' => '1.3.6.1.2.1.5.21',
'icmpOutEchoReps' => '1.3.6.1.2.1.5.22',
'icmpOutTimestampsReps' => '1.3.6.1.2.1.5.23',
'icmpOutTimestampsReps' => '1.3.6.1.2.1.5.24',
'icmpOutAddrMasks' => '1.3.6.1.2.1.5.25',
'icmpOutAddrMaskReps' => '1.3.6.1.2.1.5.26',
);
# find out which html file was requested!
my $htmlfile = $r->uri;
my $htmlbase = "/home/httpd/html";
my $html = $htmlbase . $htmlfile;
# defaults!
my $host = "localhost";
my $community = "public";
my $oid = "sysDescr";
# arrays form variable retension
my @current_vars = ();
my %var_to_oid_map = ();
my %var_to_value_map = ();
open(HTML, $html);
my @html_buffer = <HTML>;
close(HTML);
my $the_buffer = join("",@html_buffer);
# local variables so no confusion with the other modules.
my $sess = "";
my $sval = "";
my $x = 0;
my $val = "";
my @snmpvals = ();
my @tag = ();
my $whichvar = "";
my $nextvalue = "";
my $a_mac = "";
my $split_mac = "";
my $tempoid = "";
my $vb = "";
my @values = ();
my @varlist = ();
my @split_tag = ();
# split the input buffer to find the snmp tags!
my @incidents = split(/(<snmp>[a-zA-z0-9=\s\.\(\)]*<\/snmp>)/, $the_buffer);
# process each tag.
foreach $val (@incidents)
{
if($val =~ "<snmp>")
{
# get rid of <snmp> tags
$val = substr($val, 6,);
$val = substr($val, 0, -7);
# now parse snmp tag values
@snmpvals = split(/\s+/, $val);
foreach $sval (@snmpvals)
{
@tag = split(/(=)/, $sval);
if($tag[0] eq "host")
{
$host = $tag[2];
next;
}
if($tag[0] eq "community")
{
$community = $tag[2];
next;
}
# depricated
#if($tag[0] =~ /extension\(/)
#{
# # parse extension(var)=val
# $whichvar = substr($tag[0], 10,);
# $whichvar = substr($whichvar, 0, -1);
# $var_to_oid_map{$whichvar} = $var_to_oid_map{$whichvar}.".".$tag[2];
# next;
#}
if($tag[0] =~ /print\(/)
{
# parse extension(var)=val
$whichvar = substr($tag[0], 6,);
$whichvar = substr($whichvar, 0, -1);
$nextvalue = $var_to_value_map{$whichvar};
#check for special handling of packed binary MAC address
if ($var_to_oid_map{$whichvar} =~ /1\.3\.6\.1\.2\.1\.2\.2\.1\.6/ )
{
$a_mac = unpack "H12", $nextvalue;
$split_mac=substr($a_mac,0,2).":".substr($a_mac,2,2).":".substr($a_mac,4,2).":".substr($a_mac,6,2).":".substr($a_mac,8,2).":".substr($a_mac,10,2);
print $split_mac;
}
else
{
print $nextvalue;
# $var_to_value_map{$whichvar};
}
next;
}
if($tag[1] eq "=")
{
@split_tag=split(/\./, $tag[2]);
$_ = $tag[2];
s/$split_tag[0]/$oidmap{$split_tag[0]}/;
( run in 0.866 second using v1.01-cache-2.11-cpan-39bf76dae61 )