update fail2ban to have better stat graphs and and fix generic_stats graph.php (#14818)

* update fail2ban better stat graphs

* style fix

* add rainbow color pallete

* cleanup colors and make it more easily understandable via using the new rainbow colour pallete

* a bit more color tweaking

* green is easier on the eyes

* style fix

* fix hgandling for smaller graphs for some things

* for <= height graphs, use area

* rework the area bit and add a alpha

* style cleanup

* more style cleanup

* mm... colourA does work a lot nicer if the same as colour

* add two more palletes and make the purple the default

* only include 1d once as that as some versions of rrd break if it is twice

* move time_diff to the proper location
This commit is contained in:
Zane C. Bowers-Hadley
2023-03-02 11:51:16 -06:00
committed by GitHub
parent cd7aa5e65d
commit 19278bf19f
4 changed files with 128 additions and 96 deletions

View File

@@ -1,30 +1,13 @@
<?php
require 'includes/html/graphs/common.inc.php';
$scale_min = 0;
$colours = 'mixed';
$unit_text = 'Banned IPs';
$unitlen = 10;
$bigdescrlen = 10;
$smalldescrlen = 10;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$descr = 'Banned';
$ds = 'banned';
$rrd_filename = Rrd::name($device['hostname'], ['app', $app->app_type, $app->app_id]);
$filename = Rrd::name($device['hostname'], ['app', $app->app_type, $app->app_id]);
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list = [
[
'filename' => $rrd_filename,
'descr' => 'Banned',
'ds' => 'banned',
'colour' => '582A72',
],
];
} else {
echo "file missing: $rrd_filename";
if (! Rrd::checkRrdExists($filename)) {
d_echo('RRD "' . $filename . '" not found');
}
require 'includes/html/graphs/generic_v3_multiline.inc.php';
require 'includes/html/graphs/generic_stats.inc.php';

View File

@@ -1,29 +1,13 @@
<?php
require 'includes/html/graphs/common.inc.php';
$scale_min = 0;
$colours = 'mixed';
$unit_text = ' ';
$unitlen = 10;
$bigdescrlen = 10;
$smalldescrlen = 10;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$unit_text = 'Banned IPs';
$descr = 'Banbed';
$ds = 'banned';
$rrd_filename = Rrd::name($device['hostname'], ['app', $app->app_type, $app->app_id, $vars['jail']]);
if (Rrd::checkRrdExists($rrd_filename)) {
$rrd_list = [
[
'filename' => $rrd_filename,
'descr' => 'Banned IPs',
'ds' => 'banned',
'colour' => '582A72',
],
];
} else {
echo "file missing: $rrd_filename";
$filename = Rrd::name($device['hostname'], ['app', $app->app_type, $app->app_id, $vars['jail']]);
if (! Rrd::checkRrdExists($filename)) {
d_echo('RRD "' . $filename . '" not found');
}
require 'includes/html/graphs/generic_v3_multiline.inc.php';
require 'includes/html/graphs/generic_stats.inc.php';

View File

@@ -17,6 +17,10 @@ require 'includes/html/graphs/common.inc.php';
$stacked = generate_stacked_graphs();
if (! isset($colours)) {
$colours = 'rainbow_stats_purple';
}
if (! isset($descr_len)) {
$descr_len = 12;
}
@@ -26,19 +30,26 @@ if ($nototal) {
$unitlen += '2';
}
if ($height > 99) {
$rrd_options .= " COMMENT:'" . \LibreNMS\Data\Store\Rrd::fixedSafeDescr($unit_text, $descr_len) . " Now Min Max Avg\l'";
}
$i = 0;
$iter = 0;
if (! isset($colour)) {
if (! \LibreNMS\Config::get("graph_colours.$colours.$iter")) {
$iter = 0;
}
$colour = \LibreNMS\Config::get("graph_colours.$colours.$iter");
$iter++;
}
if (! isset($colourA)) {
$colourA = $colour;
}
if (! isset($colourAalpha)) {
$colourAalpha = 33;
}
if (! isset($colour25th)) {
if (! \LibreNMS\Config::get("graph_colours.$colours.$iter")) {
$iter = 0;
@@ -53,7 +64,6 @@ if (! isset($colour50th)) {
}
$colour50th = \LibreNMS\Config::get("graph_colours.$colours.$iter");
$iter++;
$iter++;
}
if (! isset($colour75th)) {
@@ -89,31 +99,37 @@ if (! isset($colour1w)) {
}
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($descr, $descr_len);
if ($height > 25) {
$descr_1h = \LibreNMS\Data\Store\Rrd::fixedSafeDescr('1 hour avg', $descr_len);
$descr_1d = \LibreNMS\Data\Store\Rrd::fixedSafeDescr('1 day avg', $descr_len);
$descr_1w = \LibreNMS\Data\Store\Rrd::fixedSafeDescr('1 week avg', $descr_len);
}
$id = 'ds' . $i;
$rrd_options .= ' DEF:' . $id . "=$filename:$ds:AVERAGE";
$rrd_optionsb .= ' AREA:' . $id . '#' . $colourA . $colourAalpha;
$rrd_optionsb .= ' LINE1.25:' . $id . '#' . $colour . ":'$descr'";
if ($height > 25) {
$rrd_options .= ' DEF:' . $id . "1h=$filename:$ds:AVERAGE:step=3600";
$rrd_options .= ' DEF:' . $id . "1d=$filename:$ds:AVERAGE:step=86400";
$rrd_options .= ' VDEF:' . $id . '50th=' . $id . ',50,PERCENTNAN';
$rrd_options .= ' VDEF:' . $id . '25th=' . $id . ',25,PERCENTNAN';
$rrd_options .= ' VDEF:' . $id . '75th=' . $id . ',75,PERCENTNAN';
// weekly breaks and causes issues if it is less than 8 days
$time_diff = $vars['to'] - $vars['from'];
if ($time_diff >= 691200) {
$rrd_options .= ' DEF:' . $id . "1w=$filename:$ds:AVERAGE:step=604800";
}
// displays nan if less than 17 hours
$time_diff = $vars['to'] - $vars['from'];
if ($time_diff >= 61200) {
$rrd_options .= ' DEF:' . $id . "1d=$filename:$ds:AVERAGE:step=86400";
}
$rrd_optionsb .= ' LINE1.25:' . $id . '#' . $colour . ":'$descr'";
// weekly breaks and causes issues if it is less than 8 days
if ($time_diff >= 691200) {
$rrd_options .= ' DEF:' . $id . "1w=$filename:$ds:AVERAGE:step=604800";
}
$rrd_optionsb .= ' GPRINT:' . $id . ':LAST:%5.' . $float_precision . 'lf%s' . $units . ' GPRINT:' . $id . ':MIN:%5.' . $float_precision . 'lf%s' . $units;
$rrd_optionsb .= ' GPRINT:' . $id . ':MAX:%5.' . $float_precision . 'lf%s' . $units . ' GPRINT:' . $id . ":AVERAGE:'%5." . $float_precision . "lf%s$units\\n'";
@@ -141,7 +157,7 @@ $rrd_optionsb .= ' GPRINT:' . $id . '50th:%' . $float_precision . 'lf%s\n';
$rrd_optionsb .= ' HRULE:' . $id . '75th#' . $colour75th . ':75th_Percentile';
$rrd_optionsb .= ' GPRINT:' . $id . '75th:%' . $float_precision . 'lf%s\n';
}
$rrd_options .= $rrd_optionsb;
$rrd_options .= ' HRULE:0#555555';

View File

@@ -1934,6 +1934,55 @@
],
"type": "array"
},
"graph_colours.rainbow": {
"default": [
"881177",
"AA3355",
"CC6666",
"EE9944",
"EEDD00",
"99DD55",
"44DD88",
"22CCBB",
"00BBCC",
"0099CC",
"3366BB",
"663399"
],
"type": "array"
},
"graph_colours.rainbow_stats_green": {
"default": [
"99DD55",
"22CCBB",
"00BBCC",
"0099CC",
"3366BB",
"AA3355",
"881177",
"CC6666",
"EEDD00",
"44DD88",
"663399"
],
"type": "array"
},
"graph_colours.rainbow_stats_purple": {
"default": [
"663399",
"22CCBB",
"00BBCC",
"0099CC",
"3366BB",
"AA3355",
"881177",
"CC6666",
"EEDD00",
"44DD88",
"99DD55"
],
"type": "array"
},
"graph_colours.varied": {
"default": [
"CC0000",