2009-11-24 23:58:56 +00:00
|
|
|
<?php
|
|
|
|
|
2016-01-26 13:49:30 +01:00
|
|
|
if ($port_stats[$port_id] &&
|
2015-07-13 20:10:26 +02:00
|
|
|
$port['ifType'] == 'ethernetCsmacd' &&
|
2016-01-26 13:49:30 +01:00
|
|
|
isset($port_stats[$port_id]['dot3StatsIndex'])) {
|
2015-07-13 20:10:26 +02:00
|
|
|
// Check to make sure Port data is cached.
|
2016-01-26 13:49:30 +01:00
|
|
|
$this_port = &$port_stats[$port_id];
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2016-01-26 13:49:30 +01:00
|
|
|
// TODO: remove legacy check?
|
2015-07-13 20:10:26 +02:00
|
|
|
$old_rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('etherlike-'.$port['ifIndex'].'.rrd');
|
2016-01-26 13:49:30 +01:00
|
|
|
$rrd_file = get_port_rrdfile_path ($device['hostname'], $port_id, 'dot3');
|
2015-07-13 20:10:26 +02:00
|
|
|
|
|
|
|
$rrd_create = $config['rrd_rra'];
|
|
|
|
|
|
|
|
if (!file_exists($rrdfile)) {
|
|
|
|
if (file_exists($old_rrdfile)) {
|
|
|
|
rename($old_rrdfile, $rrd_file);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
foreach ($etherlike_oids as $oid) {
|
|
|
|
$oid = truncate(str_replace('dot3Stats', '', $oid), 19, '');
|
|
|
|
$rrd_create .= " DS:$oid:COUNTER:600:U:100000000000";
|
|
|
|
}
|
|
|
|
|
|
|
|
rrdtool_create($rrdfile, $rrd_create);
|
|
|
|
}
|
2009-11-24 23:58:56 +00:00
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2015-08-18 16:26:55 +00:00
|
|
|
$fields = array();
|
2015-07-13 20:10:26 +02:00
|
|
|
foreach ($etherlike_oids as $oid) {
|
|
|
|
$data = ($this_port[$oid] + 0);
|
2015-08-18 16:26:55 +00:00
|
|
|
$fields[$oid] = $data;
|
2011-03-16 01:11:27 +00:00
|
|
|
}
|
|
|
|
|
2015-08-18 16:26:55 +00:00
|
|
|
rrdtool_update($rrdfile, $fields);
|
2011-03-16 01:11:27 +00:00
|
|
|
|
2015-08-19 20:58:02 +00:00
|
|
|
$tags = array('ifName' => $port['ifName']);
|
|
|
|
influx_update($device,'dot3',$tags,$fields);
|
|
|
|
|
2015-07-13 20:10:26 +02:00
|
|
|
echo 'EtherLike ';
|
2011-03-16 01:11:27 +00:00
|
|
|
}
|