librenms-librenms/includes/polling/netstats-tcp.inc.php

58 lines
1.5 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',
);
2015-07-13 20:10:26 +02:00
// $oids['tcp_collect'] = $oids['tcp'];
// $oids['tcp_collect'][] = 'tcpHCInSegs';
// $oids['tcp_collect'][] = 'tcpHCOutSegs';
unset($snmpstring, $fields, $snmpdata, $snmpdata_cmd, $rrd_create);
2015-07-13 20:10:26 +02:00
$rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/netstats-tcp.rrd';
2015-07-13 20:10:26 +02:00
$rrd_create = $config['rrd_rra'];
2015-07-13 20:10:26 +02:00
foreach ($oids as $oid) {
$oid_ds = truncate($oid, 19, '');
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:10000000";
// Limit to 10MPPS
$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];
2015-07-13 20:10:26 +02:00
unset($snmpstring);
2015-07-13 20:10:26 +02:00
if (isset($data[0]['tcpInSegs']) && isset($data[0]['tcpOutSegs'])) {
if (!file_exists($rrd_file)) {
rrdtool_create($rrd_file, $rrd_create);
}
rrdtool_update($rrd_file, $fields);
2015-08-19 20:58:02 +00:00
$tags = array();
influx_update($device,'netstats-tcp',$tags,$fields);
2015-07-13 20:10:26 +02:00
$graphs['netstat_tcp'] = true;
}
2015-07-13 20:10:26 +02:00
unset($oids, $data, $data_array, $oid, $protos);
}//end if