This patch adds two scripts which will later be used to display graphs:
-> getrrdimage.cgi: Generates PNG images for graphs. Until now, each CGI with embedded graphs had to be able to output images. These functions are now gathered in this new script. The additional parameter handling can be removed and the CGIs can be simplified. This makes it easier to use and output the graphs.
-> rrdimage.js: Interactive Javascript functions This allows the user to select time ranges without reloading the page. In addition, the graphs are now periodically updated, allowing users to live monitor the data.
Signed-off-by: Leo-Andres Hofmann hofmann@leo-andres.de --- config/cfgroot/graphs.pl | 10 +- config/rootfiles/common/web-user-interface | 2 + html/cgi-bin/getrrdimage.cgi | 245 +++++++++++++++++++++ html/html/include/rrdimage.js | 122 ++++++++++ 4 files changed, 377 insertions(+), 2 deletions(-) create mode 100644 html/cgi-bin/getrrdimage.cgi create mode 100644 html/html/include/rrdimage.js
diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index e4c3613fb..beddff032 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -29,6 +29,12 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl";
+# Graph image size in pixel +our %image_size = ('width' => 910, 'height' => 300); + +# List of all available time ranges +our @time_ranges = ("hour", "day", "week", "month", "year"); + my $ERROR;
my @GRAPH_ARGS = ( @@ -48,8 +54,8 @@ my @GRAPH_ARGS = ( "-W www.ipfire.org",
# Default size - "-w 910", - "-h 300", + "-w $image_size{'width'}", + "-h $image_size{'height'}",
# Use alternative grid "--alt-y-grid", diff --git a/config/rootfiles/common/web-user-interface b/config/rootfiles/common/web-user-interface index 540bf1e4b..23e9f3e5e 100644 --- a/config/rootfiles/common/web-user-interface +++ b/config/rootfiles/common/web-user-interface @@ -20,6 +20,7 @@ srv/web/ipfire/cgi-bin/extrahd.cgi srv/web/ipfire/cgi-bin/fireinfo.cgi srv/web/ipfire/cgi-bin/firewall.cgi srv/web/ipfire/cgi-bin/fwhosts.cgi +srv/web/ipfire/cgi-bin/getrrdimage.cgi srv/web/ipfire/cgi-bin/gpl.cgi #srv/web/ipfire/cgi-bin/guardian.cgi srv/web/ipfire/cgi-bin/gui.cgi @@ -300,6 +301,7 @@ srv/web/ipfire/html/images/view-refresh.png srv/web/ipfire/html/images/wakeup.gif srv/web/ipfire/html/images/window-new.png srv/web/ipfire/html/include +srv/web/ipfire/html/include/rrdimage.js srv/web/ipfire/html/include/zoneconf.js srv/web/ipfire/html/index.cgi srv/web/ipfire/html/redirect-templates diff --git a/html/cgi-bin/getrrdimage.cgi b/html/cgi-bin/getrrdimage.cgi new file mode 100644 index 000000000..0caefe0ac --- /dev/null +++ b/html/cgi-bin/getrrdimage.cgi @@ -0,0 +1,245 @@ +#!/usr/bin/perl +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2005-2021 IPFire Team # +# # +# 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. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +use strict; +use URI; +use GD; +use GD::Text::Wrap; +use experimental 'smartmatch'; + +# debugging +#use warnings; +#use CGI::Carp 'fatalsToBrowser'; + +require '/var/ipfire/general-functions.pl'; +require "${General::swroot}/lang.pl"; +require "${General::swroot}/header.pl"; +require "${General::swroot}/graphs.pl"; + +# List of graph origins that getrrdimage.cgi can process directly +# (unknown origins are forwarded to ensure compatibility) +my @supported_origins = ("entropy.cgi", "hardwaregraphs.cgi", "media.cgi", + "memory.cgi","netexternal.cgi", "netinternal.cgi", "netother.cgi", + "netovpnrw.cgi", "netovpnsrv.cgi", "qos.cgi", "system.cgi"); + +### Process GET parameters ### +# URL format: /?origin=[graph origin cgi]&graph=[graph name]&range=[time range] +my $uri = URI->new($ENV{'REQUEST_URI'}); +my %query = $uri->query_form; + +my $origin = lc $query{'origin'}; # lower case +my $graph = $query{'graph'}; +my $range = lc $query{'range'}; # lower case + +# Check parameters +unless(($origin =~ /^\w+?.cgi$/) && ($graph =~ /^[\w-]+?$/) && ($range ~~ @Graphs::time_ranges)) { + # Send HTTP headers + _start_png_output(); + + _print_error("URL parameters missing or malformed."); + exit; +} + +# Unsupported graph origin: Redirect request to the CGI specified in the "origin" parameter +# This enables backwards compatibility with addons that use Graphs::makegraphbox to ouput their own graphs +unless($origin ~~ @supported_origins) { + # Rewrite to old URL format: /[graph origin cgi]?[graph name]?[time range] + my $location = "https://$ENV%7B%27SERVER_NAME%27%7D:$ENV%7B%27SERVER_PORT%27%7D/cgi-bin/$%7B..."; + + # Send HTTP redirect + print "Status: 302 Found\n"; + print "Location: $location\n"; + print "Content-type: text/html; charset=UTF-8\n"; + print "\n"; # End of HTTP headers + + print "Unsupported origin, request redirected to '$location'"; + exit; +} + +### Create graphs ### +# Send HTTP headers +_start_png_output(); + +# Graphs are first grouped by their origin. +# This is because some graph categories require special parameter handling. +my $graphstatus = ''; +if($origin eq "entropy.cgi") { ## entropy.cgi + $graphstatus = Graphs::updateentropygraph($range); +# ------ + +} elsif($origin eq "hardwaregraphs.cgi") { ## hardwaregraphs.cgi + if($graph eq "hwtemp") { + $graphstatus = Graphs::updatehwtempgraph($range); + } elsif($graph eq "hwfan") { + $graphstatus = Graphs::updatehwfangraph($range); + } elsif($graph eq "hwvolt") { + $graphstatus = Graphs::updatehwvoltgraph($range); + } elsif($graph eq "thermaltemp") { + $graphstatus = Graphs::updatethermaltempgraph($range); + } elsif($graph =~ "sd?") { + $graphstatus = Graphs::updatehddgraph($graph, $range); + } elsif($graph =~ "nvme?") { + $graphstatus = Graphs::updatehddgraph($graph, $range); + } else { + $graphstatus = "Unknown graph name."; + } +# ------ + +} elsif($origin eq "media.cgi") { ## media.cgi + if ($graph =~ "sd?" || $graph =~ "mmcblk?" || $graph =~ "nvme?n?" || $graph =~ "xvd??" || $graph =~ "vd?" || $graph =~ "md*" ) { + $graphstatus = Graphs::updatediskgraph($graph, $range); + } else { + $graphstatus = "Unknown graph name."; + } +# ------ + +} elsif($origin eq "memory.cgi") { ## memory.cgi + if($graph eq "memory") { + $graphstatus = Graphs::updatememorygraph($range); + } elsif($graph eq "swap") { + $graphstatus = Graphs::updateswapgraph($range); + } else { + $graphstatus = "Unknown graph name."; + } +# ------ + +} elsif($origin eq "netexternal.cgi") { ## netexternal.cgi + $graphstatus = Graphs::updateifgraph($graph, $range); +# ------ + +} elsif($origin eq "netinternal.cgi") { ## netinternal.cgi + if ($graph =~ /wireless/){ + $graph =~ s/wireless//g; + $graphstatus = Graphs::updatewirelessgraph($graph, $range); + } else { + $graphstatus = Graphs::updateifgraph($graph, $range); + } +# ------ + +} elsif($origin eq "netother.cgi") { ## netother.cgi + if($graph eq "conntrack") { + $graphstatus = Graphs::updateconntrackgraph($range); + } elsif($graph eq "fwhits") { + $graphstatus = Graphs::updatefwhitsgraph($range); + } else { + $graphstatus = Graphs::updatepinggraph($graph, $range); + } +# ------ + +} elsif($origin eq "netovpnrw.cgi") { ## netovpnrw.cgi + if($graph ne "UNDEF") { + $graphstatus = Graphs::updatevpngraph($graph, $range); + } else { + $graphstatus = "Unknown graph name."; + } +# ------ + +} elsif($origin eq "netovpnsrv.cgi") { ## netovpnsrv.cgi + if ($graph =~ /ipsec-/){ + $graph =~ s/ipsec-//g; + $graphstatus = Graphs::updateifgraph($graph, $range); + } else { + $graphstatus = Graphs::updatevpnn2ngraph($graph, $range); + } +# ------ + +} elsif($origin eq "qos.cgi") { ## qos.cgi + $graphstatus = Graphs::updateqosgraph($graph, $range); +# ------ + +} elsif($origin eq "services.cgi") { ## services.cgi + if($graph eq "processescpu") { + $graphstatus = Graphs::updateprocessescpugraph($range); + } elsif($graph eq "processesmemory") { + $graphstatus = Graphs::updateprocessesmemorygraph($range); + } else { + $graphstatus = "Unknown graph name."; + } +# ------ + +} elsif($origin eq "system.cgi") { ## system.cgi + if($graph eq "cpu") { + $graphstatus = Graphs::updatecpugraph($range); + } elsif($graph eq "cpufreq") { + $graphstatus = Graphs::updatecpufreqgraph($range); + } elsif($graph eq "load") { + $graphstatus = Graphs::updateloadgraph($range); + } else { + $graphstatus = "Unknown graph name."; + } +# ------ + +} else { + $graphstatus = "Unknown graph origin."; +} + +### Print error message ### +# Add request parameters for debugging +if($graphstatus) { + $graphstatus = "$graphstatus\n($origin, $graph, $range)"; + _print_error($graphstatus); +} + +###--- Internal functions ---### + +# Send HTTP headers and switch to binary output +# (don't print any non-image data to STDOUT afterwards) +sub _start_png_output { + print "Cache-Control: no-cache, no-store\n"; + print "Content-Type: image/png\n"; + print "\n"; # End of HTTP headers + binmode(STDOUT); +} + +# Print error message to PNG output +sub _print_error { + my ($message) = @_; + $message = "- Error -\n \n$message"; + + # Create new image with the same size as a graph + my $img = GD::Image->new($Graphs::image_size{'width'}, $Graphs::image_size{'height'}); + $img->interlaced('true'); + + # Basic colors + my $color_background = $img->colorAllocate(255, 255, 255); + my $color_border = $img->colorAllocate(255, 0, 0); + my $color_text = $img->colorAllocate(0, 0, 0); + + # Background and border + $img->setThickness(2); + $img->filledRectangle(0, 0, $img->width, $img->height, $color_background); + $img->rectangle(10, 10, $img->width - 10, $img->height - 10, $color_border); + + # Draw message with line-wrap + my $textbox = GD::Text::Wrap->new($img, + text => $message, + width => ($img->width - 50), + color => $color_text, + align => 'center', + line_space => 5, + preserve_nl => 1 + ); + $textbox->set_font(gdLargeFont); + $textbox->draw(25, 25); + + # Get PNG output + print $img->png; +} diff --git a/html/html/include/rrdimage.js b/html/html/include/rrdimage.js new file mode 100644 index 000000000..e7ee4c769 --- /dev/null +++ b/html/html/include/rrdimage.js @@ -0,0 +1,122 @@ +/*############################################################################# +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2021 IPFire Team info@ipfire.org # +# # +# 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. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +#############################################################################*/ + +// "onclick" event handler for graph time range select button +// buttonObj: reference to the button +function rrdimage_selectRange(buttonObj) { + if(! (buttonObj && ('range' in buttonObj.dataset))) { + return; //required parameters are missing + } + + // Get selected time range from button + const range = buttonObj.dataset.range; + + // Get surrounding div box and select new range + let graphBox = $(buttonObj).closest('div'); + _rrdimg_setRange(graphBox, range); +} + +// Document loaded: Process all graphs, start reload timers +$(function() { + $('div.rrdimage').each(function() { + let graphBox = $(this); + _rrdimg_setRange(graphBox, graphBox.data('defaultRange'), true); + }); +}); + +//--- Internal functions --- + +// Set or update graph time range, start automatic reloading +// graphBox: jQuery object, reference to graph div box +// range: time range (day, hour, ...) +// initMode: don't immediately reload graph, but force timers and attributes update +function _rrdimg_setRange(graphBox, range, initMode = false) { + if(! ((graphBox instanceof jQuery) && (graphBox.length === 1))) { + return; //graphBox element missing + } + + // Check range parameter, default to "day" on error + if(! ["hour", "day", "week", "month", "year"].includes(range)) { + range = "day"; + } + + // Check if the time range is changed + if((graphBox.data('range') !== range) || initMode) { + graphBox.data('range', range); //Store new range + + // Update button highlighting + graphBox.find('button').removeClass('selected'); + graphBox.find(`button[data-range="${range}"]`).addClass('selected'); + } + + // Clear pending reload timer to prevent multiple image reloads + let timerId = graphBox.data('reloadTimer'); + if(timerId !== undefined) { + window.clearInterval(timerId); + graphBox.removeData('reloadTimer'); + } + + // Determine auto reload interval (in seconds), + // interval = 0 disables auto reloading by default + let interval = 0; + switch(range) { + case 'hour': + interval = 60; + break; + + case 'day': + case 'week': + interval = 300; + break; + } + + // Start reload timer and store reference + if(interval > 0) { + timerId = window.setInterval(function(graphRef) { + _rrdimg_reload(graphRef); + }, interval * 1000, graphBox); + graphBox.data('reloadTimer', timerId); + } + + // Always reload image unless disabled by init mode + if(! initMode) { + _rrdimg_reload(graphBox); + } +} + +// Reload graph image, add timestamp to prevent caching +// graphBox: jQuery object (graph element must be valid) +function _rrdimg_reload(graphBox) { + const origin = graphBox.data('origin'); + const graph = graphBox.data('graph'); + const timestamp = Date.now(); + + // Get user selected range or fall back to default + let range = graphBox.data('range'); + if(! range) { + range = graphBox.data('defaultRange'); + } + + // Generate new image URL with timestamp + const imageUrl = `/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${graph}&range=${range}×tamp=${timestamp}`; + + // Get graph image and set new URL + graphBox.children('img').first().attr('src', imageUrl); +}
This patch adds styling for the new graph time range buttons and loads the Javascript in the HTML head.
Signed-off-by: Leo-Andres Hofmann hofmann@leo-andres.de --- html/html/themes/ipfire/include/css/style.css | 37 +++++++++++++++++-- html/html/themes/ipfire/include/functions.pl | 1 + 2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/html/html/themes/ipfire/include/css/style.css b/html/html/themes/ipfire/include/css/style.css index 9421fc111..10644a9f8 100644 --- a/html/html/themes/ipfire/include/css/style.css +++ b/html/html/themes/ipfire/include/css/style.css @@ -328,7 +328,38 @@ table.fw-nat tbody tr td { height: 2.25em; }
-iframe.graph { - width: 100%; - min-height: 300px; +/* RRD graph images */ + +div.rrdimage > ul { + list-style-type: none; + margin: 0; + display: flex; + justify-content: center; +} +.rrdimage li:not(:first-child)::before { + content: "-"; + padding: 0 0.3em; +} + +.rrdimage button { + padding: 0.3em; + font-weight: 700; + color: #d90000; /* link color */ + border: none; + background: none; + cursor: pointer; + text-decoration: underline; +} +.rrdimage button:focus { + outline: none; + box-shadow: none; +} +.rrdimage button.selected { + background-color: rgba(135, 203, 0, 0.2); +} + +div.rrdimage > img { + box-sizing: border-box; + max-width: 100%; + min-height: 290px; } diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/themes/ipfire/include/functions.pl index 9aec77497..c76af336d 100644 --- a/html/html/themes/ipfire/include/functions.pl +++ b/html/html/themes/ipfire/include/functions.pl @@ -128,6 +128,7 @@ print <<END; <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="shortcut icon" href="/favicon.ico" /> <script type="text/javascript" src="/include/jquery.js"></script> + <script src="/include/rrdimage.js"></script>
<script type="text/javascript"> function swapVisibility(id) {
"makegraphbox" is modified to remove the old iframe method and output a modern div container instead. Graph errors are now returned, to be displayed by getrrdimage.cgi.
entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility.
Add cache control HTTP header to image output.
Signed-off-by: Leo-Andres Hofmann hofmann@leo-andres.de --- config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- html/cgi-bin/entropy.cgi | 2 +- html/cgi-bin/netovpnsrv.cgi | 2 +- 3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index beddff032..cf4a30de3 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -24,6 +24,7 @@ package Graphs;
use strict; use RRDs; +use experimental 'smartmatch';
require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -99,26 +100,35 @@ foreach (@sensorsdir){ &General::readhash("${General::swroot}/sensors/settings", %sensorsettings);
# Generate a nice box for selection of time range in graphs -# this will generate a nice iframe for the cgi every klick for -# the graph will be handled inside the iframe +# this will generate a nice div box for the cgi every klick for +# the graph will be handled by javascript # 0 is the cgi refering to # 1 is the graph name -# 2 is the time range for the graph -# 3 if given is the height of the iframe default if nothing is given +# 2 is the time range for the graph (optional)
sub makegraphbox { - print "<center>"; - print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; - print " - "; - print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; - print " - "; - print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; - print " - "; - print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; - print " - "; - print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; - print "<br></center>"; - print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; + my ($origin, $name, $default_range) = @_; + + # Optional time range: Default to "day" unless otherwise specified + $default_range = "day" unless ($default_range ~~ @time_ranges); + + print <<END; +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> + <ul> +END + + # Print range select buttons + foreach my $range (@time_ranges) { + print <<END; + <li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> +END + } + + print <<END; + </ul> + <img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> +</div> +END }
# Generate the CPU Graph for the current period of time for values given by @@ -248,7 +258,7 @@ sub updatecpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; - print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; }
# Generate the Load Graph for the current period of time for values given by collecd @@ -280,7 +290,7 @@ sub updateloadgraph { "LINE1:load1".$color{"color18"}, ); $ERROR = RRDs::error; - print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; }
# Generate the Memory Graph for the current period of time for values given by collecd @@ -336,7 +346,7 @@ sub updatememorygraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Swap Graph for the current period of time for values given by collecd @@ -385,7 +395,7 @@ sub updateswapgraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Process Cpu Graph for the current period of time for values given by collecd @@ -432,7 +442,7 @@ sub updateprocessescpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; - print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; }
# Generate the Process Memory Graph for the current period of time for values given by collecd @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph {
RRDs::graph (@command); $ERROR = RRDs::error; - print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; }
# Generate the Disk Graph for the current period of time for values given by collecd @@ -522,7 +532,7 @@ sub updatediskgraph { "GPRINT:write:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Interface Graph for the current period of time for values given by collecd @@ -561,7 +571,7 @@ sub updateifgraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpngraph { @@ -598,7 +608,7 @@ sub updatevpngraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpnn2ngraph { @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { "GPRINT:compression_out:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
# Generate the Firewall Graph for the current period of time for values given by collecd @@ -716,7 +726,7 @@ sub updatefwhitsgraph { "GPRINT:portscan:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; }
# Generate the Line Quality Graph for the current period of time for values given by collecd @@ -758,7 +768,7 @@ sub updatepinggraph { "GPRINT:roundtrip:LAST:%3.2lf ms\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; }
sub updatewirelessgraph { @@ -793,7 +803,7 @@ sub updatewirelessgraph { "GPRINT:power:LAST:%5.1lf %sdBm\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; }
# Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -827,7 +837,7 @@ sub updatehddgraph { "GPRINT:temperature:LAST:%3.0lf °C\j", ); $ERROR = RRDs::error; - print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -875,7 +885,7 @@ sub updatehwtempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; - print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; }
# Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors @@ -922,7 +932,7 @@ sub updatehwfangraph {
RRDs::graph (@command); $ERROR = RRDs::error; - print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; }
# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors @@ -969,7 +979,7 @@ sub updatehwvoltgraph {
RRDs::graph (@command); $ERROR = RRDs::error; - print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; }
@@ -1051,7 +1061,7 @@ sub updateqosgraph { } RRDs::graph (@command); $ERROR = RRDs::error; - print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; }
# Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph {
RRDs::graph (@command); $ERROR = RRDs::error; - print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; }
# Generate the Thermal Zone Temp CPU Graph @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; - print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; }
@@ -1174,7 +1184,7 @@ sub updateentropygraph { RRDs::graph (@command); $ERROR = RRDs::error;
- print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; + return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; }
sub updateconntrackgraph { @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { RRDs::graph(@command); $ERROR = RRDs::error;
- print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; + return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; } diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi index d7a9ca5d8..f8045db5a 100644 --- a/html/cgi-bin/entropy.cgi +++ b/html/cgi-bin/entropy.cgi @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { &Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'center', $Lang::tr{'entropy'}); - &Graphs::makegraphbox("entropy.cgi", "day"); + &Graphs::makegraphbox("entropy.cgi", "entropy", "day"); &Header::closebox();
# Check for hardware support. diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi index 77c69cddb..ab3548713 100755 --- a/html/cgi-bin/netovpnsrv.cgi +++ b/html/cgi-bin/netovpnsrv.cgi @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ if (@vpns || %ipsecgraphs) { foreach my $name (sort keys %ipsecgraphs) { &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); - &Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); + &Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); &Header::closebox(); }
Hello,
Is this meant to look like this?
On 1 Apr 2021, at 14:35, Leo-Andres Hofmann hofmann@leo-andres.de wrote:
"makegraphbox" is modified to remove the old iframe method and output a modern div container instead. Graph errors are now returned, to be displayed by getrrdimage.cgi.
entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility.
Add cache control HTTP header to image output.
Signed-off-by: Leo-Andres Hofmann hofmann@leo-andres.de
config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- html/cgi-bin/entropy.cgi | 2 +- html/cgi-bin/netovpnsrv.cgi | 2 +- 3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index beddff032..cf4a30de3 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -24,6 +24,7 @@ package Graphs;
use strict; use RRDs; +use experimental 'smartmatch';
require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -99,26 +100,35 @@ foreach (@sensorsdir){ &General::readhash("${General::swroot}/sensors/settings", %sensorsettings);
# Generate a nice box for selection of time range in graphs -# this will generate a nice iframe for the cgi every klick for -# the graph will be handled inside the iframe +# this will generate a nice div box for the cgi every klick for +# the graph will be handled by javascript # 0 is the cgi refering to # 1 is the graph name -# 2 is the time range for the graph -# 3 if given is the height of the iframe default if nothing is given +# 2 is the time range for the graph (optional)
sub makegraphbox {
- print "<center>";
- print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>";
- print " - ";
- print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>";
- print " - ";
- print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>";
- print " - ";
- print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>";
- print " - ";
- print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>";
- print "<br></center>";
- print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>";
- my ($origin, $name, $default_range) = @_;
- # Optional time range: Default to "day" unless otherwise specified
- $default_range = "day" unless ($default_range ~~ @time_ranges);
- print <<END;
+<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range">
<ul>
+END
- # Print range select buttons
- foreach my $range (@time_ranges) {
print <<END;
<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li>
+END
- }
- print <<END;
</ul>
<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)">
+</div> +END }
# Generate the CPU Graph for the current period of time for values given by @@ -248,7 +258,7 @@ sub updatecpugraph {
RRDs::graph (@command); $ERROR = RRDs::error;
- print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR;
- return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR;
}
# Generate the Load Graph for the current period of time for values given by collecd @@ -280,7 +290,7 @@ sub updateloadgraph { "LINE1:load1".$color{"color18"}, ); $ERROR = RRDs::error;
print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR;
}
# Generate the Memory Graph for the current period of time for values given by collecd @@ -336,7 +346,7 @@ sub updatememorygraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
}
# Generate the Swap Graph for the current period of time for values given by collecd @@ -385,7 +395,7 @@ sub updateswapgraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR;
}
# Generate the Process Cpu Graph for the current period of time for values given by collecd @@ -432,7 +442,7 @@ sub updateprocessescpugraph {
RRDs::graph (@command); $ERROR = RRDs::error;
print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR;
}
# Generate the Process Memory Graph for the current period of time for values given by collecd @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph {
RRDs::graph (@command); $ERROR = RRDs::error;
print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR;
}
# Generate the Disk Graph for the current period of time for values given by collecd @@ -522,7 +532,7 @@ sub updatediskgraph { "GPRINT:write:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR;
}
# Generate the Interface Graph for the current period of time for values given by collecd @@ -561,7 +571,7 @@ sub updateifgraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
}
sub updatevpngraph { @@ -598,7 +608,7 @@ sub updatevpngraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
}
sub updatevpnn2ngraph { @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { "GPRINT:compression_out:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR;
}
# Generate the Firewall Graph for the current period of time for values given by collecd @@ -716,7 +726,7 @@ sub updatefwhitsgraph { "GPRINT:portscan:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR;
}
# Generate the Line Quality Graph for the current period of time for values given by collecd @@ -758,7 +768,7 @@ sub updatepinggraph { "GPRINT:roundtrip:LAST:%3.2lf ms\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR;
}
sub updatewirelessgraph { @@ -793,7 +803,7 @@ sub updatewirelessgraph { "GPRINT:power:LAST:%5.1lf %sdBm\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR;
}
# Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -827,7 +837,7 @@ sub updatehddgraph { "GPRINT:temperature:LAST:%3.0lf °C\j", ); $ERROR = RRDs::error;
print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR;
}
# Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -875,7 +885,7 @@ sub updatehwtempgraph {
RRDs::graph (@command); $ERROR = RRDs::error;
print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR;
}
# Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors @@ -922,7 +932,7 @@ sub updatehwfangraph {
RRDs::graph (@command); $ERROR = RRDs::error;
print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR;
}
# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors @@ -969,7 +979,7 @@ sub updatehwvoltgraph {
RRDs::graph (@command); $ERROR = RRDs::error;
print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR;
}
@@ -1051,7 +1061,7 @@ sub updateqosgraph { } RRDs::graph (@command); $ERROR = RRDs::error;
print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR;
return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR;
}
# Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph {
RRDs::graph (@command); $ERROR = RRDs::error;
- print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR;
- return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR;
}
# Generate the Thermal Zone Temp CPU Graph @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph {
RRDs::graph (@command); $ERROR = RRDs::error;
- print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR;
- return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR;
}
@@ -1174,7 +1184,7 @@ sub updateentropygraph { RRDs::graph (@command); $ERROR = RRDs::error;
- print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR;
- return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR;
}
sub updateconntrackgraph { @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { RRDs::graph(@command); $ERROR = RRDs::error;
- print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR;
- return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR;
} diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi index d7a9ca5d8..f8045db5a 100644 --- a/html/cgi-bin/entropy.cgi +++ b/html/cgi-bin/entropy.cgi @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { &Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'center', $Lang::tr{'entropy'});
- &Graphs::makegraphbox("entropy.cgi", "day");
&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); &Header::closebox();
# Check for hardware support.
diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi index 77c69cddb..ab3548713 100755 --- a/html/cgi-bin/netovpnsrv.cgi +++ b/html/cgi-bin/netovpnsrv.cgi @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ if (@vpns || %ipsecgraphs) { foreach my $name (sort keys %ipsecgraphs) { &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name");
&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day");
}&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); &Header::closebox();
-- 2.27.0.windows.1
Hello Michael,
No, of course not, that looks terrible! Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome.
Best regards, Leo
Am 07.04.2021 um 23:31 schrieb Michael Tremer:
Hello,
Is this meant to look like this?
On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote:
"makegraphbox" is modified to remove the old iframe method and output a modern div container instead. Graph errors are now returned, to be displayed by getrrdimage.cgi.
entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility.
Add cache control HTTP header to image output.
Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de>
config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- html/cgi-bin/entropy.cgi | 2 +- html/cgi-bin/netovpnsrv.cgi | 2 +- 3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index beddff032..cf4a30de3 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -24,6 +24,7 @@ package Graphs;
use strict; use RRDs; +use experimental 'smartmatch';
require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -99,26 +100,35 @@ foreach (@sensorsdir){ &General::readhash("${General::swroot}/sensors/settings", %sensorsettings);
# Generate a nice box for selection of time range in graphs -# this will generate a nice iframe for the cgi every klick for -# the graph will be handled inside the iframe +# this will generate a nice div box for the cgi every klick for +# the graph will be handled by javascript # 0 is the cgi refering to # 1 is the graph name -# 2 is the time range for the graph -# 3 if given is the height of the iframe default if nothing is given +# 2 is the time range for the graph (optional)
sub makegraphbox { -print "<center>"; -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; -print "<br></center>"; -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; +my ($origin, $name, $default_range) = @_;
+# Optional time range: Default to "day" unless otherwise specified +$default_range = "day" unless ($default_range ~~ @time_ranges);
+print <<END; +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> +<ul> +END
+# Print range select buttons +foreach my $range (@time_ranges) { +print <<END; +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> +END +}
+print <<END; +</ul> +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> +</div> +END }
# Generate the CPU Graph for the current period of time for values given by @@ -248,7 +258,7 @@ sub updatecpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; }
# Generate the Load Graph for the current period of time for values given by collecd @@ -280,7 +290,7 @@ sub updateloadgraph { "LINE1:load1".$color{"color18"}, ); $ERROR = RRDs::error; -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; }
# Generate the Memory Graph for the current period of time for values given by collecd @@ -336,7 +346,7 @@ sub updatememorygraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Swap Graph for the current period of time for values given by collecd @@ -385,7 +395,7 @@ sub updateswapgraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Process Cpu Graph for the current period of time for values given by collecd @@ -432,7 +442,7 @@ sub updateprocessescpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; }
# Generate the Process Memory Graph for the current period of time for values given by collecd @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; }
# Generate the Disk Graph for the current period of time for values given by collecd @@ -522,7 +532,7 @@ sub updatediskgraph { "GPRINT:write:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Interface Graph for the current period of time for values given by collecd @@ -561,7 +571,7 @@ sub updateifgraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpngraph { @@ -598,7 +608,7 @@ sub updatevpngraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpnn2ngraph { @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { "GPRINT:compression_out:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
# Generate the Firewall Graph for the current period of time for values given by collecd @@ -716,7 +726,7 @@ sub updatefwhitsgraph { "GPRINT:portscan:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; }
# Generate the Line Quality Graph for the current period of time for values given by collecd @@ -758,7 +768,7 @@ sub updatepinggraph { "GPRINT:roundtrip:LAST:%3.2lf ms\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; }
sub updatewirelessgraph { @@ -793,7 +803,7 @@ sub updatewirelessgraph { "GPRINT:power:LAST:%5.1lf %sdBm\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; }
# Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -827,7 +837,7 @@ sub updatehddgraph { "GPRINT:temperature:LAST:%3.0lf °C\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -875,7 +885,7 @@ sub updatehwtempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; }
# Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors @@ -922,7 +932,7 @@ sub updatehwfangraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; }
# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors @@ -969,7 +979,7 @@ sub updatehwvoltgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; }
@@ -1051,7 +1061,7 @@ sub updateqosgraph { } RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; }
# Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; }
# Generate the Thermal Zone Temp CPU Graph @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; }
@@ -1174,7 +1184,7 @@ sub updateentropygraph { RRDs::graph (@command); $ERROR = RRDs::error;
-print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; }
sub updateconntrackgraph { @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { RRDs::graph(@command); $ERROR = RRDs::error;
-print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; } diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi index d7a9ca5d8..f8045db5a 100644 --- a/html/cgi-bin/entropy.cgi +++ b/html/cgi-bin/entropy.cgi @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { &Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'center', $Lang::tr{'entropy'}); -&Graphs::makegraphbox("entropy.cgi", "day"); +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); &Header::closebox();
# Check for hardware support. diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi index 77c69cddb..ab3548713 100755 --- a/html/cgi-bin/netovpnsrv.cgi +++ b/html/cgi-bin/netovpnsrv.cgi @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ if (@vpns || %ipsecgraphs) { foreach my $name (sort keys %ipsecgraphs) { &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); &Header::closebox(); }
-- 2.27.0.windows.1
Hello,
That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into.
Apart from that it works.
Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough?
-Michael
On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote:
Hello Michael,
No, of course not, that looks terrible! Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome.
Best regards, Leo
Am 07.04.2021 um 23:31 schrieb Michael Tremer:
Hello,
Is this meant to look like this?
On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote:
"makegraphbox" is modified to remove the old iframe method and output a modern div container instead. Graph errors are now returned, to be displayed by getrrdimage.cgi.
entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility.
Add cache control HTTP header to image output.
Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de>
config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- html/cgi-bin/entropy.cgi | 2 +- html/cgi-bin/netovpnsrv.cgi | 2 +- 3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index beddff032..cf4a30de3 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -24,6 +24,7 @@ package Graphs;
use strict; use RRDs; +use experimental 'smartmatch';
require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -99,26 +100,35 @@ foreach (@sensorsdir){ &General::readhash("${General::swroot}/sensors/settings", %sensorsettings);
# Generate a nice box for selection of time range in graphs -# this will generate a nice iframe for the cgi every klick for -# the graph will be handled inside the iframe +# this will generate a nice div box for the cgi every klick for +# the graph will be handled by javascript # 0 is the cgi refering to # 1 is the graph name -# 2 is the time range for the graph -# 3 if given is the height of the iframe default if nothing is given +# 2 is the time range for the graph (optional)
sub makegraphbox { -print "<center>"; -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; -print "<br></center>"; -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; +my ($origin, $name, $default_range) = @_;
+# Optional time range: Default to "day" unless otherwise specified +$default_range = "day" unless ($default_range ~~ @time_ranges);
+print <<END; +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> +<ul> +END
+# Print range select buttons +foreach my $range (@time_ranges) { +print <<END; +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> +END +}
+print <<END; +</ul> +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> +</div> +END }
# Generate the CPU Graph for the current period of time for values given by @@ -248,7 +258,7 @@ sub updatecpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; }
# Generate the Load Graph for the current period of time for values given by collecd @@ -280,7 +290,7 @@ sub updateloadgraph { "LINE1:load1".$color{"color18"}, ); $ERROR = RRDs::error; -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; }
# Generate the Memory Graph for the current period of time for values given by collecd @@ -336,7 +346,7 @@ sub updatememorygraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Swap Graph for the current period of time for values given by collecd @@ -385,7 +395,7 @@ sub updateswapgraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Process Cpu Graph for the current period of time for values given by collecd @@ -432,7 +442,7 @@ sub updateprocessescpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; }
# Generate the Process Memory Graph for the current period of time for values given by collecd @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; }
# Generate the Disk Graph for the current period of time for values given by collecd @@ -522,7 +532,7 @@ sub updatediskgraph { "GPRINT:write:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Interface Graph for the current period of time for values given by collecd @@ -561,7 +571,7 @@ sub updateifgraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpngraph { @@ -598,7 +608,7 @@ sub updatevpngraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpnn2ngraph { @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { "GPRINT:compression_out:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
# Generate the Firewall Graph for the current period of time for values given by collecd @@ -716,7 +726,7 @@ sub updatefwhitsgraph { "GPRINT:portscan:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; }
# Generate the Line Quality Graph for the current period of time for values given by collecd @@ -758,7 +768,7 @@ sub updatepinggraph { "GPRINT:roundtrip:LAST:%3.2lf ms\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; }
sub updatewirelessgraph { @@ -793,7 +803,7 @@ sub updatewirelessgraph { "GPRINT:power:LAST:%5.1lf %sdBm\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; }
# Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -827,7 +837,7 @@ sub updatehddgraph { "GPRINT:temperature:LAST:%3.0lf °C\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -875,7 +885,7 @@ sub updatehwtempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; }
# Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors @@ -922,7 +932,7 @@ sub updatehwfangraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; }
# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors @@ -969,7 +979,7 @@ sub updatehwvoltgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; }
@@ -1051,7 +1061,7 @@ sub updateqosgraph { } RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; }
# Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; }
# Generate the Thermal Zone Temp CPU Graph @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; }
@@ -1174,7 +1184,7 @@ sub updateentropygraph { RRDs::graph (@command); $ERROR = RRDs::error;
-print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; }
sub updateconntrackgraph { @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { RRDs::graph(@command); $ERROR = RRDs::error;
-print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; } diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi index d7a9ca5d8..f8045db5a 100644 --- a/html/cgi-bin/entropy.cgi +++ b/html/cgi-bin/entropy.cgi @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { &Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'center', $Lang::tr{'entropy'}); -&Graphs::makegraphbox("entropy.cgi", "day"); +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); &Header::closebox();
# Check for hardware support. diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi index 77c69cddb..ab3548713 100755 --- a/html/cgi-bin/netovpnsrv.cgi +++ b/html/cgi-bin/netovpnsrv.cgi @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ if (@vpns || %ipsecgraphs) { foreach my $name (sort keys %ipsecgraphs) { &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); &Header::closebox(); }
-- 2.27.0.windows.1
<rrdimg-css.png>
Hi,
I found that disabling the HTTP ETag header solved the problem for me. Are there any Cache-Control headers configured for these static files?
I'll change the CSS and submit a patch soon!
Leo
Am 09.04.2021 um 12:57 schrieb Michael Tremer:
Hello,
That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into.
Apart from that it works.
Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough?
-Michael
On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote:
Hello Michael,
No, of course not, that looks terrible! Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome.
Best regards, Leo
Am 07.04.2021 um 23:31 schrieb Michael Tremer:
Hello,
Is this meant to look like this?
On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote:
"makegraphbox" is modified to remove the old iframe method and output a modern div container instead. Graph errors are now returned, to be displayed by getrrdimage.cgi.
entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility.
Add cache control HTTP header to image output.
Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de>
config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- html/cgi-bin/entropy.cgi | 2 +- html/cgi-bin/netovpnsrv.cgi | 2 +- 3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index beddff032..cf4a30de3 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -24,6 +24,7 @@ package Graphs;
use strict; use RRDs; +use experimental 'smartmatch';
require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -99,26 +100,35 @@ foreach (@sensorsdir){ &General::readhash("${General::swroot}/sensors/settings", %sensorsettings);
# Generate a nice box for selection of time range in graphs -# this will generate a nice iframe for the cgi every klick for -# the graph will be handled inside the iframe +# this will generate a nice div box for the cgi every klick for +# the graph will be handled by javascript # 0 is the cgi refering to # 1 is the graph name -# 2 is the time range for the graph -# 3 if given is the height of the iframe default if nothing is given +# 2 is the time range for the graph (optional)
sub makegraphbox { -print "<center>"; -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; -print "<br></center>"; -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; +my ($origin, $name, $default_range) = @_;
+# Optional time range: Default to "day" unless otherwise specified +$default_range = "day" unless ($default_range ~~ @time_ranges);
+print <<END; +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> +<ul> +END
+# Print range select buttons +foreach my $range (@time_ranges) { +print <<END; +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> +END +}
+print <<END; +</ul> +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> +</div> +END }
# Generate the CPU Graph for the current period of time for values given by @@ -248,7 +258,7 @@ sub updatecpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; }
# Generate the Load Graph for the current period of time for values given by collecd @@ -280,7 +290,7 @@ sub updateloadgraph { "LINE1:load1".$color{"color18"}, ); $ERROR = RRDs::error; -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; }
# Generate the Memory Graph for the current period of time for values given by collecd @@ -336,7 +346,7 @@ sub updatememorygraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Swap Graph for the current period of time for values given by collecd @@ -385,7 +395,7 @@ sub updateswapgraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Process Cpu Graph for the current period of time for values given by collecd @@ -432,7 +442,7 @@ sub updateprocessescpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; }
# Generate the Process Memory Graph for the current period of time for values given by collecd @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; }
# Generate the Disk Graph for the current period of time for values given by collecd @@ -522,7 +532,7 @@ sub updatediskgraph { "GPRINT:write:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Interface Graph for the current period of time for values given by collecd @@ -561,7 +571,7 @@ sub updateifgraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpngraph { @@ -598,7 +608,7 @@ sub updatevpngraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpnn2ngraph { @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { "GPRINT:compression_out:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
# Generate the Firewall Graph for the current period of time for values given by collecd @@ -716,7 +726,7 @@ sub updatefwhitsgraph { "GPRINT:portscan:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; }
# Generate the Line Quality Graph for the current period of time for values given by collecd @@ -758,7 +768,7 @@ sub updatepinggraph { "GPRINT:roundtrip:LAST:%3.2lf ms\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; }
sub updatewirelessgraph { @@ -793,7 +803,7 @@ sub updatewirelessgraph { "GPRINT:power:LAST:%5.1lf %sdBm\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; }
# Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -827,7 +837,7 @@ sub updatehddgraph { "GPRINT:temperature:LAST:%3.0lf °C\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -875,7 +885,7 @@ sub updatehwtempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; }
# Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors @@ -922,7 +932,7 @@ sub updatehwfangraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; }
# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors @@ -969,7 +979,7 @@ sub updatehwvoltgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; }
@@ -1051,7 +1061,7 @@ sub updateqosgraph { } RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; }
# Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; }
# Generate the Thermal Zone Temp CPU Graph @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; }
@@ -1174,7 +1184,7 @@ sub updateentropygraph { RRDs::graph (@command); $ERROR = RRDs::error;
-print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; }
sub updateconntrackgraph { @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { RRDs::graph(@command); $ERROR = RRDs::error;
-print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; } diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi index d7a9ca5d8..f8045db5a 100644 --- a/html/cgi-bin/entropy.cgi +++ b/html/cgi-bin/entropy.cgi @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { &Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'center', $Lang::tr{'entropy'}); -&Graphs::makegraphbox("entropy.cgi", "day"); +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); &Header::closebox();
# Check for hardware support. diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi index 77c69cddb..ab3548713 100755 --- a/html/cgi-bin/netovpnsrv.cgi +++ b/html/cgi-bin/netovpnsrv.cgi @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ if (@vpns || %ipsecgraphs) { foreach my $name (sort keys %ipsecgraphs) { &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); &Header::closebox(); }
-- 2.27.0.windows.1
<rrdimg-css.png>
Hello,
Sorry for my late response. This is probably a little bit more urgent…
Our Apache configuration is here:
https://git.ipfire.org/?p=ipfire-2.x.git;a=tree;f=config/httpd;hb=HEAD
And it does not have any aggressive caching enabled.
The ETag header is precisely there for validating content without transferring it again. We probably should overhaul the entire apache configuration and come up with something that guarantees that we are using modern features of the browser and Apache. Currently the configuration is full of directives for MS Internet Explorer and Java-based browsers. We wouldn’t support any of them - not even sure if they exist any more.
@Peter: Would you be up for rewriting the apache configuration?
Best, -Michael
On 9 Apr 2021, at 18:45, Leo Hofmann hofmann@leo-andres.de wrote:
Hi,
I found that disabling the HTTP ETag header solved the problem for me. Are there any Cache-Control headers configured for these static files?
I'll change the CSS and submit a patch soon!
Leo
Am 09.04.2021 um 12:57 schrieb Michael Tremer:
Hello,
That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into.
Apart from that it works.
Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough?
-Michael
On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote:
Hello Michael,
No, of course not, that looks terrible! Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome.
Best regards, Leo
Am 07.04.2021 um 23:31 schrieb Michael Tremer:
Hello,
Is this meant to look like this?
On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote:
"makegraphbox" is modified to remove the old iframe method and output a modern div container instead. Graph errors are now returned, to be displayed by getrrdimage.cgi.
entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility.
Add cache control HTTP header to image output.
Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de>
config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- html/cgi-bin/entropy.cgi | 2 +- html/cgi-bin/netovpnsrv.cgi | 2 +- 3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index beddff032..cf4a30de3 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -24,6 +24,7 @@ package Graphs;
use strict; use RRDs; +use experimental 'smartmatch';
require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -99,26 +100,35 @@ foreach (@sensorsdir){ &General::readhash("${General::swroot}/sensors/settings", %sensorsettings);
# Generate a nice box for selection of time range in graphs -# this will generate a nice iframe for the cgi every klick for -# the graph will be handled inside the iframe +# this will generate a nice div box for the cgi every klick for +# the graph will be handled by javascript # 0 is the cgi refering to # 1 is the graph name -# 2 is the time range for the graph -# 3 if given is the height of the iframe default if nothing is given +# 2 is the time range for the graph (optional)
sub makegraphbox { -print "<center>"; -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; -print "<br></center>"; -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; +my ($origin, $name, $default_range) = @_;
+# Optional time range: Default to "day" unless otherwise specified +$default_range = "day" unless ($default_range ~~ @time_ranges);
+print <<END; +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> +<ul> +END
+# Print range select buttons +foreach my $range (@time_ranges) { +print <<END; +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> +END +}
+print <<END; +</ul> +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> +</div> +END }
# Generate the CPU Graph for the current period of time for values given by @@ -248,7 +258,7 @@ sub updatecpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; }
# Generate the Load Graph for the current period of time for values given by collecd @@ -280,7 +290,7 @@ sub updateloadgraph { "LINE1:load1".$color{"color18"}, ); $ERROR = RRDs::error; -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; }
# Generate the Memory Graph for the current period of time for values given by collecd @@ -336,7 +346,7 @@ sub updatememorygraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Swap Graph for the current period of time for values given by collecd @@ -385,7 +395,7 @@ sub updateswapgraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Process Cpu Graph for the current period of time for values given by collecd @@ -432,7 +442,7 @@ sub updateprocessescpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; }
# Generate the Process Memory Graph for the current period of time for values given by collecd @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; }
# Generate the Disk Graph for the current period of time for values given by collecd @@ -522,7 +532,7 @@ sub updatediskgraph { "GPRINT:write:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Interface Graph for the current period of time for values given by collecd @@ -561,7 +571,7 @@ sub updateifgraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpngraph { @@ -598,7 +608,7 @@ sub updatevpngraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpnn2ngraph { @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { "GPRINT:compression_out:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
# Generate the Firewall Graph for the current period of time for values given by collecd @@ -716,7 +726,7 @@ sub updatefwhitsgraph { "GPRINT:portscan:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; }
# Generate the Line Quality Graph for the current period of time for values given by collecd @@ -758,7 +768,7 @@ sub updatepinggraph { "GPRINT:roundtrip:LAST:%3.2lf ms\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; }
sub updatewirelessgraph { @@ -793,7 +803,7 @@ sub updatewirelessgraph { "GPRINT:power:LAST:%5.1lf %sdBm\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; }
# Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -827,7 +837,7 @@ sub updatehddgraph { "GPRINT:temperature:LAST:%3.0lf °C\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -875,7 +885,7 @@ sub updatehwtempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; }
# Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors @@ -922,7 +932,7 @@ sub updatehwfangraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; }
# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors @@ -969,7 +979,7 @@ sub updatehwvoltgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; }
@@ -1051,7 +1061,7 @@ sub updateqosgraph { } RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; }
# Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; }
# Generate the Thermal Zone Temp CPU Graph @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; }
@@ -1174,7 +1184,7 @@ sub updateentropygraph { RRDs::graph (@command); $ERROR = RRDs::error;
-print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; }
sub updateconntrackgraph { @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { RRDs::graph(@command); $ERROR = RRDs::error;
-print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; } diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi index d7a9ca5d8..f8045db5a 100644 --- a/html/cgi-bin/entropy.cgi +++ b/html/cgi-bin/entropy.cgi @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { &Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'center', $Lang::tr{'entropy'}); -&Graphs::makegraphbox("entropy.cgi", "day"); +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); &Header::closebox();
# Check for hardware support. diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi index 77c69cddb..ab3548713 100755 --- a/html/cgi-bin/netovpnsrv.cgi +++ b/html/cgi-bin/netovpnsrv.cgi @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ if (@vpns || %ipsecgraphs) { foreach my $name (sort keys %ipsecgraphs) { &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); &Header::closebox(); }
-- 2.27.0.windows.1
<rrdimg-css.png>
Good evening Michael, good evening Leo,
@Peter: Would you be up for rewriting the apache configuration?
voila: https://patchwork.ipfire.org/project/ipfire/list/?series=1941
This configuration has been tested and audited using NSE, Nikto, and a bunch of other wonderful penetration testing tools. To my surprise, HTTP TRACE is mandatory in HTTP 1.1 nowadays, and clients can expect it to be enabled - I used to read the advice to keep it disabled, but that seems to be obsolete meanwhile.
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
Thanks, and best regards, Peter Müller
Hello,
Sorry for my late response. This is probably a little bit more urgent…
Our Apache configuration is here:
https://git.ipfire.org/?p=ipfire-2.x.git;a=tree;f=config/httpd;hb=HEAD
And it does not have any aggressive caching enabled.
The ETag header is precisely there for validating content without transferring it again. We probably should overhaul the entire apache configuration and come up with something that guarantees that we are using modern features of the browser and Apache. Currently the configuration is full of directives for MS Internet Explorer and Java-based browsers. We wouldn’t support any of them - not even sure if they exist any more.
@Peter: Would you be up for rewriting the apache configuration?
Best, -Michael
On 9 Apr 2021, at 18:45, Leo Hofmann hofmann@leo-andres.de wrote:
Hi,
I found that disabling the HTTP ETag header solved the problem for me. Are there any Cache-Control headers configured for these static files?
I'll change the CSS and submit a patch soon!
Leo
Am 09.04.2021 um 12:57 schrieb Michael Tremer:
Hello,
That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into.
Apart from that it works.
Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough?
-Michael
On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote:
Hello Michael,
No, of course not, that looks terrible! Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome.
Best regards, Leo
Am 07.04.2021 um 23:31 schrieb Michael Tremer:
Hello,
Is this meant to look like this?
On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote:
"makegraphbox" is modified to remove the old iframe method and output a modern div container instead. Graph errors are now returned, to be displayed by getrrdimage.cgi.
entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility.
Add cache control HTTP header to image output.
Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de>
config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- html/cgi-bin/entropy.cgi | 2 +- html/cgi-bin/netovpnsrv.cgi | 2 +- 3 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index beddff032..cf4a30de3 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -24,6 +24,7 @@ package Graphs;
use strict; use RRDs; +use experimental 'smartmatch';
require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -99,26 +100,35 @@ foreach (@sensorsdir){ &General::readhash("${General::swroot}/sensors/settings", %sensorsettings);
# Generate a nice box for selection of time range in graphs -# this will generate a nice iframe for the cgi every klick for -# the graph will be handled inside the iframe +# this will generate a nice div box for the cgi every klick for +# the graph will be handled by javascript # 0 is the cgi refering to # 1 is the graph name -# 2 is the time range for the graph -# 3 if given is the height of the iframe default if nothing is given +# 2 is the time range for the graph (optional)
sub makegraphbox { -print "<center>"; -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; -print " - "; -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; -print "<br></center>"; -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; +my ($origin, $name, $default_range) = @_;
+# Optional time range: Default to "day" unless otherwise specified +$default_range = "day" unless ($default_range ~~ @time_ranges);
+print <<END; +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> +<ul> +END
+# Print range select buttons +foreach my $range (@time_ranges) { +print <<END; +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> +END +}
+print <<END; +</ul> +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> +</div> +END }
# Generate the CPU Graph for the current period of time for values given by @@ -248,7 +258,7 @@ sub updatecpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; }
# Generate the Load Graph for the current period of time for values given by collecd @@ -280,7 +290,7 @@ sub updateloadgraph { "LINE1:load1".$color{"color18"}, ); $ERROR = RRDs::error; -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; }
# Generate the Memory Graph for the current period of time for values given by collecd @@ -336,7 +346,7 @@ sub updatememorygraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Swap Graph for the current period of time for values given by collecd @@ -385,7 +395,7 @@ sub updateswapgraph { "GPRINT:freepct:LAST:%3.2lf%%\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; }
# Generate the Process Cpu Graph for the current period of time for values given by collecd @@ -432,7 +442,7 @@ sub updateprocessescpugraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; }
# Generate the Process Memory Graph for the current period of time for values given by collecd @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; }
# Generate the Disk Graph for the current period of time for values given by collecd @@ -522,7 +532,7 @@ sub updatediskgraph { "GPRINT:write:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Interface Graph for the current period of time for values given by collecd @@ -561,7 +571,7 @@ sub updateifgraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpngraph { @@ -598,7 +608,7 @@ sub updatevpngraph { "GPRINT:outgoing:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
sub updatevpnn2ngraph { @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { "GPRINT:compression_out:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; }
# Generate the Firewall Graph for the current period of time for values given by collecd @@ -716,7 +726,7 @@ sub updatefwhitsgraph { "GPRINT:portscan:LAST:%8.1lf %sBps\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; }
# Generate the Line Quality Graph for the current period of time for values given by collecd @@ -758,7 +768,7 @@ sub updatepinggraph { "GPRINT:roundtrip:LAST:%3.2lf ms\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; }
sub updatewirelessgraph { @@ -793,7 +803,7 @@ sub updatewirelessgraph { "GPRINT:power:LAST:%5.1lf %sdBm\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; }
# Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -827,7 +837,7 @@ sub updatehddgraph { "GPRINT:temperature:LAST:%3.0lf °C\j", ); $ERROR = RRDs::error; -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; }
# Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors @@ -875,7 +885,7 @@ sub updatehwtempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; }
# Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors @@ -922,7 +932,7 @@ sub updatehwfangraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; }
# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors @@ -969,7 +979,7 @@ sub updatehwvoltgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; }
@@ -1051,7 +1061,7 @@ sub updateqosgraph { } RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; }
# Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; }
# Generate the Thermal Zone Temp CPU Graph @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph {
RRDs::graph (@command); $ERROR = RRDs::error; -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; }
@@ -1174,7 +1184,7 @@ sub updateentropygraph { RRDs::graph (@command); $ERROR = RRDs::error;
-print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; }
sub updateconntrackgraph { @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { RRDs::graph(@command); $ERROR = RRDs::error;
-print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; } diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi index d7a9ca5d8..f8045db5a 100644 --- a/html/cgi-bin/entropy.cgi +++ b/html/cgi-bin/entropy.cgi @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { &Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'center', $Lang::tr{'entropy'}); -&Graphs::makegraphbox("entropy.cgi", "day"); +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); &Header::closebox();
# Check for hardware support. diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi index 77c69cddb..ab3548713 100755 --- a/html/cgi-bin/netovpnsrv.cgi +++ b/html/cgi-bin/netovpnsrv.cgi @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ if (@vpns || %ipsecgraphs) { foreach my $name (sort keys %ipsecgraphs) { &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); &Header::closebox(); }
-- 2.27.0.windows.1
<rrdimg-css.png>
Hi Peter,
thank you for taking care of that! I didn't expect that my idea to modernise the graphs would cause so much work... But I am glad that we were able to find and improve all these things.
Best regards, Leo
Am 12.04.2021 um 23:06 schrieb Peter Müller:
Good evening Michael, good evening Leo,
@Peter: Would you be up for rewriting the apache configuration?
voila: https://patchwork.ipfire.org/project/ipfire/list/?series=1941
This configuration has been tested and audited using NSE, Nikto, and a bunch of other wonderful penetration testing tools. To my surprise, HTTP TRACE is mandatory in HTTP 1.1 nowadays, and clients can expect it to be enabled - I used to read the advice to keep it disabled, but that seems to be obsolete meanwhile.
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
Thanks, and best regards, Peter Müller
Hello,
Sorry for my late response. This is probably a little bit more urgent…
Our Apache configuration is here:
https://git.ipfire.org/?p=ipfire-2.x.git;a=tree;f=config/httpd;hb=HEAD
And it does not have any aggressive caching enabled.
The ETag header is precisely there for validating content without transferring it again. We probably should overhaul the entire apache configuration and come up with something that guarantees that we are using modern features of the browser and Apache. Currently the configuration is full of directives for MS Internet Explorer and Java-based browsers. We wouldn’t support any of them - not even sure if they exist any more.
@Peter: Would you be up for rewriting the apache configuration?
Best, -Michael
On 9 Apr 2021, at 18:45, Leo Hofmann hofmann@leo-andres.de wrote:
Hi,
I found that disabling the HTTP ETag header solved the problem for me. Are there any Cache-Control headers configured for these static files?
I'll change the CSS and submit a patch soon!
Leo
Am 09.04.2021 um 12:57 schrieb Michael Tremer:
Hello,
That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into.
Apart from that it works.
Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough?
-Michael
On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote:
Hello Michael,
No, of course not, that looks terrible! Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome.
Best regards, Leo
Am 07.04.2021 um 23:31 schrieb Michael Tremer:
Hello,
Is this meant to look like this?
> On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote: > > "makegraphbox" is modified to remove the old iframe method and output > a modern div container instead. > Graph errors are now returned, to be displayed by getrrdimage.cgi. > > entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility. > > Add cache control HTTP header to image output. > > Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> > --- > config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- > html/cgi-bin/entropy.cgi | 2 +- > html/cgi-bin/netovpnsrv.cgi | 2 +- > 3 files changed, 50 insertions(+), 40 deletions(-) > > diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl > index beddff032..cf4a30de3 100644 > --- a/config/cfgroot/graphs.pl > +++ b/config/cfgroot/graphs.pl > @@ -24,6 +24,7 @@ package Graphs; > > use strict; > use RRDs; > +use experimental 'smartmatch'; > > require '/var/ipfire/general-functions.pl'; > require "${General::swroot}/lang.pl"; > @@ -99,26 +100,35 @@ foreach (@sensorsdir){ > &General::readhash("${General::swroot}/sensors/settings", %sensorsettings); > > # Generate a nice box for selection of time range in graphs > -# this will generate a nice iframe for the cgi every klick for > -# the graph will be handled inside the iframe > +# this will generate a nice div box for the cgi every klick for > +# the graph will be handled by javascript > # 0 is the cgi refering to > # 1 is the graph name > -# 2 is the time range for the graph > -# 3 if given is the height of the iframe default if nothing is given > +# 2 is the time range for the graph (optional) > > sub makegraphbox { > -print "<center>"; > -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; > -print " - "; > -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; > -print " - "; > -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; > -print " - "; > -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; > -print " - "; > -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; > -print "<br></center>"; > -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; > +my ($origin, $name, $default_range) = @_; > + > +# Optional time range: Default to "day" unless otherwise specified > +$default_range = "day" unless ($default_range ~~ @time_ranges); > + > +print <<END; > +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> > +<ul> > +END > + > +# Print range select buttons > +foreach my $range (@time_ranges) { > +print <<END; > +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> > +END > +} > + > +print <<END; > +</ul> > +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> > +</div> > +END > } > > # Generate the CPU Graph for the current period of time for values given by > @@ -248,7 +258,7 @@ sub updatecpugraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; > } > > # Generate the Load Graph for the current period of time for values given by collecd > @@ -280,7 +290,7 @@ sub updateloadgraph { > "LINE1:load1".$color{"color18"}, > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; > } > > # Generate the Memory Graph for the current period of time for values given by collecd > @@ -336,7 +346,7 @@ sub updatememorygraph { > "GPRINT:freepct:LAST:%3.2lf%%\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; > } > > # Generate the Swap Graph for the current period of time for values given by collecd > @@ -385,7 +395,7 @@ sub updateswapgraph { > "GPRINT:freepct:LAST:%3.2lf%%\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; > } > > # Generate the Process Cpu Graph for the current period of time for values given by collecd > @@ -432,7 +442,7 @@ sub updateprocessescpugraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; > } > > # Generate the Process Memory Graph for the current period of time for values given by collecd > @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; > } > > # Generate the Disk Graph for the current period of time for values given by collecd > @@ -522,7 +532,7 @@ sub updatediskgraph { > "GPRINT:write:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; > } > > # Generate the Interface Graph for the current period of time for values given by collecd > @@ -561,7 +571,7 @@ sub updateifgraph { > "GPRINT:outgoing:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > } > > sub updatevpngraph { > @@ -598,7 +608,7 @@ sub updatevpngraph { > "GPRINT:outgoing:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > } > > sub updatevpnn2ngraph { > @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { > "GPRINT:compression_out:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > } > > # Generate the Firewall Graph for the current period of time for values given by collecd > @@ -716,7 +726,7 @@ sub updatefwhitsgraph { > "GPRINT:portscan:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; > } > > # Generate the Line Quality Graph for the current period of time for values given by collecd > @@ -758,7 +768,7 @@ sub updatepinggraph { > "GPRINT:roundtrip:LAST:%3.2lf ms\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; > } > > sub updatewirelessgraph { > @@ -793,7 +803,7 @@ sub updatewirelessgraph { > "GPRINT:power:LAST:%5.1lf %sdBm\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; > } > > # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors > @@ -827,7 +837,7 @@ sub updatehddgraph { > "GPRINT:temperature:LAST:%3.0lf °C\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; > } > > # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors > @@ -875,7 +885,7 @@ sub updatehwtempgraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; > } > > # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors > @@ -922,7 +932,7 @@ sub updatehwfangraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; > } > > # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors > @@ -969,7 +979,7 @@ sub updatehwvoltgraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; > } > > > @@ -1051,7 +1061,7 @@ sub updateqosgraph { > } > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; > } > > # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors > @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; > } > > # Generate the Thermal Zone Temp CPU Graph > @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; > } > > > @@ -1174,7 +1184,7 @@ sub updateentropygraph { > RRDs::graph (@command); > $ERROR = RRDs::error; > > -print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; > } > > sub updateconntrackgraph { > @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { > RRDs::graph(@command); > $ERROR = RRDs::error; > > -print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; > +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; > } > diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi > index d7a9ca5d8..f8045db5a 100644 > --- a/html/cgi-bin/entropy.cgi > +++ b/html/cgi-bin/entropy.cgi > @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { > &Header::openbigbox('100%', 'left'); > > &Header::openbox('100%', 'center', $Lang::tr{'entropy'}); > -&Graphs::makegraphbox("entropy.cgi", "day"); > +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); > &Header::closebox(); > > # Check for hardware support. > diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi > index 77c69cddb..ab3548713 100755 > --- a/html/cgi-bin/netovpnsrv.cgi > +++ b/html/cgi-bin/netovpnsrv.cgi > @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ > if (@vpns || %ipsecgraphs) { > foreach my $name (sort keys %ipsecgraphs) { > &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); > -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); > +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); > &Header::closebox(); > } > > -- > 2.27.0.windows.1 >
<rrdimg-css.png>
Hello Leo,
thanks for your reply.
No worries, I eventually tried to get rid of the ETag header a while ago, but it eventually slipped my mind. :-)
Thanks, and best regards, Peter Müller
Hi Peter,
thank you for taking care of that! I didn't expect that my idea to modernise the graphs would cause so much work... But I am glad that we were able to find and improve all these things.
Best regards, Leo
Am 12.04.2021 um 23:06 schrieb Peter Müller:
Good evening Michael, good evening Leo,
@Peter: Would you be up for rewriting the apache configuration?
voila: https://patchwork.ipfire.org/project/ipfire/list/?series=1941
This configuration has been tested and audited using NSE, Nikto, and a bunch of other wonderful penetration testing tools. To my surprise, HTTP TRACE is mandatory in HTTP 1.1 nowadays, and clients can expect it to be enabled - I used to read the advice to keep it disabled, but that seems to be obsolete meanwhile.
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
Thanks, and best regards, Peter Müller
Hello,
Sorry for my late response. This is probably a little bit more urgent…
Our Apache configuration is here:
https://git.ipfire.org/?p=ipfire-2.x.git;a=tree;f=config/httpd;hb=HEAD
And it does not have any aggressive caching enabled.
The ETag header is precisely there for validating content without transferring it again. We probably should overhaul the entire apache configuration and come up with something that guarantees that we are using modern features of the browser and Apache. Currently the configuration is full of directives for MS Internet Explorer and Java-based browsers. We wouldn’t support any of them - not even sure if they exist any more.
@Peter: Would you be up for rewriting the apache configuration?
Best, -Michael
On 9 Apr 2021, at 18:45, Leo Hofmann hofmann@leo-andres.de wrote:
Hi,
I found that disabling the HTTP ETag header solved the problem for me. Are there any Cache-Control headers configured for these static files?
I'll change the CSS and submit a patch soon!
Leo
Am 09.04.2021 um 12:57 schrieb Michael Tremer:
Hello,
That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into.
Apart from that it works.
Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough?
-Michael
On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote:
Hello Michael,
No, of course not, that looks terrible! Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome.
Best regards, Leo
Am 07.04.2021 um 23:31 schrieb Michael Tremer: > Hello, > > Is this meant to look like this? > > > >> On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote: >> >> "makegraphbox" is modified to remove the old iframe method and output >> a modern div container instead. >> Graph errors are now returned, to be displayed by getrrdimage.cgi. >> >> entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility. >> >> Add cache control HTTP header to image output. >> >> Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> >> --- >> config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- >> html/cgi-bin/entropy.cgi | 2 +- >> html/cgi-bin/netovpnsrv.cgi | 2 +- >> 3 files changed, 50 insertions(+), 40 deletions(-) >> >> diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl >> index beddff032..cf4a30de3 100644 >> --- a/config/cfgroot/graphs.pl >> +++ b/config/cfgroot/graphs.pl >> @@ -24,6 +24,7 @@ package Graphs; >> >> use strict; >> use RRDs; >> +use experimental 'smartmatch'; >> >> require '/var/ipfire/general-functions.pl'; >> require "${General::swroot}/lang.pl"; >> @@ -99,26 +100,35 @@ foreach (@sensorsdir){ >> &General::readhash("${General::swroot}/sensors/settings", %sensorsettings); >> >> # Generate a nice box for selection of time range in graphs >> -# this will generate a nice iframe for the cgi every klick for >> -# the graph will be handled inside the iframe >> +# this will generate a nice div box for the cgi every klick for >> +# the graph will be handled by javascript >> # 0 is the cgi refering to >> # 1 is the graph name >> -# 2 is the time range for the graph >> -# 3 if given is the height of the iframe default if nothing is given >> +# 2 is the time range for the graph (optional) >> >> sub makegraphbox { >> -print "<center>"; >> -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; >> -print " - "; >> -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; >> -print " - "; >> -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; >> -print " - "; >> -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; >> -print " - "; >> -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; >> -print "<br></center>"; >> -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; >> +my ($origin, $name, $default_range) = @_; >> + >> +# Optional time range: Default to "day" unless otherwise specified >> +$default_range = "day" unless ($default_range ~~ @time_ranges); >> + >> +print <<END; >> +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> >> +<ul> >> +END >> + >> +# Print range select buttons >> +foreach my $range (@time_ranges) { >> +print <<END; >> +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> >> +END >> +} >> + >> +print <<END; >> +</ul> >> +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> >> +</div> >> +END >> } >> >> # Generate the CPU Graph for the current period of time for values given by >> @@ -248,7 +258,7 @@ sub updatecpugraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Load Graph for the current period of time for values given by collecd >> @@ -280,7 +290,7 @@ sub updateloadgraph { >> "LINE1:load1".$color{"color18"}, >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Memory Graph for the current period of time for values given by collecd >> @@ -336,7 +346,7 @@ sub updatememorygraph { >> "GPRINT:freepct:LAST:%3.2lf%%\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Swap Graph for the current period of time for values given by collecd >> @@ -385,7 +395,7 @@ sub updateswapgraph { >> "GPRINT:freepct:LAST:%3.2lf%%\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Process Cpu Graph for the current period of time for values given by collecd >> @@ -432,7 +442,7 @@ sub updateprocessescpugraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Process Memory Graph for the current period of time for values given by collecd >> @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Disk Graph for the current period of time for values given by collecd >> @@ -522,7 +532,7 @@ sub updatediskgraph { >> "GPRINT:write:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Interface Graph for the current period of time for values given by collecd >> @@ -561,7 +571,7 @@ sub updateifgraph { >> "GPRINT:outgoing:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> } >> >> sub updatevpngraph { >> @@ -598,7 +608,7 @@ sub updatevpngraph { >> "GPRINT:outgoing:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> } >> >> sub updatevpnn2ngraph { >> @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { >> "GPRINT:compression_out:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Firewall Graph for the current period of time for values given by collecd >> @@ -716,7 +726,7 @@ sub updatefwhitsgraph { >> "GPRINT:portscan:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Line Quality Graph for the current period of time for values given by collecd >> @@ -758,7 +768,7 @@ sub updatepinggraph { >> "GPRINT:roundtrip:LAST:%3.2lf ms\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; >> } >> >> sub updatewirelessgraph { >> @@ -793,7 +803,7 @@ sub updatewirelessgraph { >> "GPRINT:power:LAST:%5.1lf %sdBm\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors >> @@ -827,7 +837,7 @@ sub updatehddgraph { >> "GPRINT:temperature:LAST:%3.0lf °C\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors >> @@ -875,7 +885,7 @@ sub updatehwtempgraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors >> @@ -922,7 +932,7 @@ sub updatehwfangraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors >> @@ -969,7 +979,7 @@ sub updatehwvoltgraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; >> } >> >> >> @@ -1051,7 +1061,7 @@ sub updateqosgraph { >> } >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors >> @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Thermal Zone Temp CPU Graph >> @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; >> } >> >> >> @@ -1174,7 +1184,7 @@ sub updateentropygraph { >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> >> -print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; >> } >> >> sub updateconntrackgraph { >> @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { >> RRDs::graph(@command); >> $ERROR = RRDs::error; >> >> -print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; >> +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; >> } >> diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi >> index d7a9ca5d8..f8045db5a 100644 >> --- a/html/cgi-bin/entropy.cgi >> +++ b/html/cgi-bin/entropy.cgi >> @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { >> &Header::openbigbox('100%', 'left'); >> >> &Header::openbox('100%', 'center', $Lang::tr{'entropy'}); >> -&Graphs::makegraphbox("entropy.cgi", "day"); >> +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); >> &Header::closebox(); >> >> # Check for hardware support. >> diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi >> index 77c69cddb..ab3548713 100755 >> --- a/html/cgi-bin/netovpnsrv.cgi >> +++ b/html/cgi-bin/netovpnsrv.cgi >> @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ >> if (@vpns || %ipsecgraphs) { >> foreach my $name (sort keys %ipsecgraphs) { >> &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); >> -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); >> +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); >> &Header::closebox(); >> } >> >> -- >> 2.27.0.windows.1 >> <rrdimg-css.png>
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
What about when running openssl to generate a new key? That one times out for me.
I believe its purpose is to generate as many periods as possible. ;-)
On Apr 12, 2021, at 4:06 PM, Peter Müller peter.mueller@ipfire.org wrote:
Good evening Michael, good evening Leo,
@Peter: Would you be up for rewriting the apache configuration?
voila: https://patchwork.ipfire.org/project/ipfire/list/?series=1941
This configuration has been tested and audited using NSE, Nikto, and a bunch of other wonderful penetration testing tools. To my surprise, HTTP TRACE is mandatory in HTTP 1.1 nowadays, and clients can expect it to be enabled - I used to read the advice to keep it disabled, but that seems to be obsolete meanwhile.
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
Thanks, and best regards, Peter Müller
Hello,
Sorry for my late response. This is probably a little bit more urgent…
Our Apache configuration is here:
https://git.ipfire.org/?p=ipfire-2.x.git;a=tree;f=config/httpd;hb=HEAD
And it does not have any aggressive caching enabled.
The ETag header is precisely there for validating content without transferring it again. We probably should overhaul the entire apache configuration and come up with something that guarantees that we are using modern features of the browser and Apache. Currently the configuration is full of directives for MS Internet Explorer and Java-based browsers. We wouldn’t support any of them - not even sure if they exist any more.
@Peter: Would you be up for rewriting the apache configuration?
Best, -Michael
On 9 Apr 2021, at 18:45, Leo Hofmann hofmann@leo-andres.de wrote:
Hi,
I found that disabling the HTTP ETag header solved the problem for me. Are there any Cache-Control headers configured for these static files?
I'll change the CSS and submit a patch soon!
Leo
Am 09.04.2021 um 12:57 schrieb Michael Tremer:
Hello,
That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into.
Apart from that it works.
Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough?
-Michael
On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote:
Hello Michael,
No, of course not, that looks terrible! Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome.
Best regards, Leo
Am 07.04.2021 um 23:31 schrieb Michael Tremer:
Hello,
Is this meant to look like this?
> On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote: > > "makegraphbox" is modified to remove the old iframe method and output > a modern div container instead. > Graph errors are now returned, to be displayed by getrrdimage.cgi. > > entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility. > > Add cache control HTTP header to image output. > > Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> > --- > config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- > html/cgi-bin/entropy.cgi | 2 +- > html/cgi-bin/netovpnsrv.cgi | 2 +- > 3 files changed, 50 insertions(+), 40 deletions(-) > > diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl > index beddff032..cf4a30de3 100644 > --- a/config/cfgroot/graphs.pl > +++ b/config/cfgroot/graphs.pl > @@ -24,6 +24,7 @@ package Graphs; > > use strict; > use RRDs; > +use experimental 'smartmatch'; > > require '/var/ipfire/general-functions.pl'; > require "${General::swroot}/lang.pl"; > @@ -99,26 +100,35 @@ foreach (@sensorsdir){ > &General::readhash("${General::swroot}/sensors/settings", %sensorsettings); > > # Generate a nice box for selection of time range in graphs > -# this will generate a nice iframe for the cgi every klick for > -# the graph will be handled inside the iframe > +# this will generate a nice div box for the cgi every klick for > +# the graph will be handled by javascript > # 0 is the cgi refering to > # 1 is the graph name > -# 2 is the time range for the graph > -# 3 if given is the height of the iframe default if nothing is given > +# 2 is the time range for the graph (optional) > > sub makegraphbox { > -print "<center>"; > -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; > -print " - "; > -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; > -print " - "; > -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; > -print " - "; > -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; > -print " - "; > -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; > -print "<br></center>"; > -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; > +my ($origin, $name, $default_range) = @_; > + > +# Optional time range: Default to "day" unless otherwise specified > +$default_range = "day" unless ($default_range ~~ @time_ranges); > + > +print <<END; > +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> > +<ul> > +END > + > +# Print range select buttons > +foreach my $range (@time_ranges) { > +print <<END; > +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> > +END > +} > + > +print <<END; > +</ul> > +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> > +</div> > +END > } > > # Generate the CPU Graph for the current period of time for values given by > @@ -248,7 +258,7 @@ sub updatecpugraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; > } > > # Generate the Load Graph for the current period of time for values given by collecd > @@ -280,7 +290,7 @@ sub updateloadgraph { > "LINE1:load1".$color{"color18"}, > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; > } > > # Generate the Memory Graph for the current period of time for values given by collecd > @@ -336,7 +346,7 @@ sub updatememorygraph { > "GPRINT:freepct:LAST:%3.2lf%%\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; > } > > # Generate the Swap Graph for the current period of time for values given by collecd > @@ -385,7 +395,7 @@ sub updateswapgraph { > "GPRINT:freepct:LAST:%3.2lf%%\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; > } > > # Generate the Process Cpu Graph for the current period of time for values given by collecd > @@ -432,7 +442,7 @@ sub updateprocessescpugraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; > } > > # Generate the Process Memory Graph for the current period of time for values given by collecd > @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; > } > > # Generate the Disk Graph for the current period of time for values given by collecd > @@ -522,7 +532,7 @@ sub updatediskgraph { > "GPRINT:write:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; > } > > # Generate the Interface Graph for the current period of time for values given by collecd > @@ -561,7 +571,7 @@ sub updateifgraph { > "GPRINT:outgoing:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > } > > sub updatevpngraph { > @@ -598,7 +608,7 @@ sub updatevpngraph { > "GPRINT:outgoing:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > } > > sub updatevpnn2ngraph { > @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { > "GPRINT:compression_out:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; > } > > # Generate the Firewall Graph for the current period of time for values given by collecd > @@ -716,7 +726,7 @@ sub updatefwhitsgraph { > "GPRINT:portscan:LAST:%8.1lf %sBps\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; > } > > # Generate the Line Quality Graph for the current period of time for values given by collecd > @@ -758,7 +768,7 @@ sub updatepinggraph { > "GPRINT:roundtrip:LAST:%3.2lf ms\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; > } > > sub updatewirelessgraph { > @@ -793,7 +803,7 @@ sub updatewirelessgraph { > "GPRINT:power:LAST:%5.1lf %sdBm\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; > } > > # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors > @@ -827,7 +837,7 @@ sub updatehddgraph { > "GPRINT:temperature:LAST:%3.0lf °C\j", > ); > $ERROR = RRDs::error; > -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; > } > > # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors > @@ -875,7 +885,7 @@ sub updatehwtempgraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; > } > > # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors > @@ -922,7 +932,7 @@ sub updatehwfangraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; > } > > # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors > @@ -969,7 +979,7 @@ sub updatehwvoltgraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; > } > > > @@ -1051,7 +1061,7 @@ sub updateqosgraph { > } > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; > } > > # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors > @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; > } > > # Generate the Thermal Zone Temp CPU Graph > @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph { > > RRDs::graph (@command); > $ERROR = RRDs::error; > -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; > } > > > @@ -1174,7 +1184,7 @@ sub updateentropygraph { > RRDs::graph (@command); > $ERROR = RRDs::error; > > -print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; > +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; > } > > sub updateconntrackgraph { > @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { > RRDs::graph(@command); > $ERROR = RRDs::error; > > -print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; > +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; > } > diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi > index d7a9ca5d8..f8045db5a 100644 > --- a/html/cgi-bin/entropy.cgi > +++ b/html/cgi-bin/entropy.cgi > @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { > &Header::openbigbox('100%', 'left'); > > &Header::openbox('100%', 'center', $Lang::tr{'entropy'}); > -&Graphs::makegraphbox("entropy.cgi", "day"); > +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); > &Header::closebox(); > > # Check for hardware support. > diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi > index 77c69cddb..ab3548713 100755 > --- a/html/cgi-bin/netovpnsrv.cgi > +++ b/html/cgi-bin/netovpnsrv.cgi > @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ > if (@vpns || %ipsecgraphs) { > foreach my $name (sort keys %ipsecgraphs) { > &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); > -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); > +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); > &Header::closebox(); > } > > -- > 2.27.0.windows.1 >
<rrdimg-css.png>
Hello Jon,
thanks for your reply.
Indeed, generating key files for OpenVPN or IPsec - and, worse, DH parameters for OpenVPN - was something I did not have had in mind yesterday. These can take ages indeed, especially on slower hardware. As far as I am aware, we are not there yet when it comes to ECC cryptography for both VPN subsystems.
In an ideal world, Apache would support two distinct types of timeouts: One for network interaction to the client, where 60 seconds would be absolutely satisfying. The other one would be for server side applications such as CGIs which may take longer.
At the moment, I would estimate a relatively small amount of connections to be sufficient to launch a DoS against Apache as it comes in IPFire. Ultimately, tuning won't help here, if the offender is physically present in the GREEN or BLUE network. So, in the end, my timeout thought probably does not really matter... :-)
Thanks, and best regards, Peter Müller
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
What about when running openssl to generate a new key? That one times out for me.
I believe its purpose is to generate as many periods as possible. ;-)
On Apr 12, 2021, at 4:06 PM, Peter Müller peter.mueller@ipfire.org wrote:
Good evening Michael, good evening Leo,
@Peter: Would you be up for rewriting the apache configuration?
voila: https://patchwork.ipfire.org/project/ipfire/list/?series=1941
This configuration has been tested and audited using NSE, Nikto, and a bunch of other wonderful penetration testing tools. To my surprise, HTTP TRACE is mandatory in HTTP 1.1 nowadays, and clients can expect it to be enabled - I used to read the advice to keep it disabled, but that seems to be obsolete meanwhile.
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
Thanks, and best regards, Peter Müller
Hello,
Sorry for my late response. This is probably a little bit more urgent…
Our Apache configuration is here:
https://git.ipfire.org/?p=ipfire-2.x.git;a=tree;f=config/httpd;hb=HEAD
And it does not have any aggressive caching enabled.
The ETag header is precisely there for validating content without transferring it again. We probably should overhaul the entire apache configuration and come up with something that guarantees that we are using modern features of the browser and Apache. Currently the configuration is full of directives for MS Internet Explorer and Java-based browsers. We wouldn’t support any of them - not even sure if they exist any more.
@Peter: Would you be up for rewriting the apache configuration?
Best, -Michael
On 9 Apr 2021, at 18:45, Leo Hofmann hofmann@leo-andres.de wrote:
Hi,
I found that disabling the HTTP ETag header solved the problem for me. Are there any Cache-Control headers configured for these static files?
I'll change the CSS and submit a patch soon!
Leo
Am 09.04.2021 um 12:57 schrieb Michael Tremer:
Hello,
That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into.
Apart from that it works.
Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough?
-Michael
On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote:
Hello Michael,
No, of course not, that looks terrible! Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome.
Best regards, Leo
Am 07.04.2021 um 23:31 schrieb Michael Tremer: > Hello, > > Is this meant to look like this? > > > >> On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote: >> >> "makegraphbox" is modified to remove the old iframe method and output >> a modern div container instead. >> Graph errors are now returned, to be displayed by getrrdimage.cgi. >> >> entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility. >> >> Add cache control HTTP header to image output. >> >> Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> >> --- >> config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- >> html/cgi-bin/entropy.cgi | 2 +- >> html/cgi-bin/netovpnsrv.cgi | 2 +- >> 3 files changed, 50 insertions(+), 40 deletions(-) >> >> diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl >> index beddff032..cf4a30de3 100644 >> --- a/config/cfgroot/graphs.pl >> +++ b/config/cfgroot/graphs.pl >> @@ -24,6 +24,7 @@ package Graphs; >> >> use strict; >> use RRDs; >> +use experimental 'smartmatch'; >> >> require '/var/ipfire/general-functions.pl'; >> require "${General::swroot}/lang.pl"; >> @@ -99,26 +100,35 @@ foreach (@sensorsdir){ >> &General::readhash("${General::swroot}/sensors/settings", %sensorsettings); >> >> # Generate a nice box for selection of time range in graphs >> -# this will generate a nice iframe for the cgi every klick for >> -# the graph will be handled inside the iframe >> +# this will generate a nice div box for the cgi every klick for >> +# the graph will be handled by javascript >> # 0 is the cgi refering to >> # 1 is the graph name >> -# 2 is the time range for the graph >> -# 3 if given is the height of the iframe default if nothing is given >> +# 2 is the time range for the graph (optional) >> >> sub makegraphbox { >> -print "<center>"; >> -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; >> -print " - "; >> -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; >> -print " - "; >> -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; >> -print " - "; >> -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; >> -print " - "; >> -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; >> -print "<br></center>"; >> -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; >> +my ($origin, $name, $default_range) = @_; >> + >> +# Optional time range: Default to "day" unless otherwise specified >> +$default_range = "day" unless ($default_range ~~ @time_ranges); >> + >> +print <<END; >> +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> >> +<ul> >> +END >> + >> +# Print range select buttons >> +foreach my $range (@time_ranges) { >> +print <<END; >> +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> >> +END >> +} >> + >> +print <<END; >> +</ul> >> +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> >> +</div> >> +END >> } >> >> # Generate the CPU Graph for the current period of time for values given by >> @@ -248,7 +258,7 @@ sub updatecpugraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Load Graph for the current period of time for values given by collecd >> @@ -280,7 +290,7 @@ sub updateloadgraph { >> "LINE1:load1".$color{"color18"}, >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Memory Graph for the current period of time for values given by collecd >> @@ -336,7 +346,7 @@ sub updatememorygraph { >> "GPRINT:freepct:LAST:%3.2lf%%\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Swap Graph for the current period of time for values given by collecd >> @@ -385,7 +395,7 @@ sub updateswapgraph { >> "GPRINT:freepct:LAST:%3.2lf%%\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Process Cpu Graph for the current period of time for values given by collecd >> @@ -432,7 +442,7 @@ sub updateprocessescpugraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Process Memory Graph for the current period of time for values given by collecd >> @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Disk Graph for the current period of time for values given by collecd >> @@ -522,7 +532,7 @@ sub updatediskgraph { >> "GPRINT:write:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Interface Graph for the current period of time for values given by collecd >> @@ -561,7 +571,7 @@ sub updateifgraph { >> "GPRINT:outgoing:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> } >> >> sub updatevpngraph { >> @@ -598,7 +608,7 @@ sub updatevpngraph { >> "GPRINT:outgoing:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> } >> >> sub updatevpnn2ngraph { >> @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { >> "GPRINT:compression_out:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Firewall Graph for the current period of time for values given by collecd >> @@ -716,7 +726,7 @@ sub updatefwhitsgraph { >> "GPRINT:portscan:LAST:%8.1lf %sBps\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Line Quality Graph for the current period of time for values given by collecd >> @@ -758,7 +768,7 @@ sub updatepinggraph { >> "GPRINT:roundtrip:LAST:%3.2lf ms\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; >> } >> >> sub updatewirelessgraph { >> @@ -793,7 +803,7 @@ sub updatewirelessgraph { >> "GPRINT:power:LAST:%5.1lf %sdBm\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors >> @@ -827,7 +837,7 @@ sub updatehddgraph { >> "GPRINT:temperature:LAST:%3.0lf °C\j", >> ); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors >> @@ -875,7 +885,7 @@ sub updatehwtempgraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors >> @@ -922,7 +932,7 @@ sub updatehwfangraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors >> @@ -969,7 +979,7 @@ sub updatehwvoltgraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; >> } >> >> >> @@ -1051,7 +1061,7 @@ sub updateqosgraph { >> } >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors >> @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; >> } >> >> # Generate the Thermal Zone Temp CPU Graph >> @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph { >> >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; >> } >> >> >> @@ -1174,7 +1184,7 @@ sub updateentropygraph { >> RRDs::graph (@command); >> $ERROR = RRDs::error; >> >> -print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; >> +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; >> } >> >> sub updateconntrackgraph { >> @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { >> RRDs::graph(@command); >> $ERROR = RRDs::error; >> >> -print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; >> +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; >> } >> diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi >> index d7a9ca5d8..f8045db5a 100644 >> --- a/html/cgi-bin/entropy.cgi >> +++ b/html/cgi-bin/entropy.cgi >> @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { >> &Header::openbigbox('100%', 'left'); >> >> &Header::openbox('100%', 'center', $Lang::tr{'entropy'}); >> -&Graphs::makegraphbox("entropy.cgi", "day"); >> +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); >> &Header::closebox(); >> >> # Check for hardware support. >> diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi >> index 77c69cddb..ab3548713 100755 >> --- a/html/cgi-bin/netovpnsrv.cgi >> +++ b/html/cgi-bin/netovpnsrv.cgi >> @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ >> if (@vpns || %ipsecgraphs) { >> foreach my $name (sort keys %ipsecgraphs) { >> &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); >> -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); >> +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); >> &Header::closebox(); >> } >> >> -- >> 2.27.0.windows.1 >> <rrdimg-css.png>
Would it be possible to dump the key-generation task into the background in those instances and have the WUI report on the status? That way, the timeout does not have to be long enough for the entire process, just for however long it takes to submit the task for processing.
Kind of like Pakfire does, or even just submit the changes and have the WUI show that the process is still running if you, for example, navigate to the IPSec page, where the keys are displayed.
Tom
On Apr 13, 2021, at 11:24 AM, Peter Müller peter.mueller@ipfire.org wrote:
Hello Jon,
thanks for your reply.
Indeed, generating key files for OpenVPN or IPsec - and, worse, DH parameters for OpenVPN - was something I did not have had in mind yesterday. These can take ages indeed, especially on slower hardware. As far as I am aware, we are not there yet when it comes to ECC cryptography for both VPN subsystems.
In an ideal world, Apache would support two distinct types of timeouts: One for network interaction to the client, where 60 seconds would be absolutely satisfying. The other one would be for server side applications such as CGIs which may take longer.
At the moment, I would estimate a relatively small amount of connections to be sufficient to launch a DoS against Apache as it comes in IPFire. Ultimately, tuning won't help here, if the offender is physically present in the GREEN or BLUE network. So, in the end, my timeout thought probably does not really matter... :-)
Thanks, and best regards, Peter Müller
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
What about when running openssl to generate a new key? That one times out for me.
I believe its purpose is to generate as many periods as possible. ;-)
On Apr 12, 2021, at 4:06 PM, Peter Müller peter.mueller@ipfire.org wrote:
Good evening Michael, good evening Leo,
@Peter: Would you be up for rewriting the apache configuration?
voila: https://patchwork.ipfire.org/project/ipfire/list/?series=1941
This configuration has been tested and audited using NSE, Nikto, and a bunch of other wonderful penetration testing tools. To my surprise, HTTP TRACE is mandatory in HTTP 1.1 nowadays, and clients can expect it to be enabled - I used to read the advice to keep it disabled, but that seems to be obsolete meanwhile.
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
Thanks, and best regards, Peter Müller
Hello,
Sorry for my late response. This is probably a little bit more urgent…
Our Apache configuration is here:
https://git.ipfire.org/?p=ipfire-2.x.git;a=tree;f=config/httpd;hb=HEAD
And it does not have any aggressive caching enabled.
The ETag header is precisely there for validating content without transferring it again. We probably should overhaul the entire apache configuration and come up with something that guarantees that we are using modern features of the browser and Apache. Currently the configuration is full of directives for MS Internet Explorer and Java-based browsers. We wouldn’t support any of them - not even sure if they exist any more.
@Peter: Would you be up for rewriting the apache configuration?
Best, -Michael
On 9 Apr 2021, at 18:45, Leo Hofmann hofmann@leo-andres.de wrote:
Hi,
I found that disabling the HTTP ETag header solved the problem for me. Are there any Cache-Control headers configured for these static files?
I'll change the CSS and submit a patch soon!
Leo
Am 09.04.2021 um 12:57 schrieb Michael Tremer:
Hello,
That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into.
Apart from that it works.
Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough?
-Michael
> On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote: > > Hello Michael, > > No, of course not, that looks terrible! > Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. > Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome. > > Best regards, > Leo > > Am 07.04.2021 um 23:31 schrieb Michael Tremer: >> Hello, >> >> Is this meant to look like this? >> >> >> >>> On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote: >>> >>> "makegraphbox" is modified to remove the old iframe method and output >>> a modern div container instead. >>> Graph errors are now returned, to be displayed by getrrdimage.cgi. >>> >>> entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility. >>> >>> Add cache control HTTP header to image output. >>> >>> Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> >>> --- >>> config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- >>> html/cgi-bin/entropy.cgi | 2 +- >>> html/cgi-bin/netovpnsrv.cgi | 2 +- >>> 3 files changed, 50 insertions(+), 40 deletions(-) >>> >>> diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl >>> index beddff032..cf4a30de3 100644 >>> --- a/config/cfgroot/graphs.pl >>> +++ b/config/cfgroot/graphs.pl >>> @@ -24,6 +24,7 @@ package Graphs; >>> >>> use strict; >>> use RRDs; >>> +use experimental 'smartmatch'; >>> >>> require '/var/ipfire/general-functions.pl'; >>> require "${General::swroot}/lang.pl"; >>> @@ -99,26 +100,35 @@ foreach (@sensorsdir){ >>> &General::readhash("${General::swroot}/sensors/settings", %sensorsettings); >>> >>> # Generate a nice box for selection of time range in graphs >>> -# this will generate a nice iframe for the cgi every klick for >>> -# the graph will be handled inside the iframe >>> +# this will generate a nice div box for the cgi every klick for >>> +# the graph will be handled by javascript >>> # 0 is the cgi refering to >>> # 1 is the graph name >>> -# 2 is the time range for the graph >>> -# 3 if given is the height of the iframe default if nothing is given >>> +# 2 is the time range for the graph (optional) >>> >>> sub makegraphbox { >>> -print "<center>"; >>> -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; >>> -print " - "; >>> -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; >>> -print " - "; >>> -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; >>> -print " - "; >>> -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; >>> -print " - "; >>> -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; >>> -print "<br></center>"; >>> -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; >>> +my ($origin, $name, $default_range) = @_; >>> + >>> +# Optional time range: Default to "day" unless otherwise specified >>> +$default_range = "day" unless ($default_range ~~ @time_ranges); >>> + >>> +print <<END; >>> +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> >>> +<ul> >>> +END >>> + >>> +# Print range select buttons >>> +foreach my $range (@time_ranges) { >>> +print <<END; >>> +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> >>> +END >>> +} >>> + >>> +print <<END; >>> +</ul> >>> +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> >>> +</div> >>> +END >>> } >>> >>> # Generate the CPU Graph for the current period of time for values given by >>> @@ -248,7 +258,7 @@ sub updatecpugraph { >>> >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Load Graph for the current period of time for values given by collecd >>> @@ -280,7 +290,7 @@ sub updateloadgraph { >>> "LINE1:load1".$color{"color18"}, >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Memory Graph for the current period of time for values given by collecd >>> @@ -336,7 +346,7 @@ sub updatememorygraph { >>> "GPRINT:freepct:LAST:%3.2lf%%\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Swap Graph for the current period of time for values given by collecd >>> @@ -385,7 +395,7 @@ sub updateswapgraph { >>> "GPRINT:freepct:LAST:%3.2lf%%\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Process Cpu Graph for the current period of time for values given by collecd >>> @@ -432,7 +442,7 @@ sub updateprocessescpugraph { >>> >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Process Memory Graph for the current period of time for values given by collecd >>> @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph { >>> >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Disk Graph for the current period of time for values given by collecd >>> @@ -522,7 +532,7 @@ sub updatediskgraph { >>> "GPRINT:write:LAST:%8.1lf %sBps\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Interface Graph for the current period of time for values given by collecd >>> @@ -561,7 +571,7 @@ sub updateifgraph { >>> "GPRINT:outgoing:LAST:%8.1lf %sBps\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>> } >>> >>> sub updatevpngraph { >>> @@ -598,7 +608,7 @@ sub updatevpngraph { >>> "GPRINT:outgoing:LAST:%8.1lf %sBps\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>> } >>> >>> sub updatevpnn2ngraph { >>> @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { >>> "GPRINT:compression_out:LAST:%8.1lf %sBps\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Firewall Graph for the current period of time for values given by collecd >>> @@ -716,7 +726,7 @@ sub updatefwhitsgraph { >>> "GPRINT:portscan:LAST:%8.1lf %sBps\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Line Quality Graph for the current period of time for values given by collecd >>> @@ -758,7 +768,7 @@ sub updatepinggraph { >>> "GPRINT:roundtrip:LAST:%3.2lf ms\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; >>> } >>> >>> sub updatewirelessgraph { >>> @@ -793,7 +803,7 @@ sub updatewirelessgraph { >>> "GPRINT:power:LAST:%5.1lf %sdBm\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors >>> @@ -827,7 +837,7 @@ sub updatehddgraph { >>> "GPRINT:temperature:LAST:%3.0lf °C\j", >>> ); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors >>> @@ -875,7 +885,7 @@ sub updatehwtempgraph { >>> >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors >>> @@ -922,7 +932,7 @@ sub updatehwfangraph { >>> >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors >>> @@ -969,7 +979,7 @@ sub updatehwvoltgraph { >>> >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; >>> } >>> >>> >>> @@ -1051,7 +1061,7 @@ sub updateqosgraph { >>> } >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors >>> @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph { >>> >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; >>> } >>> >>> # Generate the Thermal Zone Temp CPU Graph >>> @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph { >>> >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; >>> } >>> >>> >>> @@ -1174,7 +1184,7 @@ sub updateentropygraph { >>> RRDs::graph (@command); >>> $ERROR = RRDs::error; >>> >>> -print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; >>> +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; >>> } >>> >>> sub updateconntrackgraph { >>> @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { >>> RRDs::graph(@command); >>> $ERROR = RRDs::error; >>> >>> -print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; >>> +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; >>> } >>> diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi >>> index d7a9ca5d8..f8045db5a 100644 >>> --- a/html/cgi-bin/entropy.cgi >>> +++ b/html/cgi-bin/entropy.cgi >>> @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { >>> &Header::openbigbox('100%', 'left'); >>> >>> &Header::openbox('100%', 'center', $Lang::tr{'entropy'}); >>> -&Graphs::makegraphbox("entropy.cgi", "day"); >>> +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); >>> &Header::closebox(); >>> >>> # Check for hardware support. >>> diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi >>> index 77c69cddb..ab3548713 100755 >>> --- a/html/cgi-bin/netovpnsrv.cgi >>> +++ b/html/cgi-bin/netovpnsrv.cgi >>> @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ >>> if (@vpns || %ipsecgraphs) { >>> foreach my $name (sort keys %ipsecgraphs) { >>> &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); >>> -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); >>> +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); >>> &Header::closebox(); >>> } >>> >>> -- >>> 2.27.0.windows.1 >>> > <rrdimg-css.png>
Hello,
On 13 Apr 2021, at 16:47, Tom Rymes tom@rymes.net wrote:
Would it be possible to dump the key-generation task into the background in those instances and have the WUI report on the status? That way, the timeout does not have to be long enough for the entire process, just for however long it takes to submit the task for processing.
This is quite difficult to do because the CGI script would lose control of the forked process.
We no longer know the PID at the next call of the CGI script unless we write that to some temporary file system and have a wrapper script run that removed the temporary data after the process is done. It would come with a lot of overhead.
But I generally agree that we need a solution. Keys are getting longer and longer and a reasonable RSA key takes a long time to generate. Especially with some people using SBCs, there is no chance to generate a cryptographically secure key in reasonable time.
Kind of like Pakfire does, or even just submit the changes and have the WUI show that the process is still running if you, for example, navigate to the IPSec page, where the keys are displayed.
Pakfire is just launched in the background and we hope for the best. In the meantime we show the log. Not ideal, but the best we can do :)
-Michael
Tom
On Apr 13, 2021, at 11:24 AM, Peter Müller peter.mueller@ipfire.org wrote:
Hello Jon,
thanks for your reply.
Indeed, generating key files for OpenVPN or IPsec - and, worse, DH parameters for OpenVPN - was something I did not have had in mind yesterday. These can take ages indeed, especially on slower hardware. As far as I am aware, we are not there yet when it comes to ECC cryptography for both VPN subsystems.
In an ideal world, Apache would support two distinct types of timeouts: One for network interaction to the client, where 60 seconds would be absolutely satisfying. The other one would be for server side applications such as CGIs which may take longer.
At the moment, I would estimate a relatively small amount of connections to be sufficient to launch a DoS against Apache as it comes in IPFire. Ultimately, tuning won't help here, if the offender is physically present in the GREEN or BLUE network. So, in the end, my timeout thought probably does not really matter... :-)
Thanks, and best regards, Peter Müller
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
What about when running openssl to generate a new key? That one times out for me.
I believe its purpose is to generate as many periods as possible. ;-)
On Apr 12, 2021, at 4:06 PM, Peter Müller peter.mueller@ipfire.org wrote:
Good evening Michael, good evening Leo,
@Peter: Would you be up for rewriting the apache configuration?
voila: https://patchwork.ipfire.org/project/ipfire/list/?series=1941
This configuration has been tested and audited using NSE, Nikto, and a bunch of other wonderful penetration testing tools. To my surprise, HTTP TRACE is mandatory in HTTP 1.1 nowadays, and clients can expect it to be enabled - I used to read the advice to keep it disabled, but that seems to be obsolete meanwhile.
Is there any particular reason why we have a extremely long (5 minutes) timeout set? The Apache documentation recommends 60 seconds, and I cannot think of an application on IPFire taking five minutes to execute...
Thanks, and best regards, Peter Müller
Hello,
Sorry for my late response. This is probably a little bit more urgent…
Our Apache configuration is here:
https://git.ipfire.org/?p=ipfire-2.x.git;a=tree;f=config/httpd;hb=HEAD
And it does not have any aggressive caching enabled.
The ETag header is precisely there for validating content without transferring it again. We probably should overhaul the entire apache configuration and come up with something that guarantees that we are using modern features of the browser and Apache. Currently the configuration is full of directives for MS Internet Explorer and Java-based browsers. We wouldn’t support any of them - not even sure if they exist any more.
@Peter: Would you be up for rewriting the apache configuration?
Best, -Michael
On 9 Apr 2021, at 18:45, Leo Hofmann hofmann@leo-andres.de wrote:
Hi,
I found that disabling the HTTP ETag header solved the problem for me. Are there any Cache-Control headers configured for these static files?
I'll change the CSS and submit a patch soon!
Leo
Am 09.04.2021 um 12:57 schrieb Michael Tremer: > Hello, > > That was it. For some reason my browser did not validate the CSS file and used a cached version. This is probably something we should look into. > > Apart from that it works. > > Can we maybe change the background colour to something less yellow when a button is selected. Maybe just underlining the word is enough? > > -Michael > >> On 7 Apr 2021, at 23:18, Leo Hofmann hofmann@leo-andres.de wrote: >> >> Hello Michael, >> >> No, of course not, that looks terrible! >> Could you please check/CTRL+F5 the CSS file /themes/ipfire/include/css/style.css? Patch 2 of this series should have added ~30 lines at the end. >> Please have a look at the attached screenshot, there you can see how it is supposed to be. I have tested this with Firefox and Chrome. >> >> Best regards, >> Leo >> >> Am 07.04.2021 um 23:31 schrieb Michael Tremer: >>> Hello, >>> >>> Is this meant to look like this? >>> >>> >>> >>>> On 1 Apr 2021, at 14:35, Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> wrote: >>>> >>>> "makegraphbox" is modified to remove the old iframe method and output >>>> a modern div container instead. >>>> Graph errors are now returned, to be displayed by getrrdimage.cgi. >>>> >>>> entropy.cgi and netovpnsrv.cgi are modified to ensure compatibility. >>>> >>>> Add cache control HTTP header to image output. >>>> >>>> Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de mailto:hofmann@leo-andres.de> >>>> --- >>>> config/cfgroot/graphs.pl | 86 +++++++++++++++++++++---------------- >>>> html/cgi-bin/entropy.cgi | 2 +- >>>> html/cgi-bin/netovpnsrv.cgi | 2 +- >>>> 3 files changed, 50 insertions(+), 40 deletions(-) >>>> >>>> diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl >>>> index beddff032..cf4a30de3 100644 >>>> --- a/config/cfgroot/graphs.pl >>>> +++ b/config/cfgroot/graphs.pl >>>> @@ -24,6 +24,7 @@ package Graphs; >>>> >>>> use strict; >>>> use RRDs; >>>> +use experimental 'smartmatch'; >>>> >>>> require '/var/ipfire/general-functions.pl'; >>>> require "${General::swroot}/lang.pl"; >>>> @@ -99,26 +100,35 @@ foreach (@sensorsdir){ >>>> &General::readhash("${General::swroot}/sensors/settings", %sensorsettings); >>>> >>>> # Generate a nice box for selection of time range in graphs >>>> -# this will generate a nice iframe for the cgi every klick for >>>> -# the graph will be handled inside the iframe >>>> +# this will generate a nice div box for the cgi every klick for >>>> +# the graph will be handled by javascript >>>> # 0 is the cgi refering to >>>> # 1 is the graph name >>>> -# 2 is the time range for the graph >>>> -# 3 if given is the height of the iframe default if nothing is given >>>> +# 2 is the time range for the graph (optional) >>>> >>>> sub makegraphbox { >>>> -print "<center>"; >>>> -print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; >>>> -print " - "; >>>> -print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; >>>> -print " - "; >>>> -print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; >>>> -print " - "; >>>> -print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; >>>> -print " - "; >>>> -print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; >>>> -print "<br></center>"; >>>> -print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; >>>> +my ($origin, $name, $default_range) = @_; >>>> + >>>> +# Optional time range: Default to "day" unless otherwise specified >>>> +$default_range = "day" unless ($default_range ~~ @time_ranges); >>>> + >>>> +print <<END; >>>> +<div class="rrdimage" id="rrdimg-$name" data-origin="$origin" data-graph="$name" data-default-range="$default_range"> >>>> +<ul> >>>> +END >>>> + >>>> +# Print range select buttons >>>> +foreach my $range (@time_ranges) { >>>> +print <<END; >>>> +<li><button data-range="$range" onclick="rrdimage_selectRange(this)">$Lang::tr{$range}</button></li> >>>> +END >>>> +} >>>> + >>>> +print <<END; >>>> +</ul> >>>> +<img src="/cgi-bin/getrrdimage.cgi?origin=${origin}&graph=${name}&range=${default_range}" alt="$Lang::tr{'graph'} ($name)"> >>>> +</div> >>>> +END >>>> } >>>> >>>> # Generate the CPU Graph for the current period of time for values given by >>>> @@ -248,7 +258,7 @@ sub updatecpugraph { >>>> >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Load Graph for the current period of time for values given by collecd >>>> @@ -280,7 +290,7 @@ sub updateloadgraph { >>>> "LINE1:load1".$color{"color18"}, >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Memory Graph for the current period of time for values given by collecd >>>> @@ -336,7 +346,7 @@ sub updatememorygraph { >>>> "GPRINT:freepct:LAST:%3.2lf%%\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Swap Graph for the current period of time for values given by collecd >>>> @@ -385,7 +395,7 @@ sub updateswapgraph { >>>> "GPRINT:freepct:LAST:%3.2lf%%\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Process Cpu Graph for the current period of time for values given by collecd >>>> @@ -432,7 +442,7 @@ sub updateprocessescpugraph { >>>> >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Process Memory Graph for the current period of time for values given by collecd >>>> @@ -478,7 +488,7 @@ sub updateprocessesmemorygraph { >>>> >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Disk Graph for the current period of time for values given by collecd >>>> @@ -522,7 +532,7 @@ sub updatediskgraph { >>>> "GPRINT:write:LAST:%8.1lf %sBps\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Interface Graph for the current period of time for values given by collecd >>>> @@ -561,7 +571,7 @@ sub updateifgraph { >>>> "GPRINT:outgoing:LAST:%8.1lf %sBps\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> sub updatevpngraph { >>>> @@ -598,7 +608,7 @@ sub updatevpngraph { >>>> "GPRINT:outgoing:LAST:%8.1lf %sBps\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> sub updatevpnn2ngraph { >>>> @@ -661,7 +671,7 @@ sub updatevpnn2ngraph { >>>> "GPRINT:compression_out:LAST:%8.1lf %sBps\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Firewall Graph for the current period of time for values given by collecd >>>> @@ -716,7 +726,7 @@ sub updatefwhitsgraph { >>>> "GPRINT:portscan:LAST:%8.1lf %sBps\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Line Quality Graph for the current period of time for values given by collecd >>>> @@ -758,7 +768,7 @@ sub updatepinggraph { >>>> "GPRINT:roundtrip:LAST:%3.2lf ms\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> sub updatewirelessgraph { >>>> @@ -793,7 +803,7 @@ sub updatewirelessgraph { >>>> "GPRINT:power:LAST:%5.1lf %sdBm\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors >>>> @@ -827,7 +837,7 @@ sub updatehddgraph { >>>> "GPRINT:temperature:LAST:%3.0lf °C\j", >>>> ); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors >>>> @@ -875,7 +885,7 @@ sub updatehwtempgraph { >>>> >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors >>>> @@ -922,7 +932,7 @@ sub updatehwfangraph { >>>> >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors >>>> @@ -969,7 +979,7 @@ sub updatehwvoltgraph { >>>> >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> >>>> @@ -1051,7 +1061,7 @@ sub updateqosgraph { >>>> } >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors >>>> @@ -1090,7 +1100,7 @@ sub updatecpufreqgraph { >>>> >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> # Generate the Thermal Zone Temp CPU Graph >>>> @@ -1129,7 +1139,7 @@ sub updatethermaltempgraph { >>>> >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> -print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> >>>> @@ -1174,7 +1184,7 @@ sub updateentropygraph { >>>> RRDs::graph (@command); >>>> $ERROR = RRDs::error; >>>> >>>> -print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; >>>> +return "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; >>>> } >>>> >>>> sub updateconntrackgraph { >>>> @@ -1202,5 +1212,5 @@ sub updateconntrackgraph { >>>> RRDs::graph(@command); >>>> $ERROR = RRDs::error; >>>> >>>> -print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; >>>> +return "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; >>>> } >>>> diff --git a/html/cgi-bin/entropy.cgi b/html/cgi-bin/entropy.cgi >>>> index d7a9ca5d8..f8045db5a 100644 >>>> --- a/html/cgi-bin/entropy.cgi >>>> +++ b/html/cgi-bin/entropy.cgi >>>> @@ -45,7 +45,7 @@ if ( $querry[0] ne~ "") { >>>> &Header::openbigbox('100%', 'left'); >>>> >>>> &Header::openbox('100%', 'center', $Lang::tr{'entropy'}); >>>> -&Graphs::makegraphbox("entropy.cgi", "day"); >>>> +&Graphs::makegraphbox("entropy.cgi", "entropy", "day"); >>>> &Header::closebox(); >>>> >>>> # Check for hardware support. >>>> diff --git a/html/cgi-bin/netovpnsrv.cgi b/html/cgi-bin/netovpnsrv.cgi >>>> index 77c69cddb..ab3548713 100755 >>>> --- a/html/cgi-bin/netovpnsrv.cgi >>>> +++ b/html/cgi-bin/netovpnsrv.cgi >>>> @@ -75,7 +75,7 @@ if ( $querry[0] ne ""){ >>>> if (@vpns || %ipsecgraphs) { >>>> foreach my $name (sort keys %ipsecgraphs) { >>>> &Header::openbox('100%', 'center', "$Lang::tr{'ipsec connection'}: $name"); >>>> -&Graphs::makegraphbox("netovpnsrv.cgi", $ipsecgraphs{$name}, "day"); >>>> +&Graphs::makegraphbox("netovpnsrv.cgi", "ipsec-$ipsecgraphs{$name}", "day"); >>>> &Header::closebox(); >>>> } >>>> >>>> -- >>>> 2.27.0.windows.1 >>>> >> <rrdimg-css.png>
Hi all,
this series of patches is a follow-up to this discussion: https://lists.ipfire.org/pipermail/development/2021-March/009523.html
I decided to write a new CGI which handles the graph image generation (png). This allowed me to add new features and remove a lot of uneccessary parameter handling from the other CGIs. I think this is in presentable form now. But there are still some issues I'd like to hear your opinion on:
- Because I have collected all the graph functions from the CGIs, there is now a very long if-elseif chain in getrrdimage.cgi. I tried my best to keep this as readable as possible. But I'd be happy to rewrite that if someone knows a better method.
- My test system doesn't have any hardware sensors or IPsec connections. I'm pretty sure that these graphs work but I can't test them.
- getrrdimage.cgi redirects graphs it can't generate to ensure compatibility with addons. Is that necessary?
Happy holidays! Leo
Hi,
I didn't look at your patch in depth 'til now. But the integration of the errors from RRDtool looks good. Thanks for taking my suggestion in the discussion. I wasn't able to look at this since then, but it seems to be my solution I've tried some time ago on my system. Could you test it with some errors of rrdgraph()?
Regards, Bernhard
Gesendet: Donnerstag, 01. April 2021 um 15:36 Uhr Von: "Leo Hofmann" hofmann@leo-andres.de An: development@lists.ipfire.org Betreff: Re: [PATCH 1/3] rrdimage: Add scripts for new graph display method
Hi all,
this series of patches is a follow-up to this discussion: https://lists.ipfire.org/pipermail/development/2021-March/009523.html
I decided to write a new CGI which handles the graph image generation (png). This allowed me to add new features and remove a lot of uneccessary parameter handling from the other CGIs. I think this is in presentable form now. But there are still some issues I'd like to hear your opinion on:
Because I have collected all the graph functions from the CGIs, there is now a very long if-elseif chain in getrrdimage.cgi. I tried my best to keep this as readable as possible. But I'd be happy to rewrite that if someone knows a better method.
My test system doesn't have any hardware sensors or IPsec connections. I'm pretty sure that these graphs work but I can't test them.
getrrdimage.cgi redirects graphs it can't generate to ensure compatibility with addons. Is that necessary?
Happy holidays! Leo
Hi Bernhard,
yes I liked your idea of having the error message directly visible in the diagram! I deliberately put a typo in the RRD command. You can see the error message in the attached screenshot.
Best regards, Leo
Am 01.04.2021 um 15:58 schrieb Bernhard Bitsch:
Hi,
I didn't look at your patch in depth 'til now. But the integration of the errors from RRDtool looks good. Thanks for taking my suggestion in the discussion. I wasn't able to look at this since then, but it seems to be my solution I've tried some time ago on my system. Could you test it with some errors of rrdgraph()?
Regards, Bernhard
Gesendet: Donnerstag, 01. April 2021 um 15:36 Uhr Von: "Leo Hofmann" hofmann@leo-andres.de An: development@lists.ipfire.org Betreff: Re: [PATCH 1/3] rrdimage: Add scripts for new graph display method
Hi all,
this series of patches is a follow-up to this discussion: https://lists.ipfire.org/pipermail/development/2021-March/009523.html
I decided to write a new CGI which handles the graph image generation (png). This allowed me to add new features and remove a lot of uneccessary parameter handling from the other CGIs. I think this is in presentable form now. But there are still some issues I'd like to hear your opinion on:
Because I have collected all the graph functions from the CGIs, there is now a very long if-elseif chain in getrrdimage.cgi. I tried my best to keep this as readable as possible. But I'd be happy to rewrite that if someone knows a better method.
My test system doesn't have any hardware sensors or IPsec connections. I'm pretty sure that these graphs work but I can't test them.
getrrdimage.cgi redirects graphs it can't generate to ensure compatibility with addons. Is that necessary?
Happy holidays! Leo
Hi Leo,
yes that's exactly what I thought of. The idea was inspired by post coming up sometimes in the community about empty graphs. Mostly just a guessing about the reason gives the solution more or less quickly/slow. Maybe the real error messages leads quicker to the issue.
Regards, Bernhard
Gesendet: Donnerstag, 01. April 2021 um 16:18 Uhr Von: "Leo Hofmann" hofmann@leo-andres.de An: "Bernhard Bitsch" Bernhard.Bitsch@gmx.de Cc: development@lists.ipfire.org Betreff: Re: [PATCH 1/3] rrdimage: Add scripts for new graph display method
Hi Bernhard,
yes I liked your idea of having the error message directly visible in the diagram! I deliberately put a typo in the RRD command. You can see the error message in the attached screenshot.
Best regards, Leo
Am 01.04.2021 um 15:58 schrieb Bernhard Bitsch:
Hi,
I didn't look at your patch in depth 'til now. But the integration of the errors from RRDtool looks good. Thanks for taking my suggestion in the discussion. I wasn't able to look at this since then, but it seems to be my solution I've tried some time ago on my system. Could you test it with some errors of rrdgraph()?
Regards, Bernhard
Gesendet: Donnerstag, 01. April 2021 um 15:36 Uhr Von: "Leo Hofmann" hofmann@leo-andres.de An: development@lists.ipfire.org Betreff: Re: [PATCH 1/3] rrdimage: Add scripts for new graph display method
Hi all,
this series of patches is a follow-up to this discussion: https://lists.ipfire.org/pipermail/development/2021-March/009523.html
I decided to write a new CGI which handles the graph image generation (png). This allowed me to add new features and remove a lot of uneccessary parameter handling from the other CGIs. I think this is in presentable form now. But there are still some issues I'd like to hear your opinion on:
Because I have collected all the graph functions from the CGIs, there is now a very long if-elseif chain in getrrdimage.cgi. I tried my best to keep this as readable as possible. But I'd be happy to rewrite that if someone knows a better method.
My test system doesn't have any hardware sensors or IPsec connections. I'm pretty sure that these graphs work but I can't test them.
getrrdimage.cgi redirects graphs it can't generate to ensure compatibility with addons. Is that necessary?
Happy holidays! Leo