mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
improve netstats poller
git-svn-id: http://www.observium.org/svn/observer/trunk@1454 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@ -8,6 +8,15 @@ if($device[os] != "Snom") {
|
|||||||
'ipReasmReqds','ipReasmOKs','ipReasmFails','ipFragOKs','ipFragFails','ipFragCreates', 'ipInUnknownProtos',
|
'ipReasmReqds','ipReasmOKs','ipReasmFails','ipFragOKs','ipFragFails','ipFragCreates', 'ipInUnknownProtos',
|
||||||
'ipInHdrErrors', 'ipInAddrErrors');
|
'ipInHdrErrors', 'ipInAddrErrors');
|
||||||
|
|
||||||
|
$oids['tcp'] = array ('tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab',
|
||||||
|
'tcpInSegs', 'tcpOutSegs', 'tcpRetransSegs', 'tcpInErrs', 'tcpOutRsts');
|
||||||
|
|
||||||
|
$oids['udp'] = array ('udpInDatagrams','udpOutDatagrams','udpInErrors','udpNoPorts');
|
||||||
|
|
||||||
|
$oids['tcp_collect'] = $oids['tcp'];
|
||||||
|
$oids['tcp_collect'][] = 'tcpHCInSegs';
|
||||||
|
$oids['tcp_collect'][] = 'tcpHCOutSegs';
|
||||||
|
|
||||||
$oids['icmp'] = array('icmpInMsgs','icmpOutMsgs','icmpInErrors','icmpOutErrors','icmpInEchos','icmpOutEchos','icmpInEchoReps',
|
$oids['icmp'] = array('icmpInMsgs','icmpOutMsgs','icmpInErrors','icmpOutErrors','icmpInEchos','icmpOutEchos','icmpInEchoReps',
|
||||||
'icmpOutEchoReps','icmpInDestUnreachs','icmpOutDestUnreachs','icmpInParmProbs','icmpInTimeExcds',
|
'icmpOutEchoReps','icmpInDestUnreachs','icmpOutDestUnreachs','icmpInParmProbs','icmpInTimeExcds',
|
||||||
'icmpInSrcQuenchs','icmpInRedirects','icmpInTimestamps','icmpInTimestampReps','icmpInAddrMasks',
|
'icmpInSrcQuenchs','icmpInRedirects','icmpInTimestamps','icmpInTimestampReps','icmpInAddrMasks',
|
||||||
@ -19,24 +28,8 @@ if($device[os] != "Snom") {
|
|||||||
'snmpInGetRequests','snmpInGetNexts','snmpInSetRequests','snmpInGetResponses','snmpInTraps','snmpOutTooBigs','snmpOutNoSuchNames',
|
'snmpInGetRequests','snmpInGetNexts','snmpInSetRequests','snmpInGetResponses','snmpInTraps','snmpOutTooBigs','snmpOutNoSuchNames',
|
||||||
'snmpOutBadValues','snmpOutGenErrs','snmpOutGetRequests','snmpOutGetNexts','snmpOutSetRequests','snmpOutGetResponses','snmpOutTraps','snmpSilentDrops','snmpProxyDrops');
|
'snmpOutBadValues','snmpOutGenErrs','snmpOutGetRequests','snmpOutGetNexts','snmpOutSetRequests','snmpOutGetResponses','snmpOutTraps','snmpSilentDrops','snmpProxyDrops');
|
||||||
|
|
||||||
$oids['tcp'] = array ('tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab',
|
|
||||||
'tcpInSegs', 'tcpOutSegs', 'tcpRetransSegs', 'tcpInErrs', 'tcpOutRsts');
|
|
||||||
|
|
||||||
$oids['tcp_collect'] = $oids['tcp'];
|
|
||||||
$oids['tcp_collect'][] = 'tcpHCInSegs';
|
|
||||||
$oids['tcp_collect'][] = 'tcpHCOutSegs';
|
|
||||||
|
|
||||||
$oids['udp'] = array ('udpInDatagrams','udpOutDatagrams','udpInErrors','udpNoPorts');
|
|
||||||
|
|
||||||
$protos = array('ip','icmp', 'snmp', 'udp', 'tcp');
|
$protos = array('ip','icmp', 'snmp', 'udp', 'tcp');
|
||||||
|
|
||||||
# /// Copy ifHC[In|Out]Octets values to non-HC if they exist
|
|
||||||
# if($this_port['ifHCInOctets'] > 0 && is_numeric($this_port['ifHCInOctets']) && $this_port['ifHCOutOctets'] > 0 && is_numeric($this_port['ifHCOutOctets'])) {
|
|
||||||
# echo("HC ");
|
|
||||||
# $this_port['ifInOctets'] = $this_port['ifHCInOctets'];
|
|
||||||
# $this_port['ifOutOctets'] = $this_port['ifHCOutOctets'];
|
|
||||||
# }
|
|
||||||
|
|
||||||
foreach($protos as $proto) {
|
foreach($protos as $proto) {
|
||||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||||
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("netstats-".$proto.".rrd");
|
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("netstats-".$proto.".rrd");
|
||||||
@ -51,25 +44,28 @@ if($device[os] != "Snom") {
|
|||||||
$snmpstring .= " $oid.0";
|
$snmpstring .= " $oid.0";
|
||||||
}
|
}
|
||||||
if(!file_exists($rrdfile)) { shell_exec($rrd_create); }
|
if(!file_exists($rrdfile)) { shell_exec($rrd_create); }
|
||||||
#$snmpdata_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m IP-MIB:SNMPv2-MIB:UDP-MIB:TCP-MIB:IP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $snmpstring";
|
|
||||||
#$snmpdata = trim(shell_exec($snmpdata_cmd));
|
|
||||||
$data = snmp_get_multi($device ,$snmpstring);
|
|
||||||
|
|
||||||
# print_r($data);
|
if($proto == "ip" || $proto == "tcp" || $proto == "udp")
|
||||||
|
{
|
||||||
|
$data = snmp_get_multi($device ,$snmpstring);
|
||||||
|
} else {
|
||||||
|
$data_array = snmpwalk_cache_oid($proto, $device, array());
|
||||||
|
}
|
||||||
|
|
||||||
$rrdupdate = "N";
|
$rrdupdate = "N";
|
||||||
|
|
||||||
foreach($oids[$proto] as $oid){
|
foreach($oids[$proto] as $oid){
|
||||||
if(is_numeric($data[0][$oid])) { $value = $data[0][$oid]; } else { $value = "0"; }
|
if(is_numeric($data[0][$oid]))
|
||||||
|
{
|
||||||
|
$value = $data[0][$oid];
|
||||||
|
} elseif(is_numeric($data_array[$device['device_id']][0][$oid])) {
|
||||||
|
$value = $data_array[$device['device_id']][0][$oid];
|
||||||
|
} else {
|
||||||
|
$value = "0";
|
||||||
|
}
|
||||||
$rrdupdate .= ":$value";
|
$rrdupdate .= ":$value";
|
||||||
}
|
}
|
||||||
|
|
||||||
# $rrdupdate = "N";
|
|
||||||
# foreach(explode("\n", $snmpdata) as $data) {
|
|
||||||
# if(strstr($data, "No") || strstr($data, "d") || strstr($data, "s")) { $data = "0"; }
|
|
||||||
# $rrdupdate .= ":$data";
|
|
||||||
# }
|
|
||||||
|
|
||||||
unset($snmpstring);
|
unset($snmpstring);
|
||||||
rrdtool_update($rrdfile, $rrdupdate);
|
rrdtool_update($rrdfile, $rrdupdate);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user