# This module contains the code used by the snmpInfo CGI script to produce its
# output in the form of HTML lists.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub get {
local($v) = shift;
local($c,$p,$t,$x);
print "
#get v=\"$v\" instance=(@_)\n" if $D>2;
if ($t = $mib{$v}) {
if ($t eq 'g' || $t eq 't' || $t eq 'e') {
$c = "&$v()";
print "
#get Group c=\"$c\"\n" if $D>2;
$x = eval($c);
print "
$v.@_\t$x\n" if $D>2;
} elsif ($t eq 'v') {
$c = "&$v(@_)";
print "
#get Variable c=\"$c\"\n" if $D>2;
$x = eval($c);
print "
#get x=$x\n" if $D>2;
} elsif ($t eq 'sv') {
($p = $v) =~ s/[A-Z].*//;
print "
#get Simple var p=\"$p\"\n" if $D>2;
$x = &vvar($p,$v);
print "
#get x=$x\n" if $D>2;
} elsif ($t eq 'vv') {
($p = $v) =~ s/[A-Z].*//;
print "
#get Vector var p=\"$p\"\n" if $D>2;
$x = &vvar($p,$v,@_);
print "
#get x=$x\n" if $D>2;
} else {
print "
#get t=$t unknown for v=\"$v\"\n" if $D>2;
}
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub all {
&snmp;
&df;
&usr;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub snmp {
&system;
&interfaces;
&at;
&ip;
&icmp;
&tcp;
&udp;
&egp;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub system { # group.
print "
| usrNumber | $usrNumber\n";
#}
sub usrTable { # table.
local($i);
&usrtbl() if !$usrNumber;
print "
\n";
print "User Table\n";
&th('usrName',
'usrUid',
'usrGid',
'usrDescr',
'usrHome',
'usrShell',
# 'usrPlan',
);
for ($i=1; $i <= $usrNumber; $i++) {
print "\n";
&td($usrName[$i],
$usrUid[$i],
$usrGid[$i],
$usrDescr[$i],
$usrHome[$i],
$usrShell[$i],
# $usrPlan[$i],
);
}
print " \n";
}
#sub usrEntry { # entry.
# local($i) = @_;
# print "usrEntry $i\n";
# print "
\n";
# &vvar('usr','usrIndex',$i);
# &vvar('usr','usrName',$i);
# &vvar('usr','usrUid',$i);
# &vvar('usr','usrGid',$i);
# &vvar('usr','usrDescr',$i);
# &vvar('usr','usrHome',$i);
# &vvar('usr','usrShell',$i);
# &vvar('usr','usrPlan',$i);
# print " \n";
#}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Here's a general-purpose routine to produce the html output for an
# associative array variable.
sub avar {
local($p,$v,$i,$a) = @_;
local($f);
$i = 1 if !$i;
if ($f = $get{$p}) {eval("&$f") if !$cnt{$p}}
print "| $v.$i | " . eval("\$${v}{$i}") . "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Here's a general-purpose routine to produce the html output for a simple
# variable.
sub svar {
local($p,$v) = @_;
local($f,$x);
if ($f = $get{$p}) {eval("&$f") if !$cnt{$p}}
if (defined($V{$v})) {
$x = $V{$v};
} else {
$x = eval("\$${v}");
}
print " | | $v | $x\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Here's a general-purpose routine to produce the html output for a variable
# that has a single index.
sub vvar {
local($p,$v,$i) = @_;
local($f);
$i = 1 if !$i;
if ($f = $get{$p}) {eval("&$f") if !$cnt{$p}}
print " | | $v.$i | " . eval("\$${v}[$i]") . "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub if {&interfaces};
sub interfaces { # group.
&iftbl() if !defined $ifNumber;
# print " interfaces:\n";
# print "
\n";
# &svar('if','ifNumber');
# print " \n";
&ifTable();
}
sub ifTable { # table.
local($i);
print "
\n";
print "Interface Table\n";
print "\n";
&iftbl() if !$ifNumber;
if ($fmt eq 'T') {
&th('Index',
'Descr',
'Type',
'OperStat',
'AdminStat',
'Mtu',
'Speed',
'PhysAddress',
# 'LastChange',
# 'InOctets',
# 'InUcastPkts',
# 'InNUcastPkts',
# 'InDiscards',
'InErrors',
# 'InUnknownProtos',
# 'OutOctets',
# 'OutUcastPkts',
# 'OutNUcastPkts',
# 'OutDiscards',
'OutErrors',
# 'OutQLen'
);
}
for ($i=1; $i <= $ifNumber; $i++) {
print " \n";
# &ifEntry($i);
&td($ifIndex[$i],
$ifDescr[$i],
$ifType[$i],
$ifOperStat[$i],
$ifAdminStat[$i],
$ifMtu[$i],
$ifSpeed[$i],
$ifPhysAddress[$i],
# $ifLastChange[$i],
# $ifInOctets[$i],
# $ifInUcastPkts[$i],
# $ifInNUcastPkts[$i],
# $ifInDiscards[$i],
$ifInErrors[$i],
# $ifInUnknownProtos[$i],
# $ifOutOctets[$i],
# $ifOutUcastPkts[$i],
# $ifOutNUcastPkts[$i],
# $ifOutDiscards[$i],
$ifOutErrors[$i],
# $ifOutQLen[$i]
);
}
print " \n";
}
sub th {for (@_) {print " | $_ | \n"}}
sub td {for (@_) {print "$_ | \n"}}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub at { # group.
local($i);
&iftbl() if !$ifNumber;
print "
\n";
print "Address Translation Table\n";
&th('atIfIndex',
'atPhysAddress',
'atNetAddress',
);
for $a (sort oidorder keys(%atNetAddress)) {
print "\n";
&td($atIfIndex{$a},
$atPhysAddress{$a},
$atNetAddress{$a},
);
}
print " \n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub ip { # group.
print "
\n";
print " ip:\n";
&svar('ip','ipForwarding');
&svar('ip','ipDefaultTTL');
&svar('ip','ipInReceives');
&svar('ip','ipInHdrErrors');
&svar('ip','ipInAddrErrors');
&svar('ip','ipForwDatagrams');
&svar('ip','ipInUnknownProtos');
&svar('ip','ipInDiscards');
&svar('ip','ipInDelivers');
&svar('ip','ipOutRequests');
&svar('ip','ipOutDiscards');
&svar('ip','ipOutNoRoutes');
&svar('ip','ipReasmTimeout');
&svar('ip','ipReasmRecords');
&svar('ip','ipReasmOKs');
&svar('ip','ipReasmFails');
&svar('ip','ipFragOKs');
&svar('ip','ipFragFails');
&svar('ip','ipFragCreates');
&svar('ip','ipAddrs');
print " \n";
print "
\n";
print " \n";
&ipAddrTable();
print " \n";
&ipRoutingTable();
print " \n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub ipAddrTable { # group.
print "
\n";
print "IP Address Table\n";
print "\n";
&iftbl() if !$ifNumber;
&th('AdEntAddr',
'AdEntIfIndex',
'AdEntNetMask',
'AdEntBcastAddr');
print "#ipAddrTable entries\n" if $D>2;
for $a (sort oidorder keys(%ipAdEntAddr)) {
print "\n";
&td($ipAdEntAddr{$a},
$ipAdEntIfIndex{$a},
$ipAdEntNetMask{$a},
$ipAdEntBcastAddr{$a});
}
print " \n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub ipRoutingTable { # group.
&rttbl() if !$ipRoutes;
print "
\n";
print "IP Routing Table\n";
print "\n";
&th('RouteDest',
'RouteIfIndex',
'RouteMetric1',
'RouteNextHop',
'RouteType',
'RouteProto',
'RouteAge');
for $a (sort oidorder keys(%ipRouteDest)) {
print " \n";
&td($ipRouteDest{$a},
$ipRouteIfIndex{$a},
$ipRouteMetric1{$a},
$ipRouteNextHop{$a},
$ipRouteType{$a},
$ipRouteProto{$a},
$ipRouteAge{$a});
}
print " \n";
}
sub ipRouteDest {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteDest.$a" . $ipRouteDest{$a} . "\n";
}
sub ipRouteIfIndex {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteIfIndex.$a" . $ipRouteIfIndex{$a} . "\n";
}
sub ipRouteMetric1 {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteMetric1.$a" . $ipRouteMetric1{$a} . "\n";
}
sub ipRouteMetric2 {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteMetric2.$a" . $ipRouteMetric2{$a} . "\n";
}
sub ipRouteMetric3 {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteMetric3.$a" . $ipRouteMetric3{$a} . "\n";
}
sub ipRouteMetric4 {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteMetric4.$a" . $ipRouteMetric4{$a} . "\n";
}
sub ipRouteNextHop {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteNextHop.$a" . $ipRouteNextHop{$a} . "\n";
}
sub ipRouteType {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteType.$a" . $ipRouteType{$a} . "\n";
}
sub ipRouteProto {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteProto.$a" . $ipRouteProto{$a} . "\n";
}
sub ipRouteAge {
local($a) = @_;
&rttbl() if !$ipRoutes;
print "ipRouteAge.$a" . $ipRouteAge{$a} . "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub icmp { # group.
print "${G1}icmp${G2}\n";
print "
\n";
&icmpOutAddrMaskReps();
&icmpOutAddrMasks();
&icmpOutTimestampReps();
&icmpOutTimestamps();
&icmpOutEchoReps();
&icmpOutEchos();
&icmpOutRedirects();
&icmpOutSrcQuenchs();
&icmpOutParmProbs();
&icmpOutTimeExcds();
&icmpOutDestUnreachs();
&icmpOutErrors();
&icmpOutMsgs();
&icmpInAddrMaskReps();
&icmpInAddrMasks();
&icmpInTimestampReps();
&icmpInTimestamps();
&icmpInEchoReps();
&icmpInEchos();
&icmpInRedirects();
&icmpInSrcQuenchs();
&icmpInParmProbs();
&icmpInTimeExcds();
&icmpInDestUnreachs();
&icmpInErrors();
&icmpInMsgs();
print " \n";
}
sub icmpInMsgs {print "icmpInMsgs.0$icmpInMsgs\n"}
sub icmpInErrors {print "icmpInErrors.0$icmpInErrors\n"}
sub icmpInDestUnreachs {print "icmpInDestUnreachs.0$icmpInDestUnreachs\n"}
sub icmpInTimeExcds {print "icmpInTimeExcds.0$icmpInTimeExcds\n"}
sub icmpInParmProbs {print "icmpInParmProbs.0$icmpInParmProbs\n"}
sub icmpInSrcQuenchs {print "icmpInSrcQuenchs.0$icmpInSrcQuenchs\n"}
sub icmpInRedirects {print "icmpInRedirects.0$icmpInRedirects\n"}
sub icmpInEchos {print "icmpInEchos.0$icmpInEchos\n"}
sub icmpInEchoReps {print "icmpInEchoReps.0$icmpInEchoReps\n"}
sub icmpInTimestamps {print "icmpInTimestamps.0$icmpInTimestamps\n"}
sub icmpInTimestampReps {print "icmpInTimestampReps.0$icmpInTimestampReps\n"}
sub icmpInAddrMasks {print "icmpInAddrMasks.0$icmpInAddrMasks\n"}
sub icmpInAddrMaskReps {print "icmpInAddrMaskReps.0$icmpInAddrMaskReps\n"}
sub icmpOutMsgs {print "icmpOutMsgs.0$icmpOutMsgs\n"}
sub icmpOutErrors {print "icmpOutErrors.0$icmpOutErrors\n"}
sub icmpOutDestUnreachs {print "icmpOutDestUnreachs.0$icmpOutDestUnreachs\n"}
sub icmpOutTimeExcds {print "icmpOutTimeExcds.0$icmpOutTimeExcds\n"}
sub icmpOutParmProbs {print "icmpOutParmProbs.0$icmpOutParmProbs\n"}
sub icmpOutSrcQuenchs {print "icmpOutSrcQuenchs.0$icmpOutSrcQuenchs\n"}
sub icmpOutRedirects {print "icmpOutRedirects.0$icmpOutRedirects\n"}
sub icmpOutEchos {print "icmpOutEchos.0$icmpOutEchos\n"}
sub icmpOutEchoReps {print "icmpOutEchoReps.0$icmpOutEchoReps\n"}
sub icmpOutTimestamps {print "icmpOutTimestamps.0$icmpOutTimestamps\n"}
sub icmpOutTimestampReps {print "icmpOutTimestampReps.0$icmpOutTimestampReps\n"}
sub icmpOutAddrMasks {print "icmpOutAddrMasks.0$icmpOutAddrMasks\n"}
sub icmpOutAddrMaskReps {print "icmpOutAddrMaskReps.0$icmpOutAddrMaskReps\n"}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub tcp { # group.
print "${G1}tcp${G2}\n";
print "
\n";
&tcpRtoAlgorithm();
&tcpRtoMin();
&tcpRtoMax();
&tcpMaxConn();
&tcpActiveOpens();
&tcpPassiveOpens();
&tcpAttemptFails();
&tcpEstabResets();
&tcpCurrEstab();
&tcpInSegs();
&tcpOutSegs();
&tcpRetransSegs();
&tcpConnTable();
print " \n";
}
sub tcpRtoAlgorithm {print "tcpRtoAlgorithm.0$tcpRtoAlgorithm\n"}
sub tcpRtoMin {print "tcpRtoMin.0$tcpRtoMin\n"}
sub tcpRtoMax {print "tcpRtoMax.0$tcpRtoMax\n"}
sub tcpMaxConn {print "tcpMaxConn.0$tcpMaxConn\n"}
sub tcpPassiveOpens {print "tcpPassiveOpens.0$tcpPassiveOpens\n"}
sub tcpAttemptFails {print "tcpAttemptFails.0$tcpAttemptFails\n"}
sub tcpEstabResets {print "tcpEstabResets.0$tcpEstabResets\n"}
sub tcpInSegs {print "tcpInSegs.0$tcpInSegs\n"}
sub tcpOutSegs {print "tcpOutSegs.0$tcpOutSegs\n"}
sub tcpRetransSegs {print "tcpRetransSegs.0$tcpRetransSegs\n"}
sub tcpConnTable { # table.
local($i);
print "tcpConnTable\n";
print "
\n";
&tcpinfo() if !defined($tcpConnNumber);
for $i (sort oidorder keys(%tcpConnTable)) {
&tcpConnEntry($i);
}
print " \n";
}
sub tcpConnEntry { # entry.
local($i) = @_;
print "tcpConnEntry $i\n";
print "
\n";
&tcpConnState($i);
&tcpConnLocalAddress($i);
&tcpConnLocalPort($i);
&tcpConnRemAddress($i);
&tcpConnRemPort($i);
print " \n";
}
sub tcpActiveOpens {
&tcptbl() if !defined($tcpConnNumber);
print "tcpActiveOpens$tcpActiveOpens\n";
}
sub tcpCurrEstab {
&tcptbl() if !defined($tcpConnNumber);
print "tcpCurrEstab$tcpCurrEstab\n";
}
sub tcpConnState {
local($i) = $_[0] || 1;
&tcptbl() if (!@tcpConnState);
print "tcpConnState.$i" . $tcpConnState{$i} . "\n";
}
sub tcpConnLocalAddress {
local($i) = $_[0] || 1;
&tcptbl() if (!@tcpConnLocalAddress);
print "tcpConnLocalAddress.$i" . $tcpConnLocalAddress{$i} . "\n";
}
sub tcpConnLocalPort {
local($i) = $_[0] || 1;
&tcptbl() if (!@tcpConnLocalPort);
print "tcpConnLocalPort.$i" . $tcpConnLocalPort{$i} . "\n";
}
sub tcpConnRemAddress {
local($i) = $_[0] || 1;
&tcptbl() if (!@tcpConnRemAddress);
print "tcpConnRemAddress.$i" . $tcpConnRemAddress{$i} . "\n";
}
sub tcpConnRemPort {
local($i) = $_[0] || 1;
&tcptbl() if (!@tcpConnRemPort);
print "tcpConnRemPort.$i" . $tcpConnRemPort{$i} . "\n";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub udp { # group.
print "${G1}udp${G2}\n";
print "
\n";
&udpInDatagrams();
&udpNoPorts();
&udpInErrors();
&udpOutDatagrams();
print " \n";
}
sub udpInDatagrams {print "udpInDatagrams.0$udpInDatagrams\n"}
sub udpNoPorts {print "udpNoPorts.0$udpNoPorts\n"}
sub udpInErrors {print "udpInErrors.0$udpInErrors\n"}
sub udpOutDatagrams {print "udpOutDatagrams.0$udpOutDatagrams\n"}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub egp { # group.
print "${G1}egp${G2}\n";
print "
\n";
&egpTable();
print " \n";
}
sub egpTable { # group.
print "egpTable\n";
print "
\n";
&rttbl() if !$egpNumber;
print "#egpTable $egpNumber entries\n" if $D>2;
for $a (sort oidorder keys(%egpDest)) {
&egpEntry($a);
}
print " \n";
}
sub egpEntry { # entry.
local($i) = @_;
print "egpEntry $i\n";
print "
\n";
&egpInMsgs($i);
&egpInErrors($i);
&egpOutMsgs($i);
&egpOutErrors($i);
&egpNeighTable($i);
&egpNeighEntry($i);
&egpNeighState($i);
&egpNeighAddr($i);
print " \n";
}
sub egpInMsgs {print "egpInMsgs.0$egpInMsgs\n"}
sub egpInErrors {print "egpInErrors.0$egpInErrors\n"}
sub egpOutMsgs {print "egpOutMsgs.0$egpOutMsgs\n"}
sub egpOutErrors {print "egpOutErrors.0$egpOutErrors\n"}
sub egpNeighTable {print "egpNeighTable.0$egpNeighTable\n"}
sub egpNeighEntry {print "egpNeighEntry.0$egpNeighEntry\n"}
sub egpNeighState {print "egpNeighState.0$egpNeighState\n"}
sub egpNeighAddr {print "egpNeighAddr.0$egpNeighAddr\n"}
1;
|---|
|