2011-09-08 02:57:02 +00:00
|
|
|
<?php
|
|
|
|
|
2012-05-09 10:01:42 +00:00
|
|
|
/**
|
2016-08-20 12:16:55 +01:00
|
|
|
* LibreNMS
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2016-08-20 12:16:55 +01:00
|
|
|
* This file is part of LibreNMS.
|
2012-05-09 10:01:42 +00:00
|
|
|
*
|
2013-10-29 05:38:12 +10:00
|
|
|
* @copyright (C) 2006 - 2012 Adam Armstrong
|
2012-05-09 10:01:42 +00:00
|
|
|
*/
|
2020-09-21 14:54:51 +02:00
|
|
|
$init_modules = ['web', 'auth'];
|
2016-11-21 14:12:59 -06:00
|
|
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2019-06-23 00:29:12 -05:00
|
|
|
if (is_numeric($_GET['id']) && (\LibreNMS\Config::get('allow_unauth_graphs') || port_permitted($_GET['id']))) {
|
2020-09-21 14:54:51 +02:00
|
|
|
$port = cleanPort(get_port_by_id($_GET['id']));
|
2015-07-13 20:10:26 +02:00
|
|
|
$device = device_by_id_cache($port['device_id']);
|
2020-09-21 14:54:51 +02:00
|
|
|
$title = generate_device_link($device);
|
|
|
|
$title .= ' :: Port ' . generate_port_link($port);
|
|
|
|
$auth = true;
|
2011-09-08 02:57:02 +00:00
|
|
|
|
2020-09-21 14:54:51 +02:00
|
|
|
$in = snmp_get($device, 'ifHCInOctets.' . $port['ifIndex'], '-OUqnv', 'IF-MIB');
|
2019-04-11 23:26:42 -05:00
|
|
|
if (empty($in)) {
|
2020-09-21 14:54:51 +02:00
|
|
|
$in = snmp_get($device, 'ifInOctets.' . $port['ifIndex'], '-OUqnv', 'IF-MIB');
|
2019-04-11 23:26:42 -05:00
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2020-09-21 14:54:51 +02:00
|
|
|
$out = snmp_get($device, 'ifHCOutOctets.' . $port['ifIndex'], '-OUqnv', 'IF-MIB');
|
2019-04-11 23:26:42 -05:00
|
|
|
if (empty($out)) {
|
2020-09-21 14:54:51 +02:00
|
|
|
$out = snmp_get($device, 'ifOutOctets.' . $port['ifIndex'], '-OUqnv', 'IF-MIB');
|
2019-04-11 23:26:42 -05:00
|
|
|
}
|
2011-09-08 02:57:02 +00:00
|
|
|
|
2019-05-01 17:02:15 -05:00
|
|
|
$time = microtime(true);
|
2011-09-08 02:57:02 +00:00
|
|
|
|
2019-05-01 17:02:15 -05:00
|
|
|
printf("%lf|%s|%s\n", $time, $in, $out);
|
2019-04-11 23:26:42 -05:00
|
|
|
}
|