]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - config/cfgroot/graphs.pl
Qos Service Graphen zeigen jetzt auch Werte
[ipfire-2.x.git] / config / cfgroot / graphs.pl
index 99beaf7b52908cc463c0b11aec2bade0065c65f7..9d5d9cec66d62768b287b4b866f567c8a2e9c997 100644 (file)
@@ -1,6 +1,8 @@
+#!/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;
@@ -51,7 +53,7 @@ sub updatecpugraph {
         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"},
@@ -107,7 +109,7 @@ sub updateloadgraph {
 
         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"},
@@ -131,7 +133,7 @@ sub updatememgraph {
         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"},
@@ -183,7 +185,7 @@ sub updatememgraph {
         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"},
@@ -218,7 +220,7 @@ sub updatediskgraph {
         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"},
@@ -233,7 +235,7 @@ sub updatediskgraph {
         "COMMENT:$Lang::tr{'average'}",
         "COMMENT:$Lang::tr{'current'}\\j",
         "GPRINT:read:MAX:$Lang::tr{'read sectors'}\\:%8.0lf",
-        "GPRINT:read:AVERAGE:$$Lang::tr{'read sectors'}\\:%8.0lf",
+        "GPRINT:read:AVERAGE:$Lang::tr{'read sectors'}\\:%8.0lf",
         "GPRINT:read:LAST:$Lang::tr{'read sectors'}\\:%8.0lf\\j",
         "GPRINT:write:MAX:$Lang::tr{'written sectors'}\\:%8.0lf",
         "GPRINT:write:AVERAGE:$Lang::tr{'written sectors'}\\:%8.0lf",
@@ -247,7 +249,7 @@ sub updateifgraph {
   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"},
@@ -268,7 +270,7 @@ sub updateifgraph {
   "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;
@@ -279,7 +281,7 @@ sub updatefwhitsgraph {
   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"},
@@ -309,7 +311,7 @@ sub updatefwhitsgraph {
 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", 
@@ -356,7 +358,7 @@ sub updatehddgraph {
   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"},
@@ -384,7 +386,7 @@ sub updatetempgraph
   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"},
@@ -425,7 +427,7 @@ sub updatefangraph
   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"},
@@ -466,7 +468,7 @@ sub updatevoltgraph
   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"},
@@ -502,3 +504,79 @@ sub updatevoltgraph
     $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);
+}