From 0d2949f69e77c2d7457d06ddd33eb555da00a4d6 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Sun, 15 Nov 2015 11:48:39 +1000 Subject: [PATCH 01/29] Overhaul use of rrdtool_lastupdate & STACK for rrdtool 1.4/1.5 compatibility --- .../graphs/XXX_device_memory_windows.inc.php | 2 +- .../graphs/application/shoutcast_multi_stats.inc.php | 8 ++++---- html/includes/graphs/device/mempool.inc.php | 2 +- .../graphs/device/smokeping_all_common_avg.inc.php | 1 + html/includes/graphs/device/storage.inc.php | 2 +- html/includes/graphs/device/ucd_load.inc.php | 4 ++-- html/includes/graphs/device/ucd_memory.inc.php | 2 +- html/includes/graphs/generic_data.inc.php | 6 +++--- html/includes/graphs/generic_multi.inc.php | 10 +++++----- .../graphs/generic_multi_bits_separated.inc.php | 9 +++------ .../graphs/generic_multi_data_separated.inc.php | 11 ++++------- html/includes/graphs/generic_multi_line.inc.php | 2 +- html/includes/graphs/generic_multi_seperated.inc.php | 4 ++-- .../graphs/generic_multi_simplex_seperated.inc.php | 10 +++++----- html/includes/graphs/munin/graph.inc.php | 2 +- html/includes/graphs/old_generic_simplex.inc.php | 12 ++++++------ html/includes/graphs/processor/usage.inc.php | 1 + html/includes/graphs/sensor/temperature.inc.php | 2 +- includes/rrdtool.inc.php | 5 +++-- 19 files changed, 46 insertions(+), 49 deletions(-) diff --git a/html/includes/graphs/XXX_device_memory_windows.inc.php b/html/includes/graphs/XXX_device_memory_windows.inc.php index 7122762da..731250de9 100644 --- a/html/includes/graphs/XXX_device_memory_windows.inc.php +++ b/html/includes/graphs/XXX_device_memory_windows.inc.php @@ -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'; diff --git a/html/includes/graphs/application/shoutcast_multi_stats.inc.php b/html/includes/graphs/application/shoutcast_multi_stats.inc.php index ea01630bf..26b989c22 100644 --- a/html/includes/graphs/application/shoutcast_multi_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_stats.inc.php @@ -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"'; diff --git a/html/includes/graphs/device/mempool.inc.php b/html/includes/graphs/device/mempool.inc.php index 8c8fba677..d574ebcf8 100644 --- a/html/includes/graphs/device/mempool.inc.php +++ b/html/includes/graphs/device/mempool.inc.php @@ -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++; } diff --git a/html/includes/graphs/device/smokeping_all_common_avg.inc.php b/html/includes/graphs/device/smokeping_all_common_avg.inc.php index 97c5d40fb..cd8613f1b 100644 --- a/html/includes/graphs/device/smokeping_all_common_avg.inc.php +++ b/html/includes/graphs/device/smokeping_all_common_avg.inc.php @@ -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); diff --git a/html/includes/graphs/device/storage.inc.php b/html/includes/graphs/device/storage.inc.php index 769e9ce91..e52e8fa65 100644 --- a/html/includes/graphs/device/storage.inc.php +++ b/html/includes/graphs/device/storage.inc.php @@ -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 diff --git a/html/includes/graphs/device/ucd_load.inc.php b/html/includes/graphs/device/ucd_load.inc.php index ccdf61ee5..1a5e5ab9a 100644 --- a/html/includes/graphs/device/ucd_load.inc.php +++ b/html/includes/graphs/device/ucd_load.inc.php @@ -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'"; diff --git a/html/includes/graphs/device/ucd_memory.inc.php b/html/includes/graphs/device/ucd_memory.inc.php index 606fed717..05c0dd685 100644 --- a/html/includes/graphs/device/ucd_memory.inc.php +++ b/html/includes/graphs/device/ucd_memory.inc.php @@ -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'"; diff --git a/html/includes/graphs/generic_data.inc.php b/html/includes/graphs/generic_data.inc.php index 63b75fde4..46560b036 100644 --- a/html/includes/graphs/generic_data.inc.php +++ b/html/includes/graphs/generic_data.inc.php @@ -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'; diff --git a/html/includes/graphs/generic_multi.inc.php b/html/includes/graphs/generic_multi.inc.php index d02e82ebb..6d7f78a1c 100644 --- a/html/includes/graphs/generic_multi.inc.php +++ b/html/includes/graphs/generic_multi.inc.php @@ -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++; diff --git a/html/includes/graphs/generic_multi_bits_separated.inc.php b/html/includes/graphs/generic_multi_bits_separated.inc.php index 181f0ae4d..88bbdec99 100644 --- a/html/includes/graphs/generic_multi_bits_separated.inc.php +++ b/html/includes/graphs/generic_multi_bits_separated.inc.php @@ -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"; diff --git a/html/includes/graphs/generic_multi_data_separated.inc.php b/html/includes/graphs/generic_multi_data_separated.inc.php index e73ac4e85..07caefd37 100644 --- a/html/includes/graphs/generic_multi_data_separated.inc.php +++ b/html/includes/graphs/generic_multi_data_separated.inc.php @@ -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"; diff --git a/html/includes/graphs/generic_multi_line.inc.php b/html/includes/graphs/generic_multi_line.inc.php index c34d78e77..513b23674 100644 --- a/html/includes/graphs/generic_multi_line.inc.php +++ b/html/includes/graphs/generic_multi_line.inc.php @@ -11,7 +11,7 @@ else { } if ($nototal) { - $descrlen += '2'; + $descr_len += '2'; $unitlen += '2'; } diff --git a/html/includes/graphs/generic_multi_seperated.inc.php b/html/includes/graphs/generic_multi_seperated.inc.php index 8549b3b33..e45752d40 100644 --- a/html/includes/graphs/generic_multi_seperated.inc.php +++ b/html/includes/graphs/generic_multi_seperated.inc.php @@ -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'; diff --git a/html/includes/graphs/generic_multi_simplex_seperated.inc.php b/html/includes/graphs/generic_multi_simplex_seperated.inc.php index 18df802ae..6125cb807 100644 --- a/html/includes/graphs/generic_multi_simplex_seperated.inc.php +++ b/html/includes/graphs/generic_multi_simplex_seperated.inc.php @@ -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'"; diff --git a/html/includes/graphs/munin/graph.inc.php b/html/includes/graphs/munin/graph.inc.php index 9b634813b..cae85137f 100644 --- a/html/includes/graphs/munin/graph.inc.php +++ b/html/includes/graphs/munin/graph.inc.php @@ -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"'; diff --git a/html/includes/graphs/old_generic_simplex.inc.php b/html/includes/graphs/old_generic_simplex.inc.php index 24a93147c..91cd0612e 100644 --- a/html/includes/graphs/old_generic_simplex.inc.php +++ b/html/includes/graphs/old_generic_simplex.inc.php @@ -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:'; } diff --git a/html/includes/graphs/processor/usage.inc.php b/html/includes/graphs/processor/usage.inc.php index 5954685d7..53db2c490 100644 --- a/html/includes/graphs/processor/usage.inc.php +++ b/html/includes/graphs/processor/usage.inc.php @@ -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'; diff --git a/html/includes/graphs/sensor/temperature.inc.php b/html/includes/graphs/sensor/temperature.inc.php index c8ffb312d..05f7ed0ef 100644 --- a/html/includes/graphs/sensor/temperature.inc.php +++ b/html/includes/graphs/sensor/temperature.inc.php @@ -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'; diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index b71eee7a0..3c35cec22 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -280,7 +280,8 @@ function rrdtool_lastupdate($filename, $options){ function rrdtool_escape($string, $maxlength=null){ $result = shorten_interface_type($string); - $result = str_replace('%', '%%', $result); + $result = str_replace("'", '', $result); # remove quotes + $result = str_replace('%', '%%', $result); # double percent signs if (is_numeric($maxlength)) { $extra = substr_count($string, ':', 0, $maxlength); $result = substr(str_pad($result, $maxlength), 0, ($maxlength + $extra)); @@ -289,7 +290,7 @@ function rrdtool_escape($string, $maxlength=null){ } } - $result = str_replace(':', '\:', $result); + $result = str_replace(':', '\:', $result); # escape colons return $result.' '; } From 7c54782cc8244879d6cbc037980276fc5ca2f4da Mon Sep 17 00:00:00 2001 From: Falk Stern Date: Mon, 16 Nov 2015 10:24:16 +0100 Subject: [PATCH 02/29] Moved auth_ad_dont_check_certificates to auth_ad_check_certificates --- html/includes/authentication/active_directory.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/includes/authentication/active_directory.inc.php b/html/includes/authentication/active_directory.inc.php index 88504a665..a562ae901 100644 --- a/html/includes/authentication/active_directory.inc.php +++ b/html/includes/authentication/active_directory.inc.php @@ -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'); }; From dda8ffd400f2a1663830b39c238fa41831a482f9 Mon Sep 17 00:00:00 2001 From: Falk Stern Date: Mon, 16 Nov 2015 10:25:13 +0100 Subject: [PATCH 03/29] Updated Documentation for 'auth_ad_check_certificates' --- doc/Extensions/Authentication.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Extensions/Authentication.md b/doc/Extensions/Authentication.md index d7c526d36..48ad0e92f 100644 --- a/doc/Extensions/Authentication.md +++ b/doc/Extensions/Authentication.md @@ -108,7 +108,7 @@ Config option: `active_directory` This is similar to LDAP Authentication. Install __php_ldap__ for CentOS/RHEL or __php5-ldap__ for Debian/Ubuntu. -If you have issues with secure LDAP try setting `$config['auth_ad_dont_check_certificates']` to `1`. +If you have issues with secure LDAP try setting `$config['auth_ad_check_certificates']` to `0`. ##### Require actual membership of the configured groups @@ -118,7 +118,7 @@ If you set ```$config['auth_ad_require_groupmembership']``` to 1, the authentica ``` $config['auth_ad_url'] = "ldaps://your-domain.controll.er"; -$config['auth_ad_dont_check_certificates'] = 1; // or 0 +$config['auth_ad_check_certificates'] = 1; // or 0 $config['auth_ad_domain'] = "your-domain.com"; $config['auth_ad_base_dn'] = "dc=your-domain,dc=com"; $config['auth_ad_groups']['admin']['level'] = 10; From f971d7ecf351cb9425c9d19f67f8d79cc77a6338 Mon Sep 17 00:00:00 2001 From: Peter Lamperud Date: Mon, 16 Nov 2015 12:27:15 +0100 Subject: [PATCH 04/29] Signed-off-by: Peter Lamperud --- html/includes/authentication/active_directory.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/includes/authentication/active_directory.inc.php b/html/includes/authentication/active_directory.inc.php index a562ae901..e2d85907f 100644 --- a/html/includes/authentication/active_directory.inc.php +++ b/html/includes/authentication/active_directory.inc.php @@ -1,6 +1,7 @@ Date: Mon, 16 Nov 2015 13:37:12 +0100 Subject: [PATCH 05/29] Functionality added: adduser(), user_exists_in_db() --- .../authentication/active_directory.inc.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/html/includes/authentication/active_directory.inc.php b/html/includes/authentication/active_directory.inc.php index e2d85907f..d4f2ef331 100644 --- a/html/includes/authentication/active_directory.inc.php +++ b/html/includes/authentication/active_directory.inc.php @@ -1,7 +1,6 @@ $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; From 7e6ca94de40cbb7c06865052ccc3f83a14863381 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Mon, 16 Nov 2015 22:36:36 +0100 Subject: [PATCH 06/29] Add some of the supported vendors --- doc/Support/Supported Vendors.md | 109 +++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 doc/Support/Supported Vendors.md diff --git a/doc/Support/Supported Vendors.md b/doc/Support/Supported Vendors.md new file mode 100644 index 000000000..dc2c24db3 --- /dev/null +++ b/doc/Support/Supported Vendors.md @@ -0,0 +1,109 @@ +Here's a bref list of supported vendors, some might be missing. +If you are unsure of whether your device is supported or not, feel free to ask us. + +### Vendors + +3Com +Aerohive +AKCP +Alcatel-Lucent +Allied Telesis +APC +Apple +Areca +Arista +Aruba +Avaya +Avocent +Axis +Barracuda +BCM963 +BNT +Brocade +Brother +Canopy +Cisco +CiscoSB +Citrix +Cometsystem +Comware +D-Link +Datacom +Dell +Delta Power Solutions +Eaton +Engenius +Enterasys +Epson +Extreme Networks +F5 +FiberHome +Force10 +Fortigate +FreeBSD +Gamatronic +Hikvision +HP +Huawei +IBM +iPoMan +ITWatchDogs +Juniper +Konica Minolta +Kyocera +Liebert +Linux +Mellanox +Meraki +MGE +Mikrotic +MRVLD +Multimatic +NetApp +NetBSD +Netgear +NetMan +Netonix +Netopia +NetVision +NetWare +NRG +OKI +OpenBSD +PacketShaper +Palo Alto Networks +Papouch +PBN +Perle +Powercode +Prestige +Proxim +Proxmox +Radlan +Raritan +Redback +Ricoh +Riverbed +Ruckus +SAF +Siklu +Sentry3 +Solaris +SonicWALL +SpeedTouch +Supermicro +Symbol +TPLink +Tranzeo +Triplite +Ubiquiti +VMware +VRP +Vyatta +VyOS +Watchguard +WebPower +Windows +Xerox +ZTE +Zyxel From dce37d2f347fbd02daa64feb5be31a88c4f4de77 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 16 Nov 2015 21:42:40 +0000 Subject: [PATCH 07/29] Eventlog query now uses event_id as already indexed --- html/includes/table/eventlog.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/table/eventlog.inc.php b/html/includes/table/eventlog.inc.php index 797b71d77..62edbbefd 100644 --- a/html/includes/table/eventlog.inc.php +++ b/html/includes/table/eventlog.inc.php @@ -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; From 8a4b3fee1992087528ad4e1b2517df6d798ffd44 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Mon, 16 Nov 2015 22:49:12 +0100 Subject: [PATCH 08/29] Rename file. --- doc/Support/{Supported Vendors.md => Features.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/Support/{Supported Vendors.md => Features.md} (100%) diff --git a/doc/Support/Supported Vendors.md b/doc/Support/Features.md similarity index 100% rename from doc/Support/Supported Vendors.md rename to doc/Support/Features.md From e5f1914096a5a6170a2cbdb62157b28e280599da Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Tue, 17 Nov 2015 07:55:35 +1000 Subject: [PATCH 09/29] Add graph selector to devices overview Copy of selector code from html/pages/graphs.inc.php that probably has bugs --- html/pages/devices.inc.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index a7a305a72..6d446d5c1 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -62,6 +62,21 @@ foreach ($menu_options as $option => $text) {
+ + Date: Tue, 17 Nov 2015 00:20:06 +0000 Subject: [PATCH 10/29] Added support for per device unix-agent port --- html/includes/functions.inc.php | 3 +++ html/js/librenms.js | 26 ++++++++++++++++++++++++++ html/pages/device/edit/misc.inc.php | 6 ++++++ html/pages/settings/external.inc.php | 16 ++++++++++++++++ includes/polling/unix-agent.inc.php | 16 ++++++++++++---- sql-schema/076.sql | 1 + 6 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 sql-schema/076.sql diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 21121d0ce..e6c7f0cca 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1178,6 +1178,9 @@ function dynamic_override_config($type, $name, $device) { if ($type == 'checkbox') { return ''; } + elseif ($type == 'text') { + return ''; + } }//end dynamic_override_config() function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') { diff --git a/html/js/librenms.js b/html/js/librenms.js index 576362bc6..3df1fc533 100644 --- a/html/js/librenms.js +++ b/html/js/librenms.js @@ -25,6 +25,32 @@ $(document).ready(function() { }); }); + // Device override for text inputs + $(document).on('blur', 'input[name="override_config_text"]', function(event) { + event.preventDefault(); + var $this = $(this); + var attrib = $this.data('attrib'); + var device_id = $this.data('device_id'); + var value = $this.val(); + $.ajax({ + type: 'POST', + url: 'ajax_form.php', + data: { type: 'override-config', device_id: device_id, attrib: attrib, state: value }, + dataType: 'json', + success: function(data) { + if (data.status == 'ok') { + toastr.success(data.message); + } + else { + toastr.error(data.message); + } + }, + error: function() { + toastr.error('Could not set this override'); + } + }); + }); + // Checkbox config ajax calls $("[name='global-config-check']").bootstrapSwitch('offColor','danger'); $('input[name="global-config-check"]').on('switchChange.bootstrapSwitch', function(event, state) { diff --git a/html/pages/device/edit/misc.inc.php b/html/pages/device/edit/misc.inc.php index a85689852..d1731ecdf 100644 --- a/html/pages/device/edit/misc.inc.php +++ b/html/pages/device/edit/misc.inc.php @@ -14,6 +14,12 @@ echo ' '.dynamic_override_config('checkbox','override_Oxidized_disable', $device).'
+
+ +
+ '.dynamic_override_config('text','override_Unixagent_port', $device).' +
+
'; diff --git a/html/pages/settings/external.inc.php b/html/pages/settings/external.inc.php index 2960b2e25..5459ed67e 100644 --- a/html/pages/settings/external.inc.php +++ b/html/pages/settings/external.inc.php @@ -19,12 +19,28 @@ $oxidized_conf = array( ), ); +$unixagent_conf = array( + array('name' => 'unix-agent.port', + 'descr' => 'Default unix-agent port', + 'type' => 'text', + ), + array('name' => 'unix-agent.connection-timeout', + 'descr' => 'Connection timeout', + 'type' => 'text', + ), + array('name' => 'unix-agent.read-timeout', + 'descr' => 'Read timeout', + 'type' => 'text', + ), +); + echo '
'; echo generate_dynamic_config_panel('Oxidized integration',true,$config_groups,$oxidized_conf); +echo generate_dynamic_config_panel('Unix-agent integration',true,$config_groups,$unixagent_conf); echo '
diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index 18d30e58e..a10ce9333 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -3,14 +3,22 @@ if ($device['os_group'] == 'unix') { echo $config['project_name'].' UNIX Agent: '; - // FIXME - this should be in config and overridable in database - $agent_port = '6556'; + $agent_port = get_dev_attrib($device,'override_Unixagent_port'); + if (empty($agent_port)) { + $agent_port = $config['unix-agent']['port']; + } + if (empty($config['unix-agent']['connection-timeout'])) { + $config['unix-agent']['connection-timeout'] = $config['unix-agent-connection-time-out']; + } + if (empty($config['unix-agent']['read-timeout'])) { + $config['unix-agent']['read-timeout'] = $config['unix-agent-read-time-out']; + } $agent_start = utime(); - $agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent-connection-time-out']); + $agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent']['connection-timeout']); // Set stream timeout (for timeouts during agent fetch - stream_set_timeout($agent, $config['unix-agent-read-time-out']); + stream_set_timeout($agent, $config['unix-agent']['read-timeout']); $agentinfo = stream_get_meta_data($agent); if (!$agent) { diff --git a/sql-schema/076.sql b/sql-schema/076.sql new file mode 100644 index 000000000..80cb87c4a --- /dev/null +++ b/sql-schema/076.sql @@ -0,0 +1 @@ +INSERT INTO config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('unix-agent.port','6556','6556','Default port for the Unix-agent (check_mk)','external',0,'unix-agent',0,'0','0'),('unix-agent.connection-timeout','10','10','Unix-agent connection timeout','external',0,'unix-agent',0,'0','0'),('unix-agent.read-timeout','10','10','Unix-agent read timeout','external',0,'unix-agent',0,'0','0'); From f2df2d0748e585093e574188fb77f5c841d11be8 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 16 Nov 2015 17:27:47 -0800 Subject: [PATCH 11/29] Added ability to select down/up devices on worldmap --- html/includes/common/worldmap.inc.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/html/includes/common/worldmap.inc.php b/html/includes/common/worldmap.inc.php index bf9e6f36e..662785e59 100644 --- a/html/includes/common/worldmap.inc.php +++ b/html/includes/common/worldmap.inc.php @@ -30,7 +30,7 @@ if ($config['map']['engine'] == 'leaflet') {
-
+
@@ -46,7 +46,7 @@ if ($config['map']['engine'] == 'leaflet') {
-
+
+
+
+ +
+
+ +
+
@@ -101,6 +113,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 +140,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 +150,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) { From 87d273fc7d540e56e05652963e356f7b05824cee Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 16 Nov 2015 20:58:16 -0800 Subject: [PATCH 12/29] Removed / from link for installs not in / --- html/includes/print-map.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php index eb41929fe..d512a7e21 100644 --- a/html/includes/print-map.inc.php +++ b/html/includes/print-map.inc.php @@ -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/" } }); From 8660745b927f161840b1e8a83f2fe9915f8b0293 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 16 Nov 2015 21:07:50 -0800 Subject: [PATCH 13/29] Added missing fields when inserting into applications table --- html/pages/device/edit/apps.inc.php | 4 ++-- includes/polling/unix-agent.inc.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/html/pages/device/edit/apps.inc.php b/html/pages/device/edit/apps.inc.php index c885666df..fc5e50eea 100644 --- a/html/pages/device/edit/apps.inc.php +++ b/html/pages/device/edit/apps.inc.php @@ -36,7 +36,7 @@ if ($_POST['device']) { foreach ($enabled as $app) { if (!in_array($app, $app_in_db)) { - $updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app), 'applications'); + $updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app, 'app_status' => '', 'app_instance' => ''), 'applications'); } } @@ -99,4 +99,4 @@ echo '
'; echo ''; echo '
'; -echo '
'; \ No newline at end of file +echo '
'; diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index 18d30e58e..a76b89614 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -108,7 +108,7 @@ if ($device['os_group'] == 'unix') { if (in_array($key, array('apache', 'mysql', 'nginx', 'proxmox', 'ceph'))) { if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $key)) == '0') { echo "Found new application '$key'\n"; - dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key), 'applications'); + dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key, 'app_status' => '', 'app_instance' => ''), 'applications'); } } } @@ -120,7 +120,7 @@ if ($device['os_group'] == 'unix') { foreach ($agent_data['app']['memcached'] as $memcached_host => $memcached_data) { if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'memcached', $memcached_host)) == '0') { echo "Found new application 'Memcached' $memcached_host\n"; - dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_instance' => $memcached_host), 'applications'); + dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_status' => '', 'app_instance' => $memcached_host), 'applications'); } } } @@ -134,7 +134,7 @@ if ($device['os_group'] == 'unix') { $agent_data['app']['drbd'][$drbd_dev] = $drbd_data; if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'drbd', $drbd_dev)) == '0') { echo "Found new application 'DRBd' $drbd_dev\n"; - dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_instance' => $drbd_dev), 'applications'); + dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_status' => '', 'app_instance' => $drbd_dev), 'applications'); } } } From a6f34fdf7e7fe3a63b628fd9862339572dcc3d54 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 17 Nov 2015 11:11:03 +0000 Subject: [PATCH 14/29] Update Dynamic-Config.md --- doc/Developing/Dynamic-Config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Developing/Dynamic-Config.md b/doc/Developing/Dynamic-Config.md index 73e808f5c..acc9d3079 100644 --- a/doc/Developing/Dynamic-Config.md +++ b/doc/Developing/Dynamic-Config.md @@ -18,7 +18,7 @@ This will determine the default config option for `$config['alert']['tolerance_w If the sub-section you want to add the new config option already exists then update the relevant file within `html/pages/settings/` otherwise you will need to create the new sub-section page. Here's an example of this: -[Commit example](https://github.com/librenm/librenms/commit/c5998f9ee27acdac0c0f7d3092fc830c51ff684c) +[Commit example](https://github.com/librenms/librenms/commit/c5998f9ee27acdac0c0f7d3092fc830c51ff684c) ```php Date: Tue, 17 Nov 2015 12:28:28 +0100 Subject: [PATCH 15/29] Update active_directory.inc.php --- html/includes/authentication/active_directory.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/authentication/active_directory.inc.php b/html/includes/authentication/active_directory.inc.php index d4f2ef331..a1dd80f86 100644 --- a/html/includes/authentication/active_directory.inc.php +++ b/html/includes/authentication/active_directory.inc.php @@ -94,7 +94,7 @@ function adduser($username) { } function user_exists_in_db($username) { - $return = @dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true); + $return = dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true); return $return; } From f7ad46ef1c2482d16ca278f8447361513fb09bb2 Mon Sep 17 00:00:00 2001 From: vizay Date: Tue, 17 Nov 2015 12:33:17 +0100 Subject: [PATCH 16/29] Update AUTHORS.md --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 4c3d6983b..0b495e5b1 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -69,4 +69,5 @@ Contributors to LibreNMS: - Rob Gormley (rgormley) - Richard Kojedzinszky (rkojedzinszky) - Tony Murray (murrant) +- Peter Lamperud (vizay) [1]: http://observium.org/ "Observium web site" From 139e6f1aef84d7a5479bed43e063067e46982cea Mon Sep 17 00:00:00 2001 From: vizay Date: Tue, 17 Nov 2015 12:33:58 +0100 Subject: [PATCH 17/29] Update AUTHORS.md --- AUTHORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 0b495e5b1..72c735435 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -69,5 +69,5 @@ Contributors to LibreNMS: - Rob Gormley (rgormley) - Richard Kojedzinszky (rkojedzinszky) - Tony Murray (murrant) -- Peter Lamperud (vizay) +- Peter Lamperud (vizay) [1]: http://observium.org/ "Observium web site" From f9c69419f425151ce6ae8ca63eef7f050ddb1b0c Mon Sep 17 00:00:00 2001 From: vizay Date: Tue, 17 Nov 2015 12:35:36 +0100 Subject: [PATCH 18/29] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 72c735435..0b495e5b1 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -69,5 +69,5 @@ Contributors to LibreNMS: - Rob Gormley (rgormley) - Richard Kojedzinszky (rkojedzinszky) - Tony Murray (murrant) -- Peter Lamperud (vizay) +- Peter Lamperud (vizay) [1]: http://observium.org/ "Observium web site" From 1508538d8e13486f1a3cb1c91ba7b26ad5d27fdc Mon Sep 17 00:00:00 2001 From: Rosiak Date: Wed, 18 Nov 2015 19:15:23 +0100 Subject: [PATCH 19/29] Add RIPE NCC API Whois lookup Fix #2051 --- html/includes/forms/query-ripenccapi.inc.php | 30 ++++++++++++ html/includes/functions.inc.php | 6 +++ html/includes/print-menubar.php | 6 +++ html/pages/ripenccapi.inc.php | 51 ++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 html/includes/forms/query-ripenccapi.inc.php create mode 100644 html/pages/ripenccapi.inc.php diff --git a/html/includes/forms/query-ripenccapi.inc.php b/html/includes/forms/query-ripenccapi.inc.php new file mode 100644 index 000000000..dd62474f5 --- /dev/null +++ b/html/includes/forms/query-ripenccapi.inc.php @@ -0,0 +1,30 @@ + + * 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 +))); diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 21121d0ce..7d8e4d37e 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1249,3 +1249,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() + diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 09d4b57b7..e61990ea0 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -74,6 +74,12 @@ if ($_SESSION['userlevel'] >= '10') {
  • Availability
  • Network
  • + +
  • Eventlog
  • diff --git a/html/pages/ripenccapi.inc.php b/html/pages/ripenccapi.inc.php new file mode 100644 index 000000000..498467ae7 --- /dev/null +++ b/html/pages/ripenccapi.inc.php @@ -0,0 +1,51 @@ + + * 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. + */ +$pagetitle[] = 'RIPE NCC - API Tools'; +?> +

    RIPE NCC API Tools

    +
    +

    Whois

    +
    +
    + + + + +
    +
    +
    +
    +
    + From 4cb734a3d4d721a83f3fa0af2da15e228e91e96b Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Wed, 18 Nov 2015 10:41:55 -0800 Subject: [PATCH 20/29] Added support for LigoWave Infinity AP's --- includes/definitions.inc.php | 11 +++++++++ includes/discovery/mempools/infinity.inc.php | 22 +++++++++++++++++ includes/discovery/os/infinity.inc.php | 17 +++++++++++++ .../discovery/processors/infinity.inc.php | 24 +++++++++++++++++++ includes/polling/mempools/infinity.inc.php | 17 +++++++++++++ includes/polling/os/infinity.inc.php | 15 ++++++++++++ 6 files changed, 106 insertions(+) create mode 100644 includes/discovery/mempools/infinity.inc.php create mode 100644 includes/discovery/os/infinity.inc.php create mode 100644 includes/discovery/processors/infinity.inc.php create mode 100644 includes/polling/mempools/infinity.inc.php create mode 100644 includes/polling/os/infinity.inc.php diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 16873101c..16e3482e6 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -107,6 +107,17 @@ $config['os'][$os]['over'][1]['text'] = 'Processor Usage'; $config['os'][$os]['over'][2]['graph'] = 'device_ucd_memory'; $config['os'][$os]['over'][2]['text'] = 'Memory Usage'; +$os = 'infinity'; +$config['os'][$os]['text'] = 'LigoWave Infinity'; +$config['os'][$os]['type'] = 'wireless'; +$config['os'][$os]['nobulk'] = 1; +$config['os'][$os]['over'][0]['graph'] = 'device_bits'; +$config['os'][$os]['over'][0]['text'] = 'Device Traffic'; +$config['os'][$os]['over'][1]['graph'] = 'device_processor'; +$config['os'][$os]['over'][1]['text'] = 'Processor Usage'; +$config['os'][$os]['over'][2]['graph'] = 'device_mempool'; +$config['os'][$os]['over'][2]['text'] = 'Memory Usage'; + // Ubiquiti $os = 'unifi'; $config['os'][$os]['text'] = 'Ubiquiti UniFi'; diff --git a/includes/discovery/mempools/infinity.inc.php b/includes/discovery/mempools/infinity.inc.php new file mode 100644 index 000000000..a6734cb31 --- /dev/null +++ b/includes/discovery/mempools/infinity.inc.php @@ -0,0 +1,22 @@ + + * 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 ($device['os'] == 'infinity') { + echo 'INFINITY-MEMORY-POOL: '; + + $total = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.1.0', '-OvQ'); + $free = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.2.0', '-OvQ'); + + if (is_numeric($total) && is_numeric($free)) { + discover_mempool($valid_mempool, $device, 0, 'infinity', 'Memory', '1', null, null); + } +} diff --git a/includes/discovery/os/infinity.inc.php b/includes/discovery/os/infinity.inc.php new file mode 100644 index 000000000..517cdfaf3 --- /dev/null +++ b/includes/discovery/os/infinity.inc.php @@ -0,0 +1,17 @@ + + * 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 (!$os) { + if (preg_match('/^NFT 2N/', $sysDescr)) { + $os = 'infinity'; + } +} diff --git a/includes/discovery/processors/infinity.inc.php b/includes/discovery/processors/infinity.inc.php new file mode 100644 index 000000000..ee7779dd9 --- /dev/null +++ b/includes/discovery/processors/infinity.inc.php @@ -0,0 +1,24 @@ + + * 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 ($device['os'] == 'infinity') { + echo 'LigoWave Infinity: '; + + $descr = 'CPU'; + $usage = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2', '-Ovqn'); + + if (is_numeric($usage)) { + discover_processor($valid['processor'], $device, '.1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2', '0', 'infinity', $descr, '1', $usage, null, null); + } +} + +unset($processors_array); diff --git a/includes/polling/mempools/infinity.inc.php b/includes/polling/mempools/infinity.inc.php new file mode 100644 index 000000000..94e3e9dd1 --- /dev/null +++ b/includes/polling/mempools/infinity.inc.php @@ -0,0 +1,17 @@ + + * 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. + */ + +$total = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.1.0', '-OvQ'); +$free = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.2.0', '-OvQ'); +$mempool['total'] = $total * 1024; +$mempool['free'] = $free * 1024; +$mempool['used'] = ($mempool['total'] - $mempool['free']); diff --git a/includes/polling/os/infinity.inc.php b/includes/polling/os/infinity.inc.php new file mode 100644 index 000000000..ddebce091 --- /dev/null +++ b/includes/polling/os/infinity.inc.php @@ -0,0 +1,15 @@ + + * 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. + */ + +$version = snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Ovq'); +$version = explode(' ', $version)[2]; +$hardware = snmp_get($device, 'IEEE802dot11-MIB::dot11manufacturerProductName.5', '-Ovq'); From 37f5b8bcff964b66ec711739f30145b6901b2926 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 18 Nov 2015 22:01:38 +0000 Subject: [PATCH 21/29] Added detection of existing settings --- html/includes/common/worldmap.inc.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/html/includes/common/worldmap.inc.php b/html/includes/common/worldmap.inc.php index 662785e59..c179b6db2 100644 --- a/html/includes/common/worldmap.inc.php +++ b/html/includes/common/worldmap.inc.php @@ -74,10 +74,23 @@ if ($config['map']['engine'] == 'leaflet') {
    - '; + + $temp_output .= '