librenms/html/data.php

37 lines
1009 B
PHP
Raw Normal View History

<?php
/**
2016-08-20 11:16:55 +00:00
* LibreNMS
*
2016-08-20 11:16:55 +00:00
* This file is part of LibreNMS.
*
2016-08-20 11:16:55 +00:00
* @package librenms
2013-10-28 19:38:12 +00:00
* @subpackage webinterface
* @copyright (C) 2006 - 2012 Adam Armstrong
*/
$init_modules = array('web', 'auth');
require realpath(__DIR__ . '/..') . '/includes/init.php';
2015-07-13 18:10:26 +00:00
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) {
$port = get_port_by_id($_GET['id']);
$device = device_by_id_cache($port['device_id']);
$title = generate_device_link($device);
$title .= ' :: Port '.generate_port_link($port);
$auth = true;
}
$in = snmp_get($device, 'ifHCInOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
2015-07-13 18:10:26 +00:00
if (empty($in)) {
$in = snmp_get($device, 'ifInOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
}
2015-07-13 18:10:26 +00:00
$out = snmp_get($device, 'ifHCOutOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
2015-07-13 18:10:26 +00:00
if (empty($out)) {
$out = snmp_get($device, 'ifOutOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
}
$time = time();
printf("%lf|%s|%s\n", time(), $in, $out);