+#!/usr/bin/perl
# Generate Graphs exported from Makegraphs to minimize system load an only generate the Graphs when displayed
# This is part of the IPFire Firewall
+
package Graphs;
use strict;
my $period = $_[0];
RRDs::graph ("$graphs/cpu-$period.png",
- "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
RRDs::graph ("$graphs/load-$period.png",
"--start", "-1$period", "-aPNG",
- "-w 600", "-h 100", "-i", "-z", "-l 0", "-r", "--alt-y-grid",
+ "-w 600", "-h 100", "-i", "-z", "-W www.ipfire.org", "-l 0", "-r", "--alt-y-grid",
"-t Load Average",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
my $period = $_[0];
RRDs::graph ("$graphs/memory-$period.png",
- "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
print "Error in RRD::graph for mem: $ERROR\n" if $ERROR;
RRDs::graph ("$graphs/swap-$period.png",
- "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
my $disk = $_[1];
RRDs::graph ("$graphs/disk-$disk-$period.png",
- "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
my $period = $_[1];
RRDs::graph ("$graphs/$interface-$period.png",
- "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
"GPRINT:incoming:MIN:$Lang::tr{'in'}\\:%8.3lf %sBps",
"GPRINT:incoming:LAST:$Lang::tr{'in'}\\:%8.3lf %sBps\\j",
"GPRINT:outgoing:MAX:$Lang::tr{'out'}\\:%8.3lf %sBps",
- "GPRINT:outgoing:AVERAGE:$$Lang::tr{'out'}\\:%8.3lf %sBps",
+ "GPRINT:outgoing:AVERAGE:$Lang::tr{'out'}\\:%8.3lf %sBps",
"GPRINT:outgoing:MIN:$Lang::tr{'out'}\\:%8.3lf %sBps",
"GPRINT:outgoing:LAST:$Lang::tr{'out'}\\:%8.3lf %sBps\\j");
$ERROR = RRDs::error;
my $period = $_[0];
RRDs::graph ("$graphs/firewallhits-$period-area.png",
- "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
sub updatelqgraph {
my $period = $_[0];
RRDs::graph ("$graphs/lq-$period.png",
- "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
"-t $Lang::tr{'linkq'} ($Lang::tr{'graph per'} $Lang::tr{$period})",
"--lazy",
my $period = $_[1];
RRDs::graph ("$graphs/hddtemp-$disk-$period.png",
- "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
my $count = "11";
@args = ("$graphs/mbmon-$type-$period.png",
- "--start", "-1$period", "-aPNG", "-i", "-z",
+ "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
my $period = $_[0];
my $count = "11";
- @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
+ @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
my $period = $_[0];
my $count = "11";
- @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z",
+ @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 100", "--alt-autoscale",
"--color", "SHADEA".$color{"color19"},
"--color", "SHADEB".$color{"color19"},
$ERROR = RRDs::error;
print("Error in RRD::graph for temp: $ERROR\n")if $ERROR;
}
+
+sub overviewgraph {
+
+ my $period = $_[0];
+ my $periodstring;
+ my $description;
+ my %qossettings = ();
+ &General::readhash("${General::swroot}/qos/settings", \%qossettings);
+ my $classentry = "";
+ my @classes = ();
+ my @classline = ();
+ my $classfile = "/var/ipfire/qos/classes";
+
+ $qossettings{'DEV'} = $_[1];
+ if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {
+ $qossettings{'CLASSPRFX'} = '1';
+ } else {
+ $qossettings{'CLASSPRFX'} = '2';
+ }
+
+ if ( $period ne '3240' ){ $periodstring = "-1$period";}else{ $periodstring = "-".$period;}
+ if ( $period ne '3240' ){ $description = "-t $Lang::tr{'Utilization on'} ($qossettings{'DEV'}) ($Lang::tr{'graph per'} $Lang::tr{$period})";}else{ $description = "-t $Lang::tr{'Utilization on'} ($qossettings{'DEV'})";}
+
+ my $ERROR="";
+ my $count="1";
+ my $color="#000000";
+ my @command=("/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'DEV'}-$period.png",
+ "--start", $periodstring, "-aPNG", "-i", "-z", "-W www.ipfire.org",
+ "--alt-y-grid", "-w 600", "-h 150", "-r",
+ "--color", "SHADEA".$color{"color19"},
+ "--color", "SHADEB".$color{"color19"},
+ "--color", "BACK".$color{"color21"},
+ "COMMENT:$Lang::tr{'caption'}\\t\\t\\t\\t ",
+ "COMMENT:$Lang::tr{'maximal'}",
+ "COMMENT:$Lang::tr{'average'}",
+ "COMMENT:$Lang::tr{'minimal'}",
+ "COMMENT:$Lang::tr{'current'}\\j",
+ $description
+ );
+ open( FILE, "< $classfile" ) or die "Unable to read $classfile";
+ @classes = <FILE>;
+ close FILE;
+ foreach $classentry (sort @classes)
+ {
+ @classline = split( /\;/, $classentry );
+ if ( $classline[0] eq $qossettings{'DEV'} )
+ {
+ $color=random_hex_color(6);
+ push(@command, "DEF:$classline[1]=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE");
+
+ if ($count eq "1") {
+ push(@command, "AREA:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8]));
+ } else {
+ push(@command, "STACK:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8]));
+
+ }
+ push(@command, "GPRINT:$classline[1]:MAX:%5.2lf");
+ push(@command, "GPRINT:$classline[1]:AVERAGE:%5.2lf");
+ push(@command, "GPRINT:$classline[1]:MIN:%5.2lf");
+ push(@command, "GPRINT:$classline[1]:LAST:%5.2lf\\j");
+ $count++;
+ }
+ }
+ RRDs::graph (@command);
+ $ERROR = RRDs::error;
+ print "$ERROR";
+}
+
+sub random_hex_color {
+ my $size = shift;
+ $size = 6 if $size !~ /^3|6$/;
+ my @hex = ( 0 .. 9, 'a' .. 'f' );
+ my @color;
+ push @color, @hex[rand(@hex)] for 1 .. $size;
+ return join('', '#', @color);
+}