Rebased SQL file

This commit is contained in:
laf
2015-11-18 23:55:00 +00:00
47 changed files with 551 additions and 86 deletions

View File

@@ -3,8 +3,8 @@
// easier to rewrite for Active Directory than to bash it into existing LDAP implementation
// disable certificate checking before connect if required
if (isset($config['auth_ad_dont_check_certificates']) &&
$config['auth_ad_dont_check_certificates'] > 0) {
if (isset($config['auth_ad_check_certificates']) &&
$config['auth_ad_check_certificates'] == 0) {
putenv('LDAPTLS_REQCERT=never');
};
@@ -35,6 +35,7 @@ function authenticate($username, $password) {
if (isset($config['auth_ad_groups'][$group_cn]['level'])) {
// user is in one of the defined groups
$user_authenticated = 1;
adduser($username);
}
}
@@ -43,6 +44,7 @@ function authenticate($username, $password) {
}
else {
// group membership is not required and user is valid
adduser($username);
return 1;
}
}
@@ -81,11 +83,20 @@ function auth_usermanagement() {
}
function adduser() {
// not supported so return 0
return 0;
function adduser($username) {
// Check to see if user is already added in the database
if (!user_exists_in_db($username)) {
return dbInsert(array('username' => $username, 'user_id' => get_userid($username), 'level' => "0", 'can_modify_passwd' => 0, 'twofactor' => 0), 'users');
}
else {
return false;
}
}
function user_exists_in_db($username) {
$return = dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true);
return $return;
}
function user_exists($username) {
global $config, $ds;

View File

@@ -30,7 +30,7 @@ if ($config['map']['engine'] == 'leaflet') {
<div class="col-sm-4">
<label for="init_lat" class="control-label">Initial Latitude: </label>
</div>
<div class="col-sm-6">
<div class="col-sm-8">
<input class="form-control" name="init_lat" id="input_lat_'.$unique_id.'" value="'.$widget_settings['init_lat'].'" placeholder="ie. 51.4800 for Greenwich">
</div>
</div>
@@ -46,7 +46,7 @@ if ($config['map']['engine'] == 'leaflet') {
<div class="col-sm-4">
<label for="init_zoom" class="control-label">Initial Zoom: </label>
</div>
<div class="col-sm-6">
<div class="col-sm-8">
<select class="form-control" name="init_zoom" id="select_zoom'.$unique_id.'">
';
for ($i=0; $i<19; $i++) {
@@ -65,10 +65,35 @@ if ($config['map']['engine'] == 'leaflet') {
<div class="col-sm-4">
<label for="group_radius" class="control-label">Grouping radius: </label>
</div>
<div class="col-sm-4">
<div class="col-sm-8">
<input class="form-control" name="group_radius" id="input_radius_'.$unique_id.'" value="'.$widget_settings['group_radius'].'" placeholder="default 80">
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<label for="status" class="control-label">Show devices: </label>
</div>
<div class="col-sm-8">
<select class="form-control" name="status" id="status_'.$unique_id.'">';
$temp_output .= '<option value="0,1"';
if ($widget_settings['status'] == '0,1') {
$temp_output .= ' selected';
}
$temp_output .= '>Up + Down</option>
<option value="1"';
if ($widget_settings['status'] == '1') {
$temp_output .= ' selected';
}
$temp_output .= '>Up</option>
<option value="0"';
if ($widget_settings['status'] == '0') {
$temp_output .= ' selected';
}
$temp_output .= '>Down</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
<button type="submit" class="btn btn-default">Set</button>
@@ -101,6 +126,9 @@ if ($config['map']['engine'] == 'leaflet') {
else {
$group_radius = 80;
}
if (empty($widget_settings['status']) && $widget_settings['status'] != '0') {
$widget_settings['status'] = '0,1';
}
$map_init = "[" . $init_lat . ", " . $init_lng . "], " . sprintf("%01.0f", $init_zoom);
$temp_output .= 'var map = L.map(\'leaflet-map\').setView('.$map_init.');
L.tileLayer(\'//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {
@@ -125,6 +153,7 @@ var greenMarker = L.AwesomeMarkers.icon({
$sql = "SELECT DISTINCT(`device_id`),`hostname`,`os`,`status`,`lat`,`lng` FROM `devices`
LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location`
WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != ''
AND `status` IN (".$widget_settings['status'].")
ORDER BY `status` ASC, `hostname`";
}
else {
@@ -134,10 +163,11 @@ var greenMarker = L.AwesomeMarkers.icon({
LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location`
WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != ''
AND `devices`.`device_id` = `devices_perms`.`device_id`
AND `devices_perms`.`user_id` = ?
AND `devices_perms`.`user_id` = ? AND `status` IN (".$widget_settings['status'].")
ORDER BY `status` ASC, `hostname`";
$param[] = $_SESSION['user_id'];
}
foreach (dbFetchRows($sql, array($_SESSION['user_id'])) as $map_devices) {
foreach (dbFetchRows($sql, $param) as $map_devices) {
$icon = 'greenMarker';
$z_offset = 0;
if ($map_devices['status'] == 0) {

View File

@@ -0,0 +1,30 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
* 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.
*/
$status = 'error';
$message = 'unknown error';
$parameter = mres($_POST['parameter']);
if (isset($parameter)) {
$status = 'ok';
$message = 'Queried';
$output = get_ripe_api_whois_data_json($parameter);
}
else {
$status = 'error';
$message = 'ERROR: Could not query';
}
die(json_encode(array(
'status' => $status,
'message' => $message,
'parameter' => $parameter,
'output' => $output
)));

View File

@@ -1178,6 +1178,9 @@ function dynamic_override_config($type, $name, $device) {
if ($type == 'checkbox') {
return '<input type="checkbox" id="override_config" name="override_config" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" data-size="small" '.$checked.'>';
}
elseif ($type == 'text') {
return '<input type="text" id="override_config_text" name="override_config_text" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" value="'.$attrib_val.'">';
}
}//end dynamic_override_config()
function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') {
@@ -1249,3 +1252,9 @@ function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$it
}
return $output;
}//end generate_dynamic_config_panel()
function get_ripe_api_whois_data_json($ripe_parameter) {
$ripe_whois_url = 'https://stat.ripe.net/data/whois/data.json?resource=' . $ripe_parameter;
return json_decode(file_get_contents($ripe_whois_url) , true);
}//end get_ripe_api_whois_data_json()

View File

@@ -39,7 +39,7 @@ $rrd_options .= ' GPRINT:availreal:LAST:\ \ \ %7.2lf%sB';
$rrd_options .= ' GPRINT:availreal:AVERAGE:%7.2lf%sB';
$rrd_options .= " GPRINT:availreal:MAX:%7.2lf%sB\\\\n";
$rrd_options .= ' LINE1:usedreal#d0b080:';
$rrd_options .= ' AREA:shared#afeced::';
$rrd_options .= ' AREA:shared#afeced:';
$rrd_options .= ' AREA:buffered#cc0000::STACK';
$rrd_options .= ' AREA:cached#ffaa66::STACK';
$rrd_options .= ' LINE1.25:shared#008fea:shared';

View File

@@ -53,14 +53,14 @@ else {
foreach ($rrd_list as $rrd) {
$colours = (isset($rrd['colour']) ? $rrd['colour'] : 'default');
$strlen = ((strlen($rrd['descr']) < $descr_len) ? ($descr_len - strlen($rrd['descr'])) : '0');
$descr = (isset($rrd['descr']) ? rrdtool_escape($rrd['descr'], ($desc_len + $strlen)) : 'Unkown');
$descr = (isset($rrd['descr']) ? rrdtool_escape($rrd['descr'], ($desc_len + $strlen)) : 'Unknown');
for ($z = 0; $z < $strlen;
$z++) {
$descr .= ' ';
}
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
$colour = $config['graph_colours'][$colours][$x];
@@ -68,7 +68,7 @@ foreach ($rrd_list as $rrd) {
$rrd_options .= ' DEF:peak'.$x.'='.$rrd['filename'].':peak:MAX';
$rrd_options .= ' DEF:unique'.$x.'='.$rrd['filename'].':unique:AVERAGE';
$rrd_options .= ' VDEF:avg'.$x.'=cur'.$x.',AVERAGE';
$rrd_options .= ' AREA:cur'.$x.'#'.$colour.':"'.$descr."\":$stack";
$rrd_options .= ' AREA:cur'.$x.'#'.$colour.":'".$descr."'$stack";
$rrd_options .= ' GPRINT:cur'.$x.':LAST:"%6.2lf"';
$rrd_options .= ' GPRINT:unique'.$x.':LAST:"%6.2lf%s"';
$rrd_options .= ' GPRINT:avg'.$x.':"%6.2lf"';
@@ -97,7 +97,7 @@ if (!$nototal) {
$rrd_options .= ' CDEF:totunique=unique0'.$totunique;
$rrd_options .= ' CDEF:totpeak=peak0'.$totpeak;
$rrd_options .= ' VDEF:totavg=totcur,AVERAGE';
$rrd_options .= ' LINE2:totcur#'.$colour.':"'.$descr.'"';
$rrd_options .= ' LINE2:totcur#'.$colour.":'".$descr."'";
$rrd_options .= ' GPRINT:totcur:LAST:"%6.2lf"';
$rrd_options .= ' GPRINT:totunique:LAST:"%6.2lf%s"';
$rrd_options .= ' GPRINT:totavg:"%6.2lf"';

View File

@@ -46,7 +46,7 @@ foreach (dbFetchRows('SELECT * FROM `mempools` where `device_id` = ?', array($de
$rrd_optionsb .= " LINE1:mempooltotal$i#".$colour.":'".$descr."' ";
$rrd_optionsb .= " GPRINT:mempooltotal$i:MIN:%3.0lf%%";
$rrd_optionsb .= " GPRINT:mempooltotal$i:LAST:%3.0lf%%";
$rrd_optionsb .= " GPRINT:mempooltotal$i:MAX:%3.0lf%%\\\l ";
$rrd_optionsb .= " GPRINT:mempooltotal$i:MAX:%3.0lf%%\\l ";
$iter++;
$i++;
}

View File

@@ -37,6 +37,7 @@ foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filena
$colour = $config['graph_colours'][$colourset][$iter];
$iter++;
// FIXME: $descr unused? -- PDG 2015-11-14
$descr = rrdtool_escape($source, $descr_len);
$filename = generate_smokeping_file($device,$filename);

View File

@@ -42,6 +42,6 @@ foreach (dbFetchRows('SELECT * FROM storage where device_id = ?', array($device[
$rrd_options .= " LINE1.25:$storage[storage_id]perc#".$colour.":'$descr'";
$rrd_options .= " GPRINT:$storage[storage_id]size:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:$storage[storage_id]used:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\\\l";
$rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\l";
$iter++;
}//end foreach

View File

@@ -14,12 +14,12 @@ $rrd_options .= ' CDEF:b=5min,100,/';
$rrd_options .= ' CDEF:c=15min,100,/';
$rrd_options .= ' CDEF:cdefd=a,b,c,+,+';
$rrd_options .= " COMMENT:'Load Average Current Average Maximum\\n'";
$rrd_options .= " AREA:a#ffeeaa:'1 Min':";
$rrd_options .= " AREA:a#ffeeaa:'1 Min'";
$rrd_options .= ' LINE1:a#c5aa00:';
$rrd_options .= " GPRINT:a:LAST:' %7.2lf'";
$rrd_options .= " GPRINT:a:AVERAGE:' %7.2lf'";
$rrd_options .= " GPRINT:a:MAX:' %7.2lf\\n'";
$rrd_options .= " LINE1.25:b#ea8f00:'5 Min':";
$rrd_options .= " LINE1.25:b#ea8f00:'5 Min'";
$rrd_options .= " GPRINT:b:LAST:' %7.2lf'";
$rrd_options .= " GPRINT:b:AVERAGE:' %7.2lf'";
$rrd_options .= " GPRINT:b:MAX:' %7.2lf\\n'";

View File

@@ -73,7 +73,7 @@ $rrd_options .= " 'COMMENT: \\n'";
$rrd_options .= " 'LINE1:usedreal#d0b080:'";
$rrd_options .= " 'AREA:shared#afeced::'";
$rrd_options .= " 'AREA:shared#afeced:'";
$rrd_options .= " 'AREA:buffered#cc0000::STACK'";
$rrd_options .= " 'AREA:cached#ffaa66::STACK'";

View File

@@ -107,7 +107,7 @@ $rrd_options .= ' LINE:in'.$format."#608720:'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 .= " GPRINT:95thin:%6.2lf%s\\n";
$rrd_options .= ' AREA:dout'.$format.'_max#E0E0FF:';
$rrd_options .= ' AREA:dout'.$format.'#8080C0:';
@@ -116,7 +116,7 @@ $rrd_options .= ' LINE:dout'.$format."#606090:'Out'";
$rrd_options .= ' GPRINT:out'.$format.':LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:out'.$format.':AVERAGE:%6.2lf%s';
$rrd_options .= ' GPRINT:out'.$format.'_max:MAX:%6.2lf%s';
$rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n";
$rrd_options .= " GPRINT:95thout:%6.2lf%s\\n";
if ($config['rrdgraph_real_95th']) {
$rrd_options .= ' HRULE:95thhigh#FF0000:"Highest"';
@@ -125,7 +125,7 @@ if ($config['rrdgraph_real_95th']) {
$rrd_options .= " GPRINT:tot:'Total %6.2lf%s'";
$rrd_options .= " GPRINT:totin:'(In %6.2lf%s'";
$rrd_options .= " GPRINT:totout:'Out %6.2lf%s)\\\\l'";
$rrd_options .= " GPRINT:totout:'Out %6.2lf%s)\\l'";
$rrd_options .= ' LINE1:95thin#aa0000';
$rrd_options .= ' LINE1:d95thout#aa0000';

View File

@@ -11,7 +11,7 @@ else {
}
if ($nototal) {
$descrlen += '2';
$descr_len += '2';
$unitlen += '2';
}
@@ -57,16 +57,16 @@ foreach ($rrd_list as $rrd) {
if ($rrd['invert']) {
$rrd_options .= ' CDEF:'.$id.'i='.$id.',-1,*';
$rrd_optionsc .= ' AREA:'.$id.'i#'.$colour.":'$descr':".$cstack;
$rrd_optionsc .= ' AREA:'.$id.'i#'.$colour.":'$descr'".$cstack;
$rrd_optionsc .= ' GPRINT:'.$id.':LAST:%5.1lf%s GPRINT:'.$id.'min:MIN:%5.1lf%s';
$rrd_optionsc .= ' GPRINT:'.$id.'max:MAX:%5.1lf%s GPRINT:'.$id.":AVERAGE:'%5.1lf%s\\n'";
$cstack = 'STACK';
$cstack = ':STACK';
}
else {
$rrd_optionsb .= ' AREA:'.$id.'#'.$colour.":'$descr':".$bstack;
$rrd_optionsb .= ' AREA:'.$id.'#'.$colour.":'$descr'".$bstack;
$rrd_optionsb .= ' GPRINT:'.$id.':LAST:%5.1lf%s GPRINT:'.$id.'min:MIN:%5.1lf%s';
$rrd_optionsb .= ' GPRINT:'.$id.'max:MAX:%5.1lf%s GPRINT:'.$id.":AVERAGE:'%5.1lf%s\\n'";
$bstack = 'STACK';
$bstack = ':STACK';
}
$i++;

View File

@@ -49,9 +49,6 @@ foreach ($rrd_list as $rrd) {
}
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len).' Out';
$descr = str_replace("'", '', $descr);
// FIXME does this mean ' should be filtered in rrdtool_escape? probably...
$descr_out = str_replace("'", '', $descr_out);
}
$rrd_options .= ' DEF:'.$in.$i.'='.$rrd['filename'].':'.$ds_in.':AVERAGE ';
@@ -68,10 +65,10 @@ foreach ($rrd_list as $rrd) {
}
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."':$stack";
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."'$stack";
if (!$nodetails) {
$rrd_options .= ' GPRINT:inB'.$i.":LAST:%6.2lf%s$units";
$rrd_options .= ' GPRINT:inB'.$i.":AVERAGE:%6.2lf%s$units";
@@ -84,7 +81,7 @@ foreach ($rrd_list as $rrd) {
}
$rrd_options .= " 'HRULE:0#".$colour_out.':'.$descr_out."'";
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out."::$stack'";
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out.":$stack'";
if (!$nodetails) {
$rrd_options .= ' GPRINT:outB'.$i.":LAST:%6.2lf%s$units";

View File

@@ -45,9 +45,6 @@ foreach ($rrd_list as $rrd) {
}
$descr_out = rrdtool_escape($rrd['descr_out'], $descr_len).' Out';
$descr = str_replace("'", '', $descr);
// FIXME does this mean ' should be filtered in rrdtool_escape? probably...
$descr_out = str_replace("'", '', $descr_out);
$rrd_options .= ' DEF:'.$in.$i.'='.$rrd['filename'].':'.$ds_in.':AVERAGE ';
$rrd_options .= ' DEF:'.$out.$i.'='.$rrd['filename'].':'.$ds_out.':AVERAGE ';
@@ -69,10 +66,10 @@ foreach ($rrd_list as $rrd) {
}
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."':$stack";
$rrd_options .= ' AREA:inB'.$i.'#'.$colour_in.":'".$descr."'$stack";
$rrd_options .= ' GPRINT:inB'.$i.":LAST:%6.2lf%s$units";
$rrd_options .= ' GPRINT:inB'.$i.":AVERAGE:%6.2lf%s$units";
$rrd_options .= ' GPRINT:inB'.$i.":MAX:%6.2lf%s$units\l";
@@ -82,7 +79,7 @@ foreach ($rrd_list as $rrd) {
}
$rrd_options .= " 'HRULE:0#".$colour_out.':'.$descr_out."'";
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out."::$stack'";
$rrd_optionsb .= " 'AREA:outB".$i.'_neg#'.$colour_out.":$stack'";
$rrd_options .= ' GPRINT:outB'.$i.":LAST:%6.2lf%s$units";
$rrd_options .= ' GPRINT:outB'.$i.":AVERAGE:%6.2lf%s$units";
$rrd_options .= ' GPRINT:outB'.$i.":MAX:%6.2lf%s$units\l";
@@ -117,7 +114,7 @@ if (!$nototal) {
$rrd_options .= ' VDEF:totout=outoctets,TOTAL';
$rrd_options .= ' VDEF:tot=octets,TOTAL';
// $rrd_options .= " AREA:totin#" . $colour_in . ":'" . $descr . "':$stack";
// $rrd_options .= " AREA:totin#" . $colour_in . ":'" . $descr . "'$stack";
// $rrd_options .= " GPRINT:totin:LAST:%6.2lf%s$units";
// $rrd_options .= " GPRINT:totin:AVERAGE:%6.2lf%s$units";
// $rrd_options .= " GPRINT:totin:MAX:%6.2lf%s$units\l";

View File

@@ -11,7 +11,7 @@ else {
}
if ($nototal) {
$descrlen += '2';
$descr_len += '2';
$unitlen += '2';
}

View File

@@ -71,7 +71,7 @@ foreach ($rrd_list as $rrd) {
}
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
$rrd_options .= ' AREA:inbits'.$i.'#'.$colour_in.":'".rrdtool_escape($rrd['descr'], 9)."In '$stack";
@@ -84,7 +84,7 @@ foreach ($rrd_list as $rrd) {
}
$rrd_options .= " COMMENT:'\\n'";
$rrd_optionsb .= ' AREA:outbits'.$i.'_neg#'.$colour_out.":$stack";
$rrd_optionsb .= ' AREA:outbits'.$i.'_neg#'.$colour_out."$stack";
$rrd_options .= ' HRULE:999999999999999#'.$colour_out.":'".str_pad('', 10)."Out'";
$rrd_options .= ' GPRINT:outbits'.$i.':LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:outbits'.$i.':AVERAGE:%6.2lf%s';

View File

@@ -12,7 +12,7 @@ else {
}
if ($nototal) {
$descrlen += '2';
$descr_len += '2';
$unitlen += '2';
}
@@ -32,7 +32,7 @@ else {
$unitlen = '10';
if ($nototal) {
$descrlen += '2';
$descr_len += '2';
$unitlen += '2';
}
@@ -81,7 +81,7 @@ foreach ($rrd_list as $i => $rrd) {
// This this not the first entry?
if ($i) {
$stack = 'STACK';
$stack = ':STACK';
}
// if we've been passed a multiplier we must make a CDEF based on it!
@@ -109,13 +109,13 @@ foreach ($rrd_list as $i => $rrd) {
$t_defname = $g_defname;
}
$rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.":'".$descr."':$stack";
$rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.":'".$descr."'$stack";
$rrd_options .= ' GPRINT:'.$t_defname.$i.':LAST:%5.2lf%s GPRINT:'.$t_defname.$i.'min:MIN:%5.2lf%s';
$rrd_options .= ' GPRINT:'.$t_defname.$i.'max:MAX:%5.2lf%s GPRINT:'.$t_defname.$i.":AVERAGE:'%5.2lf%s\\n'";
if (!$nototal) {
$rrd_options .= ' GPRINT:tot'.$rrd['ds'].$i.':%6.2lf%s'.rrdtool_escape($total_units).'';
$rrd_options .= ' GPRINT:tot'.$rrd['ds'].$i.":%6.2lf%s'".rrdtool_escape($total_units)."'";
}
$rrd_options .= " COMMENT:'\\n'";

View File

@@ -50,7 +50,7 @@ foreach ($dbq as $ds) {
$descr = rrdtool_escape($ds['ds_label'], $descr_len);
$cmd_graph .= ' '.$ds['ds_draw'].':'.$ds_name.'#'.$colour.':"'.$descr.'"';
$cmd_graph .= ' '.$ds['ds_draw'].':'.$ds_name.'#'.$colour.":'".$descr."'";
$cmd_graph .= ' GPRINT:'.$ds_name.':LAST:"%6.2lf%s"';
$cmd_graph .= ' GPRINT:'.$ds_name.':AVERAGE:"%6.2lf%s"';
$cmd_graph .= ' GPRINT:'.$ds_name.':MAX:"%6.2lf%s\\n"';

View File

@@ -20,7 +20,7 @@ else {
}
if ($print_total) {
$rrd_options .= ' VDEF:'.$ds.'_total=ds,TOTAL';
$rrd_options .= ' VDEF:'.$ds.'_total='.$ds.',TOTAL';
}
if ($percentile) {
@@ -43,7 +43,7 @@ if ($_GET['previous'] == 'yes') {
}
if ($print_total) {
$rrd_options .= ' VDEF:'.$ds.'_totalX=ds,TOTAL';
$rrd_options .= ' VDEF:'.$ds.'_totalX='.$ds.',TOTAL';
}
if ($percentile) {
@@ -74,11 +74,11 @@ if ($percentile) {
$rrd_options .= ' GPRINT:'.$ds.'_percentile:%6.2lf%s';
}
$rrd_options .= "\\\\n";
$rrd_options .= " COMMENT:\\\\n";
$rrd_options .= "\\n";
$rrd_options .= " COMMENT:\\n";
if ($print_total) {
$rrd_options .= ' GPRINT:'.$ds.'_tot:Total\ %6.2lf%s\)\\\\l';
$rrd_options .= ' GPRINT:'.$ds.'_total:Total" %6.2lf%s"\\l';
}
if ($percentile) {
@@ -86,6 +86,6 @@ if ($percentile) {
}
if ($_GET['previous'] == 'yes') {
$rrd_options .= ' LINE1.25:'.$ds."X#666666:'Prev \\\\n'";
$rrd_options .= ' LINE1.25:'.$ds."X#666666:'Prev \\n'";
$rrd_options .= ' AREA:'.$ds.'X#99999966:';
}

View File

@@ -5,6 +5,7 @@ $scale_max = '100';
$ds = 'usage';
// FIXME: As far as I can tell, $descr is never mentioned in includes/graphs/generic_simplex.inc.php -- PDG 2015-11-14
$descr = rrdtool_escape(short_hrDeviceDescr($proc['processor_descr']), 28);
$colour_line = 'cc0000';

View File

@@ -19,7 +19,7 @@ $rrd_options .= ' AREA:sensor_diff#c5c5c5::STACK';
$rrd_options .= " LINE1.5:sensor#cc0000:'".rrdtool_escape($sensor['sensor_descr'], 21)."'";
$rrd_options .= ' GPRINT:sensor_min:MIN:%4.1lfC';
$rrd_options .= ' GPRINT:sensor:LAST:%4.1lfC';
$rrd_options .= ' GPRINT:sensor_max:MAX:%4.1lfC\\\\l';
$rrd_options .= ' GPRINT:sensor_max:MAX:%4.1lfC\\l';
if (is_numeric($sensor['sensor_limit'])) {
$rrd_options .= ' HRULE:'.$sensor['sensor_limit'].'#999999::dashes';

View File

@@ -36,8 +36,8 @@ else {
$mac = '';
}
echo "<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" onclick=\"location.href='".generate_port_url($port)."'\" style='cursor: pointer;'>
<td valign=top width=350>";
echo "<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this.style.backgroundColor='$list_highlight';\" onmouseout=\"this.style.backgroundColor='$row_colour';\" style='cursor: pointer;'>
<td valign=top width=350 onclick=\"location.href='".generate_port_url($port)."'\">";
echo ' <span class=list-large>
'.generate_port_link($port, $port['ifIndex'].'. '.$port['label'])." $error_img $mac
</span><br /><span class=interface-desc>".$port['ifAlias'].'</span>';
@@ -62,7 +62,7 @@ if ($port_details) {
echo '</span>';
echo '</td><td width=100>';
echo "</td><td width=100 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port_details) {
$port['graph_type'] = 'port_bits';
@@ -73,7 +73,7 @@ if ($port_details) {
echo generate_port_link($port, "<img src='graph.php?type=port_errors&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)."'>");
}
echo '</td><td width=120>';
echo "</td><td width=120 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port['ifOperStatus'] == 'up') {
$port['in_rate'] = ($port['ifInOctets_rate'] * 8);
@@ -86,7 +86,7 @@ if ($port['ifOperStatus'] == 'up') {
<img src='images/icons/arrow_pps_out.png' align=absmiddle> ".format_bi($port['ifOutUcastPkts_rate']).'pps</span>';
}
echo '</td><td width=75>';
echo "</td><td width=75 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port['ifSpeed']) {
echo '<span class=box-desc>'.humanspeed($port['ifSpeed']).'</span>';
}
@@ -130,19 +130,19 @@ if ($device['os'] == 'ios' || $device['os'] == 'iosxe') {
}//end if
if ($port_adsl['adslLineCoding']) {
echo '</td><td width=150>';
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
echo $port_adsl['adslLineCoding'].'/'.rewrite_adslLineType($port_adsl['adslLineType']);
echo '<br />';
echo 'Sync:'.formatRates($port_adsl['adslAtucChanCurrTxRate']).'/'.formatRates($port_adsl['adslAturChanCurrTxRate']);
echo '<br />';
echo 'Max:'.formatRates($port_adsl['adslAtucCurrAttainableRate']).'/'.formatRates($port_adsl['adslAturCurrAttainableRate']);
echo '</td><td width=150>';
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
echo 'Atten:'.$port_adsl['adslAtucCurrAtn'].'dB/'.$port_adsl['adslAturCurrAtn'].'dB';
echo '<br />';
echo 'SNR:'.$port_adsl['adslAtucCurrSnrMgn'].'dB/'.$port_adsl['adslAturCurrSnrMgn'].'dB';
}
else {
echo '</td><td width=150>';
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port['ifType'] && $port['ifType'] != '') {
echo '<span class=box-desc>'.fixiftype($port['ifType']).'</span>';
}
@@ -158,7 +158,7 @@ else {
echo '-';
}
echo '</td><td width=150>';
echo "</td><td width=150 onclick=\"location.href='".generate_port_url($port)."'\" >";
if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != '') {
echo '<span class=box-desc>'.formatMac($port['ifPhysAddress']).'</span>';
}
@@ -176,13 +176,17 @@ else {
}//end if
echo '</td>';
echo '<td width=375 valign=top class=interface-desc>';
echo '<td width=375 valign=top class="interface-desc">';
$neighborsCount=0;
$nbLinks=0;
if (strpos($port['label'], 'oopback') === false && !$graph_type) {
foreach (dbFetchRows('SELECT * FROM `links` AS L, `ports` AS I, `devices` AS D WHERE L.local_port_id = ? AND L.remote_port_id = I.port_id AND I.device_id = D.device_id', array($if_id)) as $link) {
// echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generate_port_link($link, makeshortif($link['label'])) . " on " . generate_device_link($link, shorthost($link['hostname'])) . "</a><br />");
// $br = "<br />";
$int_links[$link['port_id']] = $link['port_id'];
$int_links_phys[$link['port_id']] = 1;
$nbLinks++;
}
unset($br);
@@ -233,10 +237,23 @@ if (strpos($port['label'], 'oopback') === false && !$graph_type) {
}//end foreach
}//end if
if(count($int_links) > 3)
{
echo '<div class="collapse-neighbors"><span class="neighbors-button glyphicon glyphicon-plus" aria-hidden="true"></span>
<span class="neighbors-interface-list-firsts" style="display: inline;">';
}
if ($port_details && $config['enable_port_relationship'] === true && port_permitted($int_link,$device['device_id'])) {
foreach ($int_links as $int_link) {
$neighborsCount++;
if($neighborsCount == 4)
{
echo '<span class="neighbors-list-continued" style="display: inline;"></br>[...]</span>';
echo '</span>';
echo '<span class="neighbors-interface-list" style="display: none;">';
}
$link_if = dbFetchRow('SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.port_id = ?', array($int_link));
echo "$br";
if ($int_links_phys[$int_link]) {
@@ -304,6 +321,10 @@ if ($port_details && $config['enable_port_relationship'] === true && port_permit
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
if($nbLinks > 3)
{
echo '</span></div>';
}
echo '</td></tr>';
// If we're showing graphs, generate the graph and print the img tags

View File

@@ -218,7 +218,7 @@ echo $edges;
var network = new vis.Network(container, data, options);
network.on('click', function (properties) {
if (properties.nodes > 0) {
window.location.href = "/device/device="+properties.nodes+"/tab=map/"
window.location.href = "device/device="+properties.nodes+"/tab=map/"
}
});
</script>

View File

@@ -74,6 +74,12 @@ if ($_SESSION['userlevel'] >= '10') {
<li><a href="<?php echo(generate_url(array('page'=>'availability-map'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg"></i> Availability</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'map'))); ?>"><i class="fa fa-desktop fa-fw fa-lg"></i> Network</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-wrench fa-fw fa-lg"></i> Tools</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="<?php echo(generate_url(array('page'=>'ripenccapi'))); ?>"><i class="fa fa-arrow-circle-up fa-fw fa-lg"></i> RIPE NCC API</a></li>
</ul>
</li>
<li role="presentation" class="divider"></li>
<li><a href="<?php echo(generate_url(array('page'=>'eventlog'))); ?>"><i class="fa fa-book fa-fw fa-lg"></i> Eventlog</a></li>

View File

@@ -29,7 +29,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (`D`.`hostname` LIKE '%$searchPhrase%' OR `E`.`datetime` LIKE '%$searchPhrase%' OR `E`.`message` LIKE '%$searchPhrase%' OR `E`.`type` LIKE '%$searchPhrase%')";
}
$count_sql = "SELECT COUNT(datetime) $sql";
$count_sql = "SELECT COUNT(event_id) $sql";
$total = dbFetchCell($count_sql, $param);
if (empty($total)) {
$total = 0;