Merge branch 'master' of github.com:laf/librenms into issue-711

This commit is contained in:
laf
2015-04-18 19:23:33 +01:00
63 changed files with 23057 additions and 296 deletions
+1 -1
View File
@@ -1606,7 +1606,7 @@ tr.search:nth-child(odd) {
height: 600px;
}
.75pc-width {
.threeqtr-width {
display:block;
width: 75%;
}
+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

+26 -10
View File
@@ -122,7 +122,7 @@ function generate_device_url($device, $vars=array())
return generate_url(array('page' => 'device', 'device' => $device['device_id']), $vars);
}
function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end=0, $escape_text=1)
function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end=0, $escape_text=1, $overlib=1)
{
global $config;
@@ -168,7 +168,11 @@ function generate_device_link($device, $text=NULL, $vars=array(), $start=0, $end
}
if ($escape_text) { $text = htmlentities($text); }
$link = overlib_link($url, $text, escape_quotes($contents), $class);
if ($overlib == 0) {
$link = $contents;
} else {
$link = overlib_link($url, $text, escape_quotes($contents), $class);
}
if (device_permitted($device['device_id']))
{
@@ -404,7 +408,7 @@ function generate_entity_link($type, $entity, $text = NULL, $graph_type=NULL)
}
function generate_port_link($port, $text = NULL, $type = NULL)
function generate_port_link($port, $text = NULL, $type = NULL, $overlib = 1, $single_graph = 0)
{
global $config;
@@ -429,17 +433,21 @@ function generate_port_link($port, $text = NULL, $type = NULL)
$graph_array['from'] = $config['time']['day'];
$graph_array['id'] = $port['port_id'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['week'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['month'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['year'];
$content .= generate_graph_tag($graph_array);
if ($single_graph == 0) {
$graph_array['from'] = $config['time']['week'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['month'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['year'];
$content .= generate_graph_tag($graph_array);
}
$content .= "</div>";
$url = generate_port_url($port);
if (port_permitted($port['port_id'], $port['device_id'])) {
if ($overlib == 0) {
return $content;
} elseif (port_permitted($port['port_id'], $port['device_id'])) {
return overlib_link($url, $text, $content, $class);
} else {
return fixifName($text);
@@ -744,4 +752,12 @@ function shorten_interface_type($string) {
);
}
function clean_bootgrid($string) {
$output = str_replace(array("\r","\n"), "", $string);
$output = addslashes($output);
return $output;
}
?>
+1 -1
View File
@@ -25,7 +25,7 @@ $rrd_options .= " AREA:system_perc#ea8f00:system:STACK";
$rrd_options .= " GPRINT:system_perc:LAST:' %5.2lf%%'";
$rrd_options .= " GPRINT:system_perc:AVERAGE:' %5.2lf%%'";
$rrd_options .= " GPRINT:system_perc:MAX:' %5.2lf%%\\n'";
$rrd_options .= " AREA:idle_perc#f5f5e5:idle:STACK";
$rrd_options .= " AREA:idle_perc#f8f8f3:idle:STACK";
$rrd_options .= " GPRINT:idle_perc:LAST:' %5.2lf%%'";
$rrd_options .= " GPRINT:idle_perc:AVERAGE:' %5.2lf%%'";
$rrd_options .= " GPRINT:idle_perc:MAX:' %5.2lf%%\\n'";
+6 -4
View File
@@ -93,16 +93,18 @@ if($format == "octets" || $format == "bytes")
$rrd_options .= " COMMENT:'bps Now Ave Max 95th %\\n'";
$rrd_options .= " AREA:in".$format."_max#aDEB7B:";
$rrd_options .= " AREA:in".$format."#91B13C:'In '";
$rrd_options .= " AREA:in".$format."_max#D7FFC7:";
$rrd_options .= " AREA:in".$format."#90B040:'In '";
$rrd_options .= " LINE:in".$format."#608720:'In '";
#$rrd_options .= " LINE1.25:in".$format."#006600:'In '";
$rrd_options .= " GPRINT:in".$format.":LAST:%6.2lf%s";
$rrd_options .= " GPRINT:in".$format.":AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:in".$format."_max:MAX:%6.2lf%s";
$rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n";
$rrd_options .= " AREA:dout".$format."_max#a3b9FF:";
$rrd_options .= " AREA:dout".$format."#8080BD:'Out'";
$rrd_options .= " AREA:dout".$format."_max#E0E0FF:";
$rrd_options .= " AREA:dout".$format."#8080C0:";
$rrd_options .= " LINE:dout".$format."#606090:'Out'";
#$rrd_options .= " LINE1.25:dout".$format."#000099:Out";
$rrd_options .= " GPRINT:out".$format.":LAST:%6.2lf%s";
$rrd_options .= " GPRINT:out".$format.":AVERAGE:%6.2lf%s";
+1 -1
View File
@@ -47,7 +47,7 @@ foreach ($sql_debug as $sql_error) {
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">SQL Debug</h4>
<h4 class="modal-title" id="myModalLabel">PHP Debug</h4>
</div>
<div class="modal-body">
<table class="table table-condensed table-hover">
+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>
+40 -9
View File
@@ -25,12 +25,12 @@ $sql .= ' AND `local_device_id` != 0 AND `remote_device_id` != 0';
$tmp_ids = array();
foreach (dbFetchRows("SELECT DISTINCT least(`devices`.`device_id`, `remote_device_id`) AS `remote_device_id`, GREATEST(`remote_device_id`,`devices`.`device_id`) AS `local_device_id` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` $sql", $sql_array) as $link_devices) {
if (!in_array($link_devices['local_device_id'], $tmp_ids) && device_permitted($link_devices['local_device_id'])) {
$link_dev = dbFetchRow("SELECT `hostname`,`location` FROM `devices` WHERE `device_id`=?",array($link_devices['local_device_id']));
$tmp_devices[] = array('id'=>$link_devices['local_device_id'],'label'=>$link_dev['hostname'],'title'=>$link_dev['hostname'],'group'=>$link_dev['location']);
$link_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?",array($link_devices['local_device_id']));
$tmp_devices[] = array('id'=>$link_devices['local_device_id'],'label'=>$link_dev['hostname'],'title'=>generate_device_link($link_dev,'',array(),'','','',0),'group'=>$link_dev['location'],'shape'=>'box');
}
if (!in_array($link_devices['remote_device_id'], $tmp_ids) && device_permitted($link_devices['remote_device_id'])) {
$link_dev = dbFetchRow("SELECT `hostname`,`location` FROM `devices` WHERE `device_id`=?",array($link_devices['remote_device_id']));
$tmp_devices[] = array('id'=>$link_devices['remote_device_id'],'label'=>$link_dev['hostname'],'title'=>$link_dev['hostname'],'group'=>$link_dev['location']);
$link_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?",array($link_devices['remote_device_id']));
$tmp_devices[] = array('id'=>$link_devices['remote_device_id'],'label'=>$link_dev['hostname'],'title'=>generate_device_link($link_dev,'',array(),'','','',0),'group'=>$link_dev['location'],'shape'=>'box');
}
array_push($tmp_ids,$link_devices['local_device_id']);
array_push($tmp_ids,$link_devices['remote_device_id']);
@@ -42,11 +42,12 @@ $nodes = json_encode($tmp_devices);
if (is_array($tmp_devices[0])) {
$tmp_links = array();
foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.`ifName` AS `local_port`, `remote_port`,`ports`.`ifSpeed` AS ifSpeed FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_ids) AND `remote_device_id` IN ($tmp_ids))") as $link_devices) {
foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ($tmp_ids) AND `remote_device_id` IN ($tmp_ids))") as $link_devices) {
foreach ($tmp_devices as $k=>$v) {
if ($v['id'] == $link_devices['local_device_id']) {
$from = $v['id'];
$port = shorten_interface_type($link_devices['local_port']);
$port = shorten_interface_type($link_devices['ifName']);
$port_data = $link_devices;
}
if ($v['id'] == $link_devices['remote_device_id']) {
$to = $v['id'];
@@ -67,7 +68,20 @@ if (is_array($tmp_devices[0])) {
} else {
$width = 1;
}
$tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>$port,'width'=>$width);
$link_in_used = ($link_devices['ifInOctets_rate'] * 8) / $link_devices['ifSpeed'] * 100;
$link_out_used = ($link_devices['ifOutOctets_rate'] * 8) / $link_devices['ifSpeed'] * 100;
if ($link_in_used > $link_out_used) {
$link_used = $link_in_used;
} else {
$link_used = $link_out_used;
}
$link_used = round($link_used, -1);
if ($link_used > 100) {
$link_used = 100;
}
$link_color = $config['map_legend'][$link_used];
$tmp_links[] = array('from'=>$from,'to'=>$to,'label'=>$port,'title'=>generate_port_link($port_data, "<img src='graph.php?type=port_bits&amp;id=".$port['port_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>",'',0,1),'width'=>$width,'color'=>$link_color);
}
$edges = json_encode($tmp_links);
@@ -97,9 +111,26 @@ echo $edges;
var data = {
nodes: nodes,
edges: edges,
stabilize: true
stabilize: false
};
var options = {
physics: {
barnesHut: {
gravitationalConstant: -80000, springConstant: 0.001, springLength: 200
}
},
tooltip: {
color: {
background: '#ffffff'
}
},
smoothCurves: {dynamic:false, type: "continuous"},
edges: {
color: {
color: '#000000'
}
}
};
var options = {physics: {barnesHut: {gravitationalConstant: -11900, centralGravity: 1.4, springLength: 203, springConstant: 0.05, damping: 0.3}}, smoothCurves: false};
var network = new vis.Network(container, data, options);
network.on("resize", function(params) {console.log(params.width,params.height)});
network.on('click', function (properties) {
+9 -3
View File
@@ -1,4 +1,5 @@
<?php
include($config['install_dir'].'/includes/object-cache.inc.php');
// FIXME - this could do with some performance improvements, i think. possible rearranging some tables and setting flags at poller time (nothing changes outside of then anyways)
@@ -194,13 +195,14 @@ if ($_SESSION['userlevel'] >= '10')
<li><a href="ports/"><i class="fa fa-link fa-fw fa-lg"></i> All Ports</a></li>
<?php
$ports = new ObjCache('ports');
if (isset($ports['errored']))
if ($ports['errored'] > 0)
{
echo(' <li><a href="ports/errors=1/"><i class="fa fa-exclamation-circle fa-fw fa-lg"></i> Errored ('.$ports['errored'].')</a></li>');
}
if (isset($ports['ignored']))
if ($ports['ignored'] > 0)
{
echo(' <li><a href="ports/ignore=1/"><i class="fa fa-question-circle fa-fw fa-lg"></i> Ignored ('.$ports['ignored'].')</a></li>');
}
@@ -431,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;
}
+7 -41
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; }
@@ -338,7 +304,7 @@ toastr.options.extendedTimeOut = 20;
echo("</script>");
}
if (is_array($sql_debug) && is_array($php_debug)) {
if (is_array($sql_debug) && is_array($php_debug) && $_SESSION['authenticated'] === TRUE) {
include_once "includes/print-debug.php";
+71 -13
View File
@@ -93,6 +93,59 @@ list($format, $subformat) = explode("_", $vars['format']);
if($format == "graph")
{
$sql_param = array();
if(isset($vars['state']))
{
if($vars['state'] == 'up')
{
$state = '1';
}
elseif($vars['state'] == 'down')
{
$state = '0';
}
}
if (!empty($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; }
if (!empty($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; }
if (!empty($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; }
if (!empty($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; }
if (!empty($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; }
if (!empty($vars['type'])) {
if ($vars['type'] == 'generic') {
$where .= " AND ( type = ? OR type = '')"; $sql_param[] = $vars['type'];
} else {
$where .= " AND type = ?"; $sql_param[] = $vars['type'];
}
}
if (!empty($vars['state'])) {
$where .= " AND status= ?"; $sql_param[] = $state;
$where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = '';
}
if (!empty($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; }
if (!empty($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; }
if (!empty($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; }
if (!empty($vars['location'])) { $location_filter = $vars['location']; }
if( !empty($vars['group']) ) {
require_once('../includes/device-groups.inc.php');
$where .= " AND ( ";
foreach( GetDevicesFromGroup($vars['group']) as $dev ) {
$where .= "device_id = ? OR ";
$sql_param[] = $dev['device_id'];
}
$where = substr($where, 0, strlen($where)-3);
$where .= " )";
}
$query = "SELECT * FROM `devices` WHERE 1 ";
if (isset($where)) {
$query .= $where;
}
$query .= " ORDER BY hostname";
$row = 1;
foreach (dbFetchRows($query, $sql_param) as $device)
{
@@ -149,7 +202,7 @@ var grid = $("#devices").bootgrid({
columnSelection: false,
formatters: {
"status": function(column,row) {
return "<h4><span class='label label-"+row.extra+" 75pc-width'>" + row.msg + "</span></h4>";
return "<h4><span class='label label-"+row.extra+" threeqtr-width'>" + row.msg + "</span></h4>";
}
},
templates: {
@@ -165,11 +218,12 @@ var grid = $("#devices").bootgrid({
foreach (dbFetch('SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY `os`') as $data) {
if ($data['os']) {
echo('"<option value=\"'.$data['os'].'\""+');
if ($data['os'] == $vars['os']) {
$tmp_os = clean_bootgrid($data['os']);
echo('"<option value=\"'.$tmp_os.'\""+');
if ($tmp_os == $vars['os']) {
echo('" selected "+');
}
echo('">'.$config['os'][$data['os']]['text'].'</option>"+');
echo('">'.$config['os'][$tmp_os]['text'].'</option>"+');
}
}
?>
@@ -182,11 +236,12 @@ foreach (dbFetch('SELECT `os` FROM `devices` AS D WHERE 1 GROUP BY `os` ORDER BY
foreach (dbFetch('SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version` ORDER BY `version`') as $data) {
if ($data['version']) {
echo('"<option value=\"'.$data['version'].'\""+');
if ($data['version'] == $vars['version']) {
$tmp_version = clean_bootgrid($data['version']);
echo('"<option value=\"'.$tmp_version.'\""+');
if ($tmp_version == $vars['version']) {
echo('" selected "+');
}
echo('">'.$data['version'].'</option>"+');
echo('">'.$tmp_version.'</option>"+');
}
}
?>
@@ -199,11 +254,12 @@ foreach (dbFetch('SELECT `version` FROM `devices` AS D WHERE 1 GROUP BY `version
foreach (dbFetch('SELECT `hardware` FROM `devices` AS D WHERE 1 GROUP BY `hardware` ORDER BY `hardware`') as $data) {
if ($data['hardware']) {
echo('"<option value=\"'.$data['hardware'].'\""+');
if ($data['hardware'] == $vars['hardware']) {
$tmp_hardware = clean_bootgrid($data['hardware']);
echo('"<option value=\"'.$tmp_hardware.'\""+');
if ($tmp_hardware == $vars['hardware']) {
echo('" selected"+');
}
echo('">'.$data['hardware'].'</option>"+');
echo('">'.$tmp_hardware.'</option>"+');
}
}
@@ -219,11 +275,12 @@ foreach (dbFetch('SELECT `features` FROM `devices` AS D WHERE 1 GROUP BY `featur
{
if ($data['features'])
{
echo('"<option value=\"'.$data['features'].'\""+');
if ($data['features'] == $vars['features']) {
$tmp_features = clean_bootgrid($data['features']);
echo('"<option value=\"'.$tmp_features.'\""+');
if ($tmp_features == $vars['features']) {
echo('" selected"+');
}
echo('">'.$data['features'].'</option>"+');
echo('">'.$tmp_features.'</option>"+');
}
}
@@ -239,6 +296,7 @@ foreach (dbFetch('SELECT `features` FROM `devices` AS D WHERE 1 GROUP BY `featur
foreach (getlocations() as $location) {
if ($location) {
$location = clean_bootgrid($location);
echo('"<option value=\"'.$location.'\""+');
if ($location == $vars['location']) {
echo('" selected"+');
+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';
}