Merge branch 'master' of git://github.com/librenms/librenms

This commit is contained in:
Paul Gear
2015-04-18 18:56:54 +10:00
33 changed files with 18489 additions and 170 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if (strpos($_SERVER['PATH_INFO'], "debug"))
{
$debug = "1";
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('log_errors', 1);
ini_set('error_reporting', E_ALL);
} else {
$debug = FALSE;
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
ini_set('error_reporting', 0);
}
include "../includes/defaults.inc.php";
include "../config.php";
include_once "../includes/definitions.inc.php";
include "../includes/functions.php";
include "includes/functions.inc.php";
include "includes/vars.inc.php";
include "includes/authenticate.inc.php";
$report = mres($vars['report']);
if( !empty($report) && file_exists("includes/reports/$report.csv.inc.php")) {
if( $debug == false ) {
header("Content-Type: text/csv");
header('Content-Disposition: attachment; filename="'.$report.'-'.date('Ymd').'.csv"');
}
$csv = array();
include_once "includes/reports/$report.csv.inc.php";
foreach( $csv as $line ) {
echo implode(',',$line)."\n";
}
} else {
echo "Report not found.\n";
}
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+4 -4
View File
@@ -19,11 +19,11 @@ if (isset($device['device_id']) && $device['device_id'] > 0) {
}
if ($_SESSION['userlevel'] >= '5') {
$query = "SELECT DATE(time_logged) Date, COUNT(alert_log.device_id) totalCount, alert_rules.severity Severity FROM alert_log,alert_rules WHERE alert_log.rule_id=alert_rules.id $sql GROUP BY DATE(time_logged),alert_rules.severity";
$query = "SELECT DATE_FORMAT(time_logged, '".$config['alert_graph_date_format']."') Date, COUNT(alert_log.rule_id) totalCount, alert_rules.severity Severity FROM alert_log,alert_rules WHERE alert_log.rule_id=alert_rules.id AND `alert_log`.`state` != 0 $sql GROUP BY DATE_FORMAT(time_logged, '".$config['alert_graph_date_format']."'),alert_rules.severity";
}
if ($_SESSION['userlevel'] < '5') {
$query = "SELECT DATE(time_logged) Date, COUNT(alert_log.device_id) totalCount, alert_rules.severity Severity FROM alert_log,alert_rules,devices_perms WHERE alert_log.rule_id=alert_rules.id $sql AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " GROUP BY DATE(time_logged),alert_rules.severity";
$query = "SELECT DATE_FORMAT(time_logged, '".$config['alert_graph_date_format']."') Date, COUNT(alert_log.device_id) totalCount, alert_rules.severity Severity FROM alert_log,alert_rules,devices_perms WHERE alert_log.rule_id=alert_rules.id AND `alert_log`.`state` != 0 $sql AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " GROUP BY DATE_FORMAT(time_logged, '".$config['alert_graph_date_format']."'),alert_rules.severity";
}
?>
@@ -86,7 +86,7 @@ echo $max_count; ?>
}
}
},
zoomMin: 2073600000, //24hrs
zoomMin: 86400, //24hrs
zoomMax: <?php
$first_date = reset($data);
$last_date = end($data);
@@ -97,4 +97,4 @@ echo $milisec_diff;
};
var graph2d = new vis.Graph2d(container, items, groups, options);
</script>
</script>
+5 -1
View File
@@ -433,8 +433,12 @@ Plugins::call('menu');
if ($_SESSION['userlevel'] >= '10')
{
echo('
if (dbFetchCell("SELECT COUNT(*) from `plugins` WHERE plugin_active = '1'") > 0) {
echo('
<li role="presentation" class="divider"></li>
');
}
echo('
<li><a href="plugin/view=admin"> <i class="fa fa-lock fa-fw fa-lg"></i>Plugin Admin</a></li>
');
}
+137
View File
@@ -0,0 +1,137 @@
<?php
$param = array();
if(!isset($vars['ignore'])) { $vars['ignore'] = "0"; }
if(!isset($vars['disabled'])) { $vars['disabled'] = "0"; }
if(!isset($vars['deleted'])) { $vars['deleted'] = "0"; }
$where = '';
foreach ($vars as $var => $value)
{
if ($value != "")
{
switch ($var)
{
case 'hostname':
$where .= " AND D.hostname LIKE ?";
$param[] = "%".$value."%";
break;
case 'location':
$where .= " AND D.location LIKE ?";
$param[] = "%".$value."%";
break;
case 'device_id':
$where .= " AND D.device_id = ?";
$param[] = $value;
break;
case 'deleted':
case 'ignore':
if ($value == 1)
{
$where .= " AND (I.ignore = 1 OR D.ignore = 1) AND I.deleted = 0";
}
break;
case 'disable':
case 'ifSpeed':
if (is_numeric($value))
{
$where .= " AND I.$var = ?";
$param[] = $value;
}
break;
case 'ifType':
$where .= " AND I.$var = ?";
$param[] = $value;
break;
case 'ifAlias':
case 'port_descr_type':
$where .= " AND I.$var LIKE ?";
$param[] = "%".$value."%";
break;
case 'errors':
if ($value == 1)
{
$where .= " AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')";
}
break;
case 'state':
if ($value == "down")
{
$where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ?";
$param[] = "up";
$param[] = "down";
} elseif($value == "up") {
$where .= "AND I.ifAdminStatus = ? AND I.ifOperStatus = ? AND I.ignore = '0' AND D.ignore='0' AND I.deleted='0'";
$param[] = "up";
$param[] = "up";
} elseif($value == "admindown") {
$where .= "AND I.ifAdminStatus = ? AND D.ignore = 0";
$param[] = "down";
}
break;
}
}
}
$query = "SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id ".$where." ".$query_sort;
$row = 1;
list($format, $subformat) = explode("_", $vars['format']);
$ports = dbFetchRows($query, $param);
switch ($vars['sort'])
{
case 'traffic':
$ports = array_sort($ports, 'ifOctets_rate', SORT_DESC);
break;
case 'traffic_in':
$ports = array_sort($ports, 'ifInOctets_rate', SORT_DESC);
break;
case 'traffic_out':
$ports = array_sort($ports, 'ifOutOctets_rate', SORT_DESC);
break;
case 'packets':
$ports = array_sort($ports, 'ifUcastPkts_rate', SORT_DESC);
break;
case 'packets_in':
$ports = array_sort($ports, 'ifInUcastOctets_rate', SORT_DESC);
break;
case 'packets_out':
$ports = array_sort($ports, 'ifOutUcastOctets_rate', SORT_DESC);
break;
case 'errors':
$ports = array_sort($ports, 'ifErrors_rate', SORT_DESC);
break;
case 'speed':
$ports = array_sort($ports, 'ifSpeed', SORT_DESC);
break;
case 'port':
$ports = array_sort($ports, 'ifDescr', SORT_ASC);
break;
case 'media':
$ports = array_sort($ports, 'ifType', SORT_ASC);
break;
case 'descr':
$ports = array_sort($ports, 'ifAlias', SORT_ASC);
break;
case 'device':
default:
$ports = array_sort($ports, 'hostname', SORT_ASC);
}
$csv[] = array('Device','Port','Speed','Down','Up','Media','Description');
foreach( $ports as $port ) {
if( port_permitted($port['port_id'], $port['device_id']) ) {
$speed = humanspeed($port['ifSpeed']);
$type = humanmedia($port['ifType']);
$port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8);
$port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8);
$port = ifLabel($port, $device);
$csv[] = array($port['hostname'],fixIfName($port['label']),$speed,$port['in_rate'],$port['out_rate'],$type,$port['ifAlias']);
}
}
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
foreach ($_GET as $key=>$get_var)
{
if (strstr($key, "opt"))
{
list($name, $value) = explode("|", $get_var);
if (!isset($value)) { $value = "yes"; }
$vars[$name] = $value;
}
}
$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
foreach ($segments as $pos => $segment)
{
$segment = urldecode($segment);
if ($pos == "0")
{
$vars['page'] = $segment;
} else {
list($name, $value) = explode("=", $segment);
if ($value == "" || !isset($value))
{
$vars[$name] = yes;
} else {
$vars[$name] = $value;
}
}
}
foreach ($_GET as $name => $value)
{
$vars[$name] = $value;
}
foreach ($_POST as $name => $value)
{
$vars[$name] = $value;
}
+6 -40
View File
@@ -12,7 +12,11 @@
*
*/
$_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '');
if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) {
$_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']);
} else {
$_SERVER['PATH_INFO'] = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '');
}
function logErrors($errno, $errstr, $errfile, $errline) {
global $php_debug;
@@ -52,6 +56,7 @@ include("../config.php");
include_once("../includes/definitions.inc.php");
include("../includes/functions.php");
include("includes/functions.inc.php");
include("includes/vars.inc.php");
include('includes/plugins.inc.php');
Plugins::start();
@@ -70,45 +75,6 @@ ob_start();
ini_set('allow_url_fopen', 0);
ini_set('display_errors', 0);
foreach ($_GET as $key=>$get_var)
{
if (strstr($key, "opt"))
{
list($name, $value) = explode("|", $get_var);
if (!isset($value)) { $value = "yes"; }
$vars[$name] = $value;
}
}
$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
foreach ($segments as $pos => $segment)
{
$segment = urldecode($segment);
if ($pos == "0")
{
$vars['page'] = $segment;
} else {
list($name, $value) = explode("=", $segment);
if ($value == "" || !isset($value))
{
$vars[$name] = yes;
} else {
$vars[$name] = $value;
}
}
}
foreach ($_GET as $name => $value)
{
$vars[$name] = $value;
}
foreach ($_POST as $name => $value)
{
$vars[$name] = $value;
}
include("includes/authenticate.inc.php");
if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) { $_SESSION['widescreen'] = 1; }
+1 -1
View File
@@ -25,7 +25,7 @@ foreach (dbFetchRows("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.de
$text_descr = str_replace("Sub-Module", "Module ", $text_descr);
$text_descr = str_replace("DFC Card", "DFC", $text_descr);
$proc_url = "device/".$device['device_id']."/health/processor/";
$proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/";
$mini_url = "graph.php?id=".$proc['processor_id']."&amp;type=".$graph_type."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=80&amp;height=20&amp;bg=f4f4f400";
+1
View File
@@ -60,6 +60,7 @@ foreach ($menu_options as $option => $text)
echo('<div style="float: right;">');
?>
<a href="/csv.php/report=<?php echo generate_url($vars,array('format'=>'')); ?>" title="Export as CSV" target="_blank">Export CSV</a> |
<a href="<?php echo(generate_url($vars)); ?>" title="Update the browser URL to reflect the search criteria." >Update URL</a> |
<?php
+1 -1
View File
@@ -55,7 +55,7 @@ $pdf->setTextShadow(array('enabled'=>false, 'depth_w'=>0.2, 'depth_h'=>0.2, 'col
if (isset($_GET['report']) && !empty($_GET['report'])) {
$report = mres($_GET['report']);
$pdf->SetHeaderData('../../' . $config['title_image'], 40, ucfirst($report), $config['project_name'], array(0,0,0), array(0,64,128));
include_once "includes/reports/$report.inc.php";
include_once "includes/reports/$report.pdf.inc.php";
} else {
$report = 'report';
}