51 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2015-07-13 20:10:26 +02:00
if ($device['os'] != 'Snom') {
echo ' TCP';
2015-07-13 20:10:26 +02:00
$oids = array(
'tcpActiveOpens',
'tcpPassiveOpens',
'tcpAttemptFails',
'tcpEstabResets',
'tcpCurrEstab',
'tcpInSegs',
'tcpOutSegs',
'tcpRetransSegs',
'tcpInErrs',
'tcpOutRsts',
);
$rrd_def = array();
$snmpstring = '';
2015-07-13 20:10:26 +02:00
foreach ($oids as $oid) {
$oid_ds = truncate($oid, 19, '');
$rrd_def[] = " DS:$oid_ds:COUNTER:600:U:10000000"; // Limit to 10MPPS
2015-07-13 20:10:26 +02:00
$snmpstring .= ' TCP-MIB::'.$oid.'.0';
}
2015-07-13 20:10:26 +02:00
$snmpstring .= ' tcpHCInSegs.0';
$snmpstring .= ' tcpHCOutSegs.0';
2015-07-13 20:10:26 +02:00
$data = snmp_get_multi($device, $snmpstring, '-OQUs', 'TCP-MIB');
2016-06-06 15:09:31 +01:00
$fields = $data[0];
2016-07-18 08:33:29 -05:00
// use HC Segs if we have them.
if (isset($fields['tcpHCInSegs'])) {
if (!empty($fields['tcpHCInSegs'])) {
$fields['tcpInSegs'] = $fields['tcpHCInSegs'];
$fields['tcpOutSegs'] = $fields['tcpHCOutSegs'];
}
2016-07-18 08:33:29 -05:00
unset($fields['tcpHCInSegs'], $fields['tcpHCOutSegs']);
}
if (isset($fields['tcpInSegs']) && isset($fields['tcpOutSegs'])) {
$tags = compact('rrd_def');
data_update($device, 'netstats-tcp', $tags, $fields);
2015-08-19 20:58:02 +00:00
2015-07-13 20:10:26 +02:00
$graphs['netstat_tcp'] = true;
}
2016-07-18 08:33:29 -05:00
unset($oids, $data, $fields, $oid, $protos, $snmpstring);
2015-07-13 20:10:26 +02:00
}//end if