]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
Fixed maniacs files (mail has convertet to "dos")
authorArne Fitzenreiter <arne_f@ipfire.org>
Thu, 29 May 2008 08:18:04 +0000 (10:18 +0200)
committerArne Fitzenreiter <arne_f@ipfire.org>
Thu, 29 May 2008 08:18:04 +0000 (10:18 +0200)
config/cfgroot/graphs.pl
html/cgi-bin/hardwaregraphs.cgi

index 8ee97a5b7771c34344ea23bcb52a76108776cd66..1c68d1ecdae170fe53c44a2def140bb5d67194af 100644 (file)
-#!/usr/bin/perl\r
-# Generate Graphs exported from Makegraphs to minimize system load an only generate the Graphs when displayed\r
-# This is part of the IPFire Firewall\r
-\r
-\r
-package Graphs;\r
-\r
-use strict;\r
-use RRDs;\r
-\r
-require '/var/ipfire/general-functions.pl';\r
-require "${General::swroot}/lang.pl";\r
-require "${General::swroot}/header.pl";\r
-\r
-my $ERROR;\r
-my $rrdlog = "/var/log/rrd";\r
-my $graphs = "/srv/web/ipfire/html/graphs";\r
-$ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";\r
-\r
-# Read the global settings files to get the current theme and after this load\r
-# colors for this theme\r
-\r
-my %color = ();\r
-my %mainsettings = ();\r
-my %sensorsettings = ();\r
-&General::readhash("${General::swroot}/main/settings", \%mainsettings);\r
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);\r
-\r
-\r
-# If the collection deamon is working and collecting lm_sensors data there will be\r
-# some data source named after a common scheme, with the sensorssettingsfile\r
-# the user is able to deactivate some of this parameters, in case not to show\r
-# false collected value´s may be disable. The user has the ability to enter\r
-# custom graph names in order to change temp0 to cpu or motherboad\r
-\r
-my $key;\r
-my $value;\r
-my @args = ();\r
-my $count = 0;\r
-my @sensorsgraphs = ();\r
-my @processesgraph = `ls -dA $rrdlog/collectd/localhost/processes-*/`;\r
-my @sensorsdir = `ls -dA $rrdlog/collectd/localhost/sensors-*/`;\r
-foreach (@sensorsdir)\r
-{\r
-       chomp($_);chop($_);\r
-       foreach (`ls $_/*`){\r
-               chomp($_);\r
-               push(@sensorsgraphs,$_);\r
-               $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;\r
-               my $label = $2.$3;$label=~ s/-//g;\r
-               $sensorsettings{'LABEL-'.$label}="$label";\r
-               $sensorsettings{'LINE-'.$label}="checked";\r
-       }\r
-}\r
-\r
-&General::readhash("${General::swroot}/sensors/settings", \%sensorsettings);\r
-use Encode 'from_to';\r
-\r
-my %tr=();\r
-if ((${Lang::language} eq 'el') ||\r
-    (${Lang::language} eq 'fa') ||\r
-    (${Lang::language} eq 'ru') ||\r
-    (${Lang::language} eq 'th') ||\r
-    (${Lang::language} eq 'vi') ||\r
-    (${Lang::language} eq 'zh') ||\r
-    (${Lang::language} eq 'zt')) {\r
-        eval `/bin/cat "${General::swroot}/langs/en.pl"`;\r
-} else {\r
-        %tr=%Lang::tr;          # use translated version for other languages\r
-}\r
-\r
-# Generate the CPU Graph for the current period of time for values given by\r
-# collectd atm only cpu average is displayed and only 1 or 2 cpu´s is working\r
-\r
-sub updatecpugraph {\r
-        my $period    = $_[0];\r
-                               my @command = ("$graphs/cpu-$period.png",\r
-        "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}",\r
-        "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r",\r
-        "--color", "SHADEA".$color{"color19"},\r
-        "--color", "SHADEB".$color{"color19"},\r
-        "--color", "BACK".$color{"color21"},\r
-        "-t $Lang::tr{'cpu usage per'} $Lang::tr{$period}");\r
-\r
-        if ( -e "$rrdlog/collectd/localhost/cpu-1/" ){\r
-        push(@command,"DEF:iowait0=$rrdlog/collectd/localhost/cpu-0/cpu-wait.rrd:value:AVERAGE",\r
-                               "DEF:nice0=$rrdlog/collectd/localhost/cpu-0/cpu-nice.rrd:value:AVERAGE",\r
-                               "DEF:interrupt0=$rrdlog/collectd/localhost/cpu-0/cpu-interrupt.rrd:value:AVERAGE",\r
-                               "DEF:steal0=$rrdlog/collectd/localhost/cpu-0/cpu-steal.rrd:value:AVERAGE",\r
-                               "DEF:user0=$rrdlog/collectd/localhost/cpu-0/cpu-user.rrd:value:AVERAGE",\r
-                               "DEF:system0=$rrdlog/collectd/localhost/cpu-0/cpu-system.rrd:value:AVERAGE",\r
-                               "DEF:idle0=$rrdlog/collectd/localhost/cpu-0/cpu-idle.rrd:value:AVERAGE",\r
-                               "DEF:irq0=$rrdlog/collectd/localhost/cpu-0/cpu-softirq.rrd:value:AVERAGE");\r
-        push(@command,"DEF:iowait1=$rrdlog/collectd/localhost/cpu-1/cpu-wait.rrd:value:AVERAGE",\r
-                               "DEF:nice1=$rrdlog/collectd/localhost/cpu-1/cpu-nice.rrd:value:AVERAGE",\r
-                               "DEF:interrupt1=$rrdlog/collectd/localhost/cpu-1/cpu-interrupt.rrd:value:AVERAGE",\r
-                               "DEF:steal1=$rrdlog/collectd/localhost/cpu-1/cpu-steal.rrd:value:AVERAGE",\r
-                               "DEF:user1=$rrdlog/collectd/localhost/cpu-1/cpu-user.rrd:value:AVERAGE",\r
-                               "DEF:system1=$rrdlog/collectd/localhost/cpu-1/cpu-system.rrd:value:AVERAGE",\r
-                               "DEF:idle1=$rrdlog/collectd/localhost/cpu-1/cpu-idle.rrd:value:AVERAGE",\r
-                               "DEF:irq1=$rrdlog/collectd/localhost/cpu-1/cpu-softirq.rrd:value:AVERAGE");\r
-        push(@command,"CDEF:user=user0,user1,+",\r
-                               "CDEF:nice=nice0,nice1,+",\r
-                               "CDEF:interrupt=interrupt0,interrupt1,+",\r
-                               "CDEF:steal=steal0,steal1,+",\r
-                               "CDEF:system=system0,system1,+",\r
-                               "CDEF:idle=idle0,idle1,+",\r
-                               "CDEF:iowait=iowait0,iowait1,+",\r
-                               "CDEF:irq=irq0,irq1,+");\r
-                               }\r
-        else {\r
-        push(@command,"DEF:iowait=$rrdlog/collectd/localhost/cpu-0/cpu-wait.rrd:value:AVERAGE",\r
-                               "DEF:nice=$rrdlog/collectd/localhost/cpu-0/cpu-nice.rrd:value:AVERAGE",\r
-                               "DEF:interrupt=$rrdlog/collectd/localhost/cpu-0/cpu-interrupt.rrd:value:AVERAGE",\r
-                               "DEF:steal=$rrdlog/collectd/localhost/cpu-0/cpu-steal.rrd:value:AVERAGE",\r
-                               "DEF:user=$rrdlog/collectd/localhost/cpu-0/cpu-user.rrd:value:AVERAGE",\r
-                               "DEF:system=$rrdlog/collectd/localhost/cpu-0/cpu-system.rrd:value:AVERAGE",\r
-                               "DEF:idle=$rrdlog/collectd/localhost/cpu-0/cpu-idle.rrd:value:AVERAGE",\r
-                               "DEF:irq=$rrdlog/collectd/localhost/cpu-0/cpu-softirq.rrd:value:AVERAGE");\r
-                               }\r
-                               push(@command,"CDEF:total=user,system,idle,iowait,irq,nice,interrupt,steal,+,+,+,+,+,+,+",\r
-                               "CDEF:userpct=100,user,total,/,*",\r
-                               "CDEF:nicepct=100,nice,total,/,*",\r
-                               "CDEF:interruptpct=100,interrupt,total,/,*",\r
-                               "CDEF:stealpct=100,steal,total,/,*",\r
-                               "CDEF:systempct=100,system,total,/,*",\r
-                               "CDEF:idlepct=100,idle,total,/,*",\r
-                               "CDEF:iowaitpct=100,iowait,total,/,*",\r
-                               "CDEF:irqpct=100,irq,total,/,*",\r
-                               "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",\r
-        "AREA:iowaitpct".$color{"color14"}.":".sprintf("%-25s",$Lang::tr{'cpu iowait usage'}),\r
-        "GPRINT:iowaitpct:MAX:%3.2lf%%",\r
-        "GPRINT:iowaitpct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:iowaitpct:MIN:%3.2lf%%",\r
-        "GPRINT:iowaitpct:LAST:%3.2lf%%\\j",\r
-        "STACK:irqpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr{'cpu irq usage'}),\r
-        "GPRINT:irqpct:MAX:%3.2lf%%",\r
-        "GPRINT:irqpct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:irqpct:MIN:%3.2lf%%",\r
-        "GPRINT:irqpct:LAST:%3.2lf%%\\j",\r
-        "STACK:nicepct".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr{'cpu nice usage'}),\r
-        "GPRINT:nicepct:MAX:%3.2lf%%",\r
-        "GPRINT:nicepct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:nicepct:MIN:%3.2lf%%",\r
-        "GPRINT:nicepct:LAST:%3.2lf%%\\j",\r
-        "STACK:interruptpct".$color{"color15"}."A0:".sprintf("%-25s",$Lang::tr{'cpu interrupt usage'}),\r
-        "GPRINT:interruptpct:MAX:%3.2lf%%",\r
-        "GPRINT:interruptpct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:interruptpct:MIN:%3.2lf%%",\r
-        "GPRINT:interruptpct:LAST:%3.2lf%%\\j",\r
-        "STACK:stealpct".$color{"color18"}."A0:".sprintf("%-25s",$Lang::tr{'cpu steal usage'}),\r
-        "GPRINT:stealpct:MAX:%3.2lf%%",\r
-        "GPRINT:stealpct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:stealpct:MIN:%3.2lf%%",\r
-        "GPRINT:stealpct:LAST:%3.2lf%%\\j",\r
-        "STACK:userpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'cpu user usage'}),\r
-        "GPRINT:userpct:MAX:%3.2lf%%",\r
-        "GPRINT:userpct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:userpct:MIN:%3.2lf%%",\r
-        "GPRINT:userpct:LAST:%3.2lf%%\\j",\r
-        "STACK:systempct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'cpu system usage'}),\r
-        "GPRINT:systempct:MAX:%3.2lf%%",\r
-        "GPRINT:systempct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:systempct:MIN:%3.2lf%%",\r
-        "GPRINT:systempct:LAST:%3.2lf%%\\j",\r
-        "STACK:idlepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'cpu idle usage'}),\r
-        "GPRINT:idlepct:MAX:%3.2lf%%",\r
-        "GPRINT:idlepct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:idlepct:MIN:%3.2lf%%",\r
-        "GPRINT:idlepct:LAST:%3.2lf%%\\j");\r
-\r
-                               RRDs::graph (@command);\r
-        $ERROR = RRDs::error;\r
-        print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR;\r
-}\r
-\r
-# Generate the Load Graph for the current period of time for values given by collecd\r
-\r
-sub updateloadgraph {\r
-        my $period    = $_[0];\r
-\r
-        RRDs::graph ("$graphs/load-$period.png",\r
-        "--start", "-1$period", "-aPNG",\r
-        "-w 600", "-h 125", "-i", "-z", "-W www.ipfire.org", "-l 0", "-r", "--alt-y-grid",\r
-        "-t Load Average $Lang::tr{'graph per'} $Lang::tr{$period}", "-v $Lang::tr{'processes'}",\r
-        "--color", "SHADEA".$color{"color19"},\r
-        "--color", "SHADEB".$color{"color19"},\r
-        "--color", "BACK".$color{"color21"},\r
-        "DEF:load1=$rrdlog/collectd/localhost/load/load.rrd:shortterm:AVERAGE",\r
-        "DEF:load5=$rrdlog/collectd/localhost/load/load.rrd:midterm:AVERAGE",\r
-        "DEF:load15=$rrdlog/collectd/localhost/load/load.rrd:longterm:AVERAGE",\r
-        "AREA:load1".$color{"color13"}."A0:1 Minute:",\r
-        "GPRINT:load1:LAST:%5.2lf",\r
-        "AREA:load5".$color{"color18"}."A0:5 Minuten:",\r
-        "GPRINT:load5:LAST:%5.2lf",\r
-        "AREA:load15".$color{"color14"}."A0:15 Minuten:",\r
-        "GPRINT:load15:LAST:%5.2lf\\j",\r
-        "LINE1:load5".$color{"color13"},\r
-        "LINE1:load1".$color{"color18"});\r
-        $ERROR = RRDs::error;\r
-        print "Error in RRD::graph for load: $ERROR\n" if $ERROR;\r
-}\r
-\r
-# Generate the Memory and Swap Graph for the current period of time for values given by collecd\r
-\r
-sub updatememgraph {\r
-        my $period    = $_[0];\r
-\r
-        RRDs::graph ("$graphs/memory-$period.png",\r
-        "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}",\r
-        "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r",\r
-        "--color", "SHADEA".$color{"color19"},\r
-        "--color", "SHADEB".$color{"color19"},\r
-        "--color", "BACK".$color{"color21"},\r
-        "-t $Lang::tr{'memory usage per'} $Lang::tr{$period}",\r
-        "DEF:used=$rrdlog/collectd/localhost/memory/memory-used.rrd:value:AVERAGE",\r
-        "DEF:free=$rrdlog/collectd/localhost/memory/memory-free.rrd:value:AVERAGE",\r
-        "DEF:buffer=$rrdlog/collectd/localhost/memory/memory-buffered.rrd:value:AVERAGE",\r
-        "DEF:cache=$rrdlog/collectd/localhost/memory/memory-cached.rrd:value:AVERAGE",\r
-        "CDEF:total=used,free,cache,buffer,+,+,+",\r
-        "CDEF:usedpct=used,total,/,100,*",\r
-        "CDEF:bufferpct=buffer,total,/,100,*",\r
-        "CDEF:cachepct=cache,total,/,100,*",\r
-        "CDEF:freepct=free,total,/,100,*",\r
-                               "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",\r
-        "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'used memory'}),\r
-        "GPRINT:usedpct:MAX:%3.2lf%%",\r
-        "GPRINT:usedpct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:usedpct:MIN:%3.2lf%%",\r
-        "GPRINT:usedpct:LAST:%3.2lf%%\\j",\r
-        "STACK:bufferpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr{'buffered memory'}),\r
-        "GPRINT:bufferpct:MAX:%3.2lf%%",\r
-        "GPRINT:bufferpct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:bufferpct:MIN:%3.2lf%%",\r
-        "GPRINT:bufferpct:LAST:%3.2lf%%\\j",\r
-        "STACK:cachepct".$color{"color14"}."A0:".sprintf("%-25s",$Lang::tr{'cached memory'}),\r
-        "GPRINT:cachepct:MAX:%3.2lf%%",\r
-        "GPRINT:cachepct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:cachepct:MIN:%3.2lf%%",\r
-        "GPRINT:cachepct:LAST:%3.2lf%%\\j",\r
-        "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'free memory'}),\r
-        "GPRINT:freepct:MAX:%3.2lf%%",\r
-        "GPRINT:freepct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:freepct:MIN:%3.2lf%%",\r
-        "GPRINT:freepct:LAST:%3.2lf%%\\j");\r
-        $ERROR = RRDs::error;\r
-        print "Error in RRD::graph for mem: $ERROR\n" if $ERROR;\r
-\r
-        RRDs::graph ("$graphs/swap-$period.png",\r
-        "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}",\r
-        "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r",\r
-        "--color", "SHADEA".$color{"color19"},\r
-        "--color", "SHADEB".$color{"color19"},\r
-        "--color", "BACK".$color{"color21"},\r
-        "-t $Lang::tr{'swap usage per'} $Lang::tr{$period}",\r
-        "DEF:used=$rrdlog/collectd/localhost/swap/swap-used.rrd:value:AVERAGE",\r
-        "DEF:free=$rrdlog/collectd/localhost/swap/swap-free.rrd:value:AVERAGE",\r
-                               "DEF:cached=$rrdlog/collectd/localhost/swap/swap-cached.rrd:value:AVERAGE",\r
-        "CDEF:total=used,free,cached,+,+",\r
-        "CDEF:usedpct=100,used,total,/,*",\r
-        "CDEF:freepct=100,free,total,/,*",\r
-        "CDEF:cachedpct=100,cached,total,/,*",\r
-                               "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",\r
-        "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'used swap'}),\r
-        "GPRINT:usedpct:MAX:%3.2lf%%",\r
-        "GPRINT:usedpct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:usedpct:MIN:%3.2lf%%",\r
-        "GPRINT:usedpct:LAST:%3.2lf%%\\j",\r
-        "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'free swap'}),\r
-        "GPRINT:freepct:MAX:%3.2lf%%",\r
-        "GPRINT:freepct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:freepct:MIN:%3.2lf%%",\r
-        "GPRINT:freepct:LAST:%3.2lf%%\\j",\r
-        "STACK:cachedpct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'cached swap'}),\r
-        "GPRINT:cachedpct:MAX:%3.2lf%%",\r
-        "GPRINT:cachedpct:AVERAGE:%3.2lf%%",\r
-        "GPRINT:cachedpct:MIN:%3.2lf%%",\r
-        "GPRINT:cachedpct:LAST:%3.2lf%%\\j");\r
-        $ERROR = RRDs::error;\r
-        print "Error in RRD::graph for swap: $ERROR\n" if $ERROR;\r
-}\r
-\r
-# Generate the Disk Graph for the current period of time for values given by collecd\r
-\r
-sub updatediskgraph {\r
-        my $period    = $_[0];\r
-        my $disk    = $_[1];\r
-\r
-        RRDs::graph ("$graphs/disk-$disk-$period.png",\r
-        "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", "-v $Lang::tr{'bytes per second'}",\r
-        "--alt-y-grid", "-w 600", "-h 125", "-r", "-z",\r
-                               "--color", "SHADEA".$color{"color19"},\r
-        "--color", "SHADEB".$color{"color19"},\r
-        "--color", "BACK".$color{"color21"},\r
-        "-t $disk $Lang::tr{'disk access per'} $Lang::tr{$period}",\r
-        "DEF:read=$rrdlog/collectd/localhost/disk-$disk/disk_octets.rrd:read:AVERAGE",\r
-        "DEF:write=$rrdlog/collectd/localhost/disk-$disk/disk_octets.rrd:write:AVERAGE",\r
-        "CDEF:writen=write,-1,*",\r
-        "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE",\r
-        "CDEF:st=standby,INF,*",\r
-        "CDEF:st1=standby,-INF,*",\r
-                               "COMMENT:".sprintf("%-25s",$Lang::tr{'caption'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",\r
-        "AREA:st".$color{"color20"}."A0:",\r
-        "AREA:st1".$color{"color20"}."A0:standby\\j",\r
-        "AREA:read".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'read bytes'}),\r
-        "GPRINT:read:MAX:%8.1lf %sBps",\r
-        "GPRINT:read:AVERAGE:%8.1lf %sBps",\r
-        "GPRINT:read:MIN:%8.1lf %sBps",\r
-        "GPRINT:read:LAST:%8.1lf %sBps\\j",\r
-        "AREA:writen".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'written bytes'}),\r
-                               "GPRINT:write:MAX:%8.1lf %sBps",\r
-        "GPRINT:write:AVERAGE:%8.1lf %sBps",\r
-        "GPRINT:write:MIN:%8.1lf %sBps",\r
-        "GPRINT:write:LAST:%8.1lf %sBps\\j");\r
-        $ERROR = RRDs::error;\r
-        print "Error in RRD::graph for disk: $ERROR\n" if $ERROR;\r
-}\r
-\r
-# Generate the Interface Graph for the current period of time for values given by collecd\r
-\r
-sub updateifgraph {\r
-        my $interface = $_[0];\r
-        my $period    = $_[1];\r
-\r
-                               RRDs::graph ("$graphs/$interface-$period.png",\r
-                               "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", "-v $Lang::tr{'bytes per second'}",\r
-                               "--alt-y-grid", "-w 600", "-h 125", "-z", "-r",\r
-                               "--color", "SHADEA".$color{"color19"},\r
-                               "--color", "SHADEB".$color{"color19"},\r
-                               "--color", "BACK".$color{"color21"},\r
-                               "-t $Lang::tr{'traffic on'} $interface $Lang::tr{'graph per'} $Lang::tr{$period}",\r
-                               "-v$Lang::tr{'bytes per second'}",\r
-                               "DEF:incoming=$rrdlog/collectd/localhost/interface/if_octets-$interface.rrd:rx:AVERAGE",\r
-                               "DEF:outgoing=$rrdlog/collectd/localhost/interface/if_octets-$interface.rrd:tx:AVERAGE",\r
-                               "CDEF:outgoingn=outgoing,-1,*",\r
-                               "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",\r
-                               "AREA:incoming".$color{"color12"}."A0:".sprintf("%-20s",$Lang::tr{'incoming traffic in bytes per second'}),\r
-                               "GPRINT:incoming:MAX:%8.1lf %sBps",\r
-                               "GPRINT:incoming:AVERAGE:%8.1lf %sBps",\r
-                               "GPRINT:incoming:MIN:%8.1lf %sBps",\r
-                               "GPRINT:incoming:LAST:%8.1lf %sBps\\j",\r
-                               "AREA:outgoingn".$color{"color13"}."A0:".sprintf("%-20s",$Lang::tr{'outgoing traffic in bytes per second'}),\r
-                               "GPRINT:outgoing:MAX:%8.1lf %sBps",\r
-                               "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",\r
-                               "GPRINT:outgoing:MIN:%8.1lf %sBps",\r
-                               "GPRINT:outgoing:LAST:%8.1lf %sBps\\j");\r
-                               $ERROR = RRDs::error;\r
-                               print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR;\r
-}\r
-\r
-# Generate the Firewall Graph for the current period of time for values given by collecd\r
-\r
-sub updatefwhitsgraph {\r
-                               my $period = $_[0];\r
-                               RRDs::graph ("$graphs/fwhits-$period.png",\r
-                               "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",\r
-                               "--alt-y-grid", "-w 600", "-h 125", "-r", "-v $Lang::tr{'bytes per second'}",\r
-                               "--color", "SHADEA".$color{"color19"},\r
-                               "--color", "SHADEB".$color{"color19"},\r
-                               "--color", "BACK".$color{"color21"},\r
-                               "-t $Lang::tr{'firewall hits per'} $Lang::tr{$period}",\r
-                               "DEF:output=$rrdlog/collectd/localhost/iptables-filter-FORWARD/ipt_bytes-DROP_OUTPUT.rrd:value:AVERAGE",\r
-                               "DEF:input=$rrdlog/collectd/localhost/iptables-filter-INPUT/ipt_bytes-DROP_INPUT.rrd:value:AVERAGE",\r
-                               "DEF:newnotsyn=$rrdlog/collectd/localhost/iptables-filter-NEWNOTSYN/ipt_bytes-DROP_NEWNOTSYN.rrd:value:AVERAGE",\r
-                               "DEF:portscan=$rrdlog/collectd/localhost/iptables-filter-PSCAN/ipt_bytes-DROP_PScan.rrd:value:AVERAGE",\r
-                               "CDEF:amount=output,input,newnotsyn,+,+",\r
-               "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",\r
-                               "AREA:amount".$color{"color24"}."A0:".sprintf("%-20s",$Lang::tr{'firewallhits'}),\r
-                               "GPRINT:amount:MAX:%8.1lf %sBps",\r
-                               "GPRINT:amount:AVERAGE:%8.1lf %sBps",\r
-                               "GPRINT:amount:MIN:%8.1lf %sBps",\r
-                               "GPRINT:amount:LAST:%8.1lf %sBps\\j",\r
-                               "STACK:portscan".$color{"color25"}."A0:".sprintf("%-20s",$Lang::tr{'portscans'}),\r
-                               "GPRINT:portscan:MAX:%8.1lf %sBps",\r
-                               "GPRINT:portscan:MIN:%8.1lf %sBps",\r
-                               "GPRINT:portscan:AVERAGE:%8.1lf %sBps",\r
-                               "GPRINT:portscan:LAST:%8.1lf %sBps\\j");\r
-                               $ERROR = RRDs::error;\r
-    print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR;\r
-}\r
-\r
-# Generate the Line Quality Graph for the current period of time for values given by collecd\r
-\r
-sub updatelqgraph {\r
-                               my $period    = $_[0];\r
-                               RRDs::graph ("$graphs/lq-$period.png",\r
-                               "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",\r
-                               "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-r", "-v ms",\r
-                               "-t $Lang::tr{'linkq'} $Lang::tr{'graph per'} $Lang::tr{$period}",\r
-                               "--color", "SHADEA".$color{"color19"},\r
-                               "--color", "SHADEB".$color{"color19"},\r
-                               "--color", "BACK".$color{"color21"},\r
-                               "DEF:roundtrip=$rrdlog/collectd/localhost/ping/ping-gateway.rrd:ping:AVERAGE",\r
-                               "COMMENT:$Lang::".sprintf("%-20s",$Lang::tr{'caption'})."\\j",\r
-                               "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",\r
-                               "CDEF:r0=roundtrip,30,MIN",\r
-                               "CDEF:r1=roundtrip,70,MIN",\r
-                               "CDEF:r2=roundtrip,150,MIN",\r
-                               "CDEF:r3=roundtrip,300,MIN",\r
-                               "AREA:roundtrip".$color{"color25"}."A0:>300 ms",\r
-                               "AREA:r3".$color{"color18"}."A0:150-300 ms",\r
-                               "AREA:r2".$color{"color14"}."A0:70-150 ms",\r
-                               "AREA:r1".$color{"color17"}."A0:30-70 ms",\r
-                               "AREA:r0".$color{"color12"}."A0:<30 ms\\j",\r
-                               "COMMENT:".sprintf("%-15s",$Lang::tr{'maximal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),\r
-                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",\r
-                               "LINE1:roundtrip#707070:",\r
-                               "GPRINT:roundtrip:MAX:%3.2lf ms",\r
-                               "GPRINT:roundtrip:AVERAGE:%3.2lf ms",\r
-                               "GPRINT:roundtrip:MIN:%3.2lf ms",\r
-                               "GPRINT:roundtrip:LAST:%3.2lf ms\\j");\r
-                               $ERROR = RRDs::error;\r
-                               print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR;\r
-}\r
-\r
-# Generate the Hdd Graph for the current period of time for values given by collecd\r
-\r
-sub updatehddgraph {\r
-\r
-  my $disk = $_[0];\r
-  my $period = $_[1];\r
-\r
-  RRDs::graph ("$graphs/hddtemp-$disk-$period.png",\r
-  "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",\r
-  "--alt-y-grid", "-w 600", "-h 125",\r
-  "--color", "SHADEA".$color{"color19"},\r
-  "--color", "SHADEB".$color{"color19"},\r
-  "--color", "BACK".$color{"color21"},\r
-  "-t $disk $Lang::tr{'harddisk temperature'} $Lang::tr{'graph per'} $Lang::tr{$period}",\r
-  "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE",\r
-  "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE",\r
-  "CDEF:st=standby,INF,*",\r
-  "AREA:st".$color{"color20"}."A0:standby",\r
-  "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} C\\j",\r
-  "COMMENT:$Lang::tr{'maximal'}",\r
-  "COMMENT:$Lang::tr{'average'}",\r
-  "COMMENT:$Lang::tr{'minimal'}",\r
-  "COMMENT:$Lang::tr{'current'}\\j",\r
-  "GPRINT:temperature:MAX:%3.0lf Grad C",\r
-  "GPRINT:temperature:AVERAGE:%3.0lf Grad C",\r
-  "GPRINT:temperature:MIN:%3.0lf Grad C",\r
-  "GPRINT:temperature:LAST:%3.0lf Grad C\\j",\r
-  );\r
-  $ERROR = RRDs::error;\r
-  print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR;\r
-}\r
-\r
-# Generate the QoS Graph for the current period of time\r
-\r
-sub overviewgraph {\r
-\r
-  my $period = $_[0];\r
-  my $periodstring;\r
-  my $description;\r
-  my %qossettings = ();\r
-  &General::readhash("${General::swroot}/qos/settings", \%qossettings);\r
-  my $classentry = "";\r
-  my @classes = ();\r
-  my @classline = ();\r
-  my $classfile = "/var/ipfire/qos/classes";\r
-\r
-       $qossettings{'DEV'} = $_[1];\r
-       if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {\r
-               $qossettings{'CLASSPRFX'} = '1';\r
-       } else {\r
-               $qossettings{'CLASSPRFX'} = '2';\r
-       }\r
-\r
-  if ( $period ne '3240' ){ $periodstring = "-1$period";}else{ $periodstring = "-".$period;}\r
-  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'})";}\r
-\r
-       my $ERROR="";\r
-       my $count="1";\r
-       my $color="#000000";\r
-       my @command=("/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'DEV'}-$period.png",\r
-               "--start", $periodstring, "-aPNG", "-i", "-z", "-W www.ipfire.org",\r
-               "--alt-y-grid", "-w 600", "-h 125", "-r", "-v $Lang::tr{'bytes per second'}",\r
-    "--color", "SHADEA".$color{"color19"},\r
-    "--color", "SHADEB".$color{"color19"},\r
-    "--color", "BACK".$color{"color21"},\r
-               "COMMENT:".sprintf("%-28s",$Lang::tr{'caption'}),\r
-               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),\r
-               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),\r
-               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),\r
-               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",\r
-               $description\r
-       );\r
-       open( FILE, "< $classfile" ) or die "Unable to read $classfile";\r
-       @classes = <FILE>;\r
-       close FILE;\r
-       foreach $classentry (sort @classes)\r
-       {\r
-               @classline = split( /\;/, $classentry );\r
-               if ( $classline[0] eq $qossettings{'DEV'} )\r
-               {\r
-                       $color=random_hex_color(6);\r
-                       push(@command, "DEF:$classline[1]=$rrdlog/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE");\r
-\r
-                       if ($count eq "1") {\r
-                               push(@command, "AREA:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8]));\r
-                       } else {\r
-                               push(@command, "STACK:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8]));\r
-\r
-                       }\r
-                       push(@command, "GPRINT:$classline[1]:MAX:%8.1lf %sBps");\r
-                       push(@command, "GPRINT:$classline[1]:AVERAGE:%8.1lf %sBps");\r
-                       push(@command, "GPRINT:$classline[1]:MIN:%8.1lf %sBps");\r
-                       push(@command, "GPRINT:$classline[1]:LAST:%8.1lf %sBps\\j");\r
-                       $count++;\r
-               }\r
-       }\r
-       RRDs::graph (@command);\r
-       $ERROR = RRDs::error;\r
-       print "$ERROR";\r
-}\r
-\r
-# Generate the Temperature Graph for the current period of time for values given by collecd and lm_sensors\r
-\r
-sub updatehwtempgraph {\r
-\r
-  my $period = $_[0];\r
-\r
-  my @command = ("$graphs/sensors-hwtemp-$period.png",\r
-       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",\r
-       "--alt-y-grid", "-w 600", "-h 125",\r
-       "--color", "SHADEA".$color{"color19"},"--color",\r
-       "SHADEB".$color{"color19"},"--color",\r
-       "BACK".$color{"color21"},\r
-       "-t $Lang::tr{'sensors temp'} $Lang::tr{'graph per'} $Lang::tr{$period}");\r
-\r
-       foreach(@sensorsgraphs){\r
-               chomp($_);\r
-               if ( $_ =~ /temperature/ ) {\r
-                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;\r
-                       my $label = $2.$3;$label=~ s/-//g;\r
-                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}\r
-                       push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");\r
-               }\r
-       }\r
-       push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j");\r
-       foreach(@sensorsgraphs){\r
-               chomp($_);\r
-               if ( $_ =~ /temperature/ ){\r
-                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;\r
-                       my $label = $2.$3;$label=~ s/-//g;\r
-                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}\r
-                       push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf C\\j",);\r
-               }\r
-       }\r
-       RRDs::graph (@command);\r
-       $ERROR = RRDs::error;\r
-       print "$ERROR";\r
-}\r
-\r
-# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors\r
-\r
-sub updatehwvoltgraph {\r
-\r
-  my $period = $_[0];\r
-\r
-  my @command = ("$graphs/sensors-hwvolt-$period.png",\r
-       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",\r
-       "--alt-y-grid", "-w 600", "-h 125",\r
-       "--color", "SHADEA".$color{"color19"},"--color",\r
-       "SHADEB".$color{"color19"},"--color",\r
-       "BACK".$color{"color21"},\r
-       "-t $Lang::tr{'mbmon volt'} $Lang::tr{'graph per'} $Lang::tr{$period}");\r
-\r
-       foreach(@sensorsgraphs){\r
-               chomp($_);\r
-               if ( $_ =~ /voltage/ ) {\r
-                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;\r
-                       my $label = $2.$3;$label=~ s/-//g;\r
-                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}\r
-                       push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");\r
-               }\r
-       }\r
-       push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j");\r
-       foreach(@sensorsgraphs){\r
-               chomp($_);\r
-               if ( $_ =~ /voltage/ ){\r
-                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;\r
-                       my $label = $2.$3;$label=~ s/-//g;\r
-                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}\r
-                       push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf V\\j",);\r
-               }\r
-       }\r
-       RRDs::graph (@command);\r
-       $ERROR = RRDs::error;\r
-       print "$ERROR";\r
-}\r
-\r
-# Generate the Load Graph for the current period of time for values given by collecd and lm_sensors\r
-\r
-sub updatehwfangraph {\r
-\r
-  my $period = $_[0];\r
-\r
-  my @command = ("$graphs/sensors-hwfan-$period.png",\r
-       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",\r
-       "--alt-y-grid", "-w 600", "-h 125",\r
-       "--color", "SHADEA".$color{"color19"},"--color",\r
-       "SHADEB".$color{"color19"},"--color",\r
-       "BACK".$color{"color21"},\r
-       "-t $Lang::tr{'mbmon fan'} $Lang::tr{'graph per'} $Lang::tr{$period}");\r
-\r
-       foreach(@sensorsgraphs){\r
-               chomp($_);\r
-               if ( $_ =~ /fanspeed/ ) {\r
-                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;\r
-                       my $label = $2.$3;$label=~ s/-//g;\r
-                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}\r
-                       push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");\r
-               }\r
-       }\r
-       push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j");\r
-       foreach(@sensorsgraphs){\r
-               chomp($_);\r
-               if ( $_ =~ /fanspeed/ ){\r
-                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;\r
-                       my $label = $2.$3;$label=~ s/-//g;\r
-                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}\r
-                       push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf RPM\\j",);\r
-               }\r
-       }\r
-       RRDs::graph (@command);\r
-       $ERROR = RRDs::error;\r
-       print "$ERROR";\r
-}\r
-\r
-sub updateprocessesgraph {\r
-\r
-  my $period = $_[0];\r
-  my $count="0";\r
-\r
-  my @command = ("$graphs/processes-$period.png",\r
-       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",\r
-       "--alt-y-grid", "-w 600", "-h 125",\r
-       "--color", "SHADEA".$color{"color19"},"--color",\r
-       "SHADEB".$color{"color19"},"--color",\r
-       "BACK".$color{"color21"},\r
-       "-t $Lang::tr{'processes'} $Lang::tr{'graph per'} $Lang::tr{$period}");\r
-\r
-       foreach(@processesgraph){\r
-                       chomp($_);my @name=split(/\-/,$_);chop($name[1]);\r
-                       push(@command,"DEF:".$name[1]."user=".$_."ps_cputime.rrd:user:AVERAGE");\r
-                       push(@command,"DEF:".$name[1]."system=".$_."ps_cputime.rrd:syst:AVERAGE");\r
-                       push(@command,"CDEF:".$name[1]."=".$name[1]."user,".$name[1]."system,+");}\r
-\r
-                       push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j");\r
-\r
-       foreach(@processesgraph){\r
-                       chomp($_);my @name=split(/\-/,$_);chop($name[1]);\r
-                       if ($count eq "0") {push(@command,"AREA:".$name[1].random_hex_color(6)."A0:".$name[1]);}\r
-                       else {push(@command,"STACK:".$name[1].random_hex_color(6)."A0:".$name[1]);}\r
-                       $count++;}\r
-\r
-       RRDs::graph (@command);\r
-       $ERROR = RRDs::error;\r
-       print "$ERROR";\r
-\r
-  my $count="0";\r
-\r
-  my @command = ("$graphs/processesmem-$period.png",\r
-       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",\r
-       "--alt-y-grid", "-w 600", "-h 125",\r
-       "--color", "SHADEA".$color{"color19"},"--color",\r
-       "SHADEB".$color{"color19"},"--color",\r
-       "BACK".$color{"color21"},\r
-       "-t $Lang::tr{'processes'} $Lang::tr{'memory'} $Lang::tr{'graph per'} $Lang::tr{$period}");\r
-\r
-       foreach(@processesgraph){\r
-                       chomp($_);my @name=split(/\-/,$_);chop($name[1]);\r
-                       push(@command,"DEF:".$name[1]."=".$_."ps_rss.rrd:value:AVERAGE");}\r
-                       push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j");\r
-\r
-       foreach(@processesgraph){\r
-                       chomp($_);my @name=split(/\-/,$_);chop($name[1]);\r
-                       if ($count eq "0") {push(@command,"AREA:".$name[1].random_hex_color(6)."A0:".$name[1]);}\r
-                       else {push(@command,"STACK:".$name[1].random_hex_color(6)."A0:".$name[1]);}\r
-                       $count++;}\r
-\r
-       RRDs::graph (@command);\r
-       $ERROR = RRDs::error;\r
-       print "$ERROR";\r
-}\r
-\r
-# Generate a random color, used by Qos Graph to be independent from the amount of values\r
-\r
-sub random_hex_color {\r
-    my $size = shift;\r
-    $size = 6 if $size !~ /^3|6$/;\r
-    my @hex = ( 0 .. 9, 'a' .. 'f' );\r
-    my @color;\r
-    push @color, @hex[rand(@hex)] for 1 .. $size;\r
-    return join('', '#', @color);\r
-}\r
+#!/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;
+use RRDs;
+
+require '/var/ipfire/general-functions.pl';
+require "${General::swroot}/lang.pl";
+require "${General::swroot}/header.pl";
+
+my $ERROR;
+my $rrdlog = "/var/log/rrd";
+my $graphs = "/srv/web/ipfire/html/graphs";
+$ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
+
+# Read the global settings files to get the current theme and after this load
+# colors for this theme
+
+my %color = ();
+my %mainsettings = ();
+my %sensorsettings = ();
+&General::readhash("${General::swroot}/main/settings", \%mainsettings);
+&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+
+
+# If the collection deamon is working and collecting lm_sensors data there will be
+# some data source named after a common scheme, with the sensorssettingsfile
+# the user is able to deactivate some of this parameters, in case not to show
+# false collected value´s may be disable. The user has the ability to ente
+# custom graph names in order to change temp0 to cpu or motherboad
+
+my $key;
+my $value;
+my @args = ();
+my $count = 0;
+my @sensorsgraphs = ();
+my @processesgraph = `ls -dA $rrdlog/collectd/localhost/processes-*/`;
+my @sensorsdir = `ls -dA $rrdlog/collectd/localhost/sensors-*/`;
+foreach (@sensorsdir)
+{
+       chomp($_);chop($_);
+       foreach (`ls $_/*`){
+               chomp($_);
+               push(@sensorsgraphs,$_);
+               $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+               my $label = $2.$3;$label=~ s/-//g;
+               $sensorsettings{'LABEL-'.$label}="$label";
+               $sensorsettings{'LINE-'.$label}="checked";
+       }
+}
+
+&General::readhash("${General::swroot}/sensors/settings", \%sensorsettings);
+use Encode 'from_to';
+
+my %tr=();
+if ((${Lang::language} eq 'el') ||
+    (${Lang::language} eq 'fa') ||
+    (${Lang::language} eq 'ru') ||
+    (${Lang::language} eq 'th') ||
+    (${Lang::language} eq 'vi') ||
+    (${Lang::language} eq 'zh') ||
+    (${Lang::language} eq 'zt')) {
+        eval `/bin/cat "${General::swroot}/langs/en.pl"`;
+} else {
+        %tr=%Lang::tr;          # use translated version for other languages
+}
+
+# Generate the CPU Graph for the current period of time for values given by
+# collectd atm only cpu average is displayed and only 1 or 2 cpus is working
+
+sub updatecpugraph {
+        my $period    = $_[0];
+                               my @command = ("$graphs/cpu-$period.png",
+        "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}",
+        "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r",
+        "--color", "SHADEA".$color{"color19"},
+        "--color", "SHADEB".$color{"color19"},
+        "--color", "BACK".$color{"color21"},
+        "-t $Lang::tr{'cpu usage per'} $Lang::tr{$period}");
+
+        if ( -e "$rrdlog/collectd/localhost/cpu-1/" ){
+        push(@command,"DEF:iowait0=$rrdlog/collectd/localhost/cpu-0/cpu-wait.rrd:value:AVERAGE",
+                               "DEF:nice0=$rrdlog/collectd/localhost/cpu-0/cpu-nice.rrd:value:AVERAGE",
+                               "DEF:interrupt0=$rrdlog/collectd/localhost/cpu-0/cpu-interrupt.rrd:value:AVERAGE",
+                               "DEF:steal0=$rrdlog/collectd/localhost/cpu-0/cpu-steal.rrd:value:AVERAGE",
+                               "DEF:user0=$rrdlog/collectd/localhost/cpu-0/cpu-user.rrd:value:AVERAGE",
+                               "DEF:system0=$rrdlog/collectd/localhost/cpu-0/cpu-system.rrd:value:AVERAGE",
+                               "DEF:idle0=$rrdlog/collectd/localhost/cpu-0/cpu-idle.rrd:value:AVERAGE",
+                               "DEF:irq0=$rrdlog/collectd/localhost/cpu-0/cpu-softirq.rrd:value:AVERAGE");
+        push(@command,"DEF:iowait1=$rrdlog/collectd/localhost/cpu-1/cpu-wait.rrd:value:AVERAGE",
+                               "DEF:nice1=$rrdlog/collectd/localhost/cpu-1/cpu-nice.rrd:value:AVERAGE",
+                               "DEF:interrupt1=$rrdlog/collectd/localhost/cpu-1/cpu-interrupt.rrd:value:AVERAGE",
+                               "DEF:steal1=$rrdlog/collectd/localhost/cpu-1/cpu-steal.rrd:value:AVERAGE",
+                               "DEF:user1=$rrdlog/collectd/localhost/cpu-1/cpu-user.rrd:value:AVERAGE",
+                               "DEF:system1=$rrdlog/collectd/localhost/cpu-1/cpu-system.rrd:value:AVERAGE",
+                               "DEF:idle1=$rrdlog/collectd/localhost/cpu-1/cpu-idle.rrd:value:AVERAGE",
+                               "DEF:irq1=$rrdlog/collectd/localhost/cpu-1/cpu-softirq.rrd:value:AVERAGE");
+        push(@command,"CDEF:user=user0,user1,+",
+                               "CDEF:nice=nice0,nice1,+",
+                               "CDEF:interrupt=interrupt0,interrupt1,+",
+                               "CDEF:steal=steal0,steal1,+",
+                               "CDEF:system=system0,system1,+",
+                               "CDEF:idle=idle0,idle1,+",
+                               "CDEF:iowait=iowait0,iowait1,+",
+                               "CDEF:irq=irq0,irq1,+");
+                               }
+        else {
+        push(@command,"DEF:iowait=$rrdlog/collectd/localhost/cpu-0/cpu-wait.rrd:value:AVERAGE",
+                               "DEF:nice=$rrdlog/collectd/localhost/cpu-0/cpu-nice.rrd:value:AVERAGE",
+                               "DEF:interrupt=$rrdlog/collectd/localhost/cpu-0/cpu-interrupt.rrd:value:AVERAGE",
+                               "DEF:steal=$rrdlog/collectd/localhost/cpu-0/cpu-steal.rrd:value:AVERAGE",
+                               "DEF:user=$rrdlog/collectd/localhost/cpu-0/cpu-user.rrd:value:AVERAGE",
+                               "DEF:system=$rrdlog/collectd/localhost/cpu-0/cpu-system.rrd:value:AVERAGE",
+                               "DEF:idle=$rrdlog/collectd/localhost/cpu-0/cpu-idle.rrd:value:AVERAGE",
+                               "DEF:irq=$rrdlog/collectd/localhost/cpu-0/cpu-softirq.rrd:value:AVERAGE");
+                               }
+                               push(@command,"CDEF:total=user,system,idle,iowait,irq,nice,interrupt,steal,+,+,+,+,+,+,+",
+                               "CDEF:userpct=100,user,total,/,*",
+                               "CDEF:nicepct=100,nice,total,/,*",
+                               "CDEF:interruptpct=100,interrupt,total,/,*",
+                               "CDEF:stealpct=100,steal,total,/,*",
+                               "CDEF:systempct=100,system,total,/,*",
+                               "CDEF:idlepct=100,idle,total,/,*",
+                               "CDEF:iowaitpct=100,iowait,total,/,*",
+                               "CDEF:irqpct=100,irq,total,/,*",
+                               "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",
+        "AREA:iowaitpct".$color{"color14"}.":".sprintf("%-25s",$Lang::tr{'cpu iowait usage'}),
+        "GPRINT:iowaitpct:MAX:%3.2lf%%",
+        "GPRINT:iowaitpct:AVERAGE:%3.2lf%%",
+        "GPRINT:iowaitpct:MIN:%3.2lf%%",
+        "GPRINT:iowaitpct:LAST:%3.2lf%%\\j",
+        "STACK:irqpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr{'cpu irq usage'}),
+        "GPRINT:irqpct:MAX:%3.2lf%%",
+        "GPRINT:irqpct:AVERAGE:%3.2lf%%",
+        "GPRINT:irqpct:MIN:%3.2lf%%",
+        "GPRINT:irqpct:LAST:%3.2lf%%\\j",
+        "STACK:nicepct".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr{'cpu nice usage'}),
+        "GPRINT:nicepct:MAX:%3.2lf%%",
+        "GPRINT:nicepct:AVERAGE:%3.2lf%%",
+        "GPRINT:nicepct:MIN:%3.2lf%%",
+        "GPRINT:nicepct:LAST:%3.2lf%%\\j",
+        "STACK:interruptpct".$color{"color15"}."A0:".sprintf("%-25s",$Lang::tr{'cpu interrupt usage'}),
+        "GPRINT:interruptpct:MAX:%3.2lf%%",
+        "GPRINT:interruptpct:AVERAGE:%3.2lf%%",
+        "GPRINT:interruptpct:MIN:%3.2lf%%",
+        "GPRINT:interruptpct:LAST:%3.2lf%%\\j",
+        "STACK:stealpct".$color{"color18"}."A0:".sprintf("%-25s",$Lang::tr{'cpu steal usage'}),
+        "GPRINT:stealpct:MAX:%3.2lf%%",
+        "GPRINT:stealpct:AVERAGE:%3.2lf%%",
+        "GPRINT:stealpct:MIN:%3.2lf%%",
+        "GPRINT:stealpct:LAST:%3.2lf%%\\j",
+        "STACK:userpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'cpu user usage'}),
+        "GPRINT:userpct:MAX:%3.2lf%%",
+        "GPRINT:userpct:AVERAGE:%3.2lf%%",
+        "GPRINT:userpct:MIN:%3.2lf%%",
+        "GPRINT:userpct:LAST:%3.2lf%%\\j",
+        "STACK:systempct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'cpu system usage'}),
+        "GPRINT:systempct:MAX:%3.2lf%%",
+        "GPRINT:systempct:AVERAGE:%3.2lf%%",
+        "GPRINT:systempct:MIN:%3.2lf%%",
+        "GPRINT:systempct:LAST:%3.2lf%%\\j",
+        "STACK:idlepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'cpu idle usage'}),
+        "GPRINT:idlepct:MAX:%3.2lf%%",
+        "GPRINT:idlepct:AVERAGE:%3.2lf%%",
+        "GPRINT:idlepct:MIN:%3.2lf%%",
+        "GPRINT:idlepct:LAST:%3.2lf%%\\j");
+
+                               RRDs::graph (@command);
+        $ERROR = RRDs::error;
+        print "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
+
+sub updateloadgraph {
+        my $period    = $_[0];
+
+        RRDs::graph ("$graphs/load-$period.png",
+        "--start", "-1$period", "-aPNG",
+        "-w 600", "-h 125", "-i", "-z", "-W www.ipfire.org", "-l 0", "-r", "--alt-y-grid",
+        "-t Load Average $Lang::tr{'graph per'} $Lang::tr{$period}", "-v $Lang::tr{'processes'}",
+        "--color", "SHADEA".$color{"color19"},
+        "--color", "SHADEB".$color{"color19"},
+        "--color", "BACK".$color{"color21"},
+        "DEF:load1=$rrdlog/collectd/localhost/load/load.rrd:shortterm:AVERAGE",
+        "DEF:load5=$rrdlog/collectd/localhost/load/load.rrd:midterm:AVERAGE",
+        "DEF:load15=$rrdlog/collectd/localhost/load/load.rrd:longterm:AVERAGE",
+        "AREA:load1".$color{"color13"}."A0:1 Minute:",
+        "GPRINT:load1:LAST:%5.2lf",
+        "AREA:load5".$color{"color18"}."A0:5 Minuten:",
+        "GPRINT:load5:LAST:%5.2lf",
+        "AREA:load15".$color{"color14"}."A0:15 Minuten:",
+        "GPRINT:load15:LAST:%5.2lf\\j",
+        "LINE1:load5".$color{"color13"},
+        "LINE1:load1".$color{"color18"});
+        $ERROR = RRDs::error;
+        print "Error in RRD::graph for load: $ERROR\n" if $ERROR;
+}
+
+# Generate the Memory and Swap Graph for the current period of time for values given by collecd
+
+sub updatememgraph {
+        my $period    = $_[0];
+
+        RRDs::graph ("$graphs/memory-$period.png",
+        "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}",
+        "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r",
+        "--color", "SHADEA".$color{"color19"},
+        "--color", "SHADEB".$color{"color19"},
+        "--color", "BACK".$color{"color21"},
+        "-t $Lang::tr{'memory usage per'} $Lang::tr{$period}",
+        "DEF:used=$rrdlog/collectd/localhost/memory/memory-used.rrd:value:AVERAGE",
+        "DEF:free=$rrdlog/collectd/localhost/memory/memory-free.rrd:value:AVERAGE",
+        "DEF:buffer=$rrdlog/collectd/localhost/memory/memory-buffered.rrd:value:AVERAGE",
+        "DEF:cache=$rrdlog/collectd/localhost/memory/memory-cached.rrd:value:AVERAGE",
+        "CDEF:total=used,free,cache,buffer,+,+,+",
+        "CDEF:usedpct=used,total,/,100,*",
+        "CDEF:bufferpct=buffer,total,/,100,*",
+        "CDEF:cachepct=cache,total,/,100,*",
+        "CDEF:freepct=free,total,/,100,*",
+                               "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",
+        "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'used memory'}),
+        "GPRINT:usedpct:MAX:%3.2lf%%",
+        "GPRINT:usedpct:AVERAGE:%3.2lf%%",
+        "GPRINT:usedpct:MIN:%3.2lf%%",
+        "GPRINT:usedpct:LAST:%3.2lf%%\\j",
+        "STACK:bufferpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr{'buffered memory'}),
+        "GPRINT:bufferpct:MAX:%3.2lf%%",
+        "GPRINT:bufferpct:AVERAGE:%3.2lf%%",
+        "GPRINT:bufferpct:MIN:%3.2lf%%",
+        "GPRINT:bufferpct:LAST:%3.2lf%%\\j",
+        "STACK:cachepct".$color{"color14"}."A0:".sprintf("%-25s",$Lang::tr{'cached memory'}),
+        "GPRINT:cachepct:MAX:%3.2lf%%",
+        "GPRINT:cachepct:AVERAGE:%3.2lf%%",
+        "GPRINT:cachepct:MIN:%3.2lf%%",
+        "GPRINT:cachepct:LAST:%3.2lf%%\\j",
+        "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'free memory'}),
+        "GPRINT:freepct:MAX:%3.2lf%%",
+        "GPRINT:freepct:AVERAGE:%3.2lf%%",
+        "GPRINT:freepct:MIN:%3.2lf%%",
+        "GPRINT:freepct:LAST:%3.2lf%%\\j");
+        $ERROR = RRDs::error;
+        print "Error in RRD::graph for mem: $ERROR\n" if $ERROR;
+
+        RRDs::graph ("$graphs/swap-$period.png",
+        "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}",
+        "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r",
+        "--color", "SHADEA".$color{"color19"},
+        "--color", "SHADEB".$color{"color19"},
+        "--color", "BACK".$color{"color21"},
+        "-t $Lang::tr{'swap usage per'} $Lang::tr{$period}",
+        "DEF:used=$rrdlog/collectd/localhost/swap/swap-used.rrd:value:AVERAGE",
+        "DEF:free=$rrdlog/collectd/localhost/swap/swap-free.rrd:value:AVERAGE",
+                               "DEF:cached=$rrdlog/collectd/localhost/swap/swap-cached.rrd:value:AVERAGE",
+        "CDEF:total=used,free,cached,+,+",
+        "CDEF:usedpct=100,used,total,/,*",
+        "CDEF:freepct=100,free,total,/,*",
+        "CDEF:cachedpct=100,cached,total,/,*",
+                               "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",
+        "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'used swap'}),
+        "GPRINT:usedpct:MAX:%3.2lf%%",
+        "GPRINT:usedpct:AVERAGE:%3.2lf%%",
+        "GPRINT:usedpct:MIN:%3.2lf%%",
+        "GPRINT:usedpct:LAST:%3.2lf%%\\j",
+        "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'free swap'}),
+        "GPRINT:freepct:MAX:%3.2lf%%",
+        "GPRINT:freepct:AVERAGE:%3.2lf%%",
+        "GPRINT:freepct:MIN:%3.2lf%%",
+        "GPRINT:freepct:LAST:%3.2lf%%\\j",
+        "STACK:cachedpct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'cached swap'}),
+        "GPRINT:cachedpct:MAX:%3.2lf%%",
+        "GPRINT:cachedpct:AVERAGE:%3.2lf%%",
+        "GPRINT:cachedpct:MIN:%3.2lf%%",
+        "GPRINT:cachedpct:LAST:%3.2lf%%\\j");
+        $ERROR = RRDs::error;
+        print "Error in RRD::graph for swap: $ERROR\n" if $ERROR;
+}
+
+# Generate the Disk Graph for the current period of time for values given by collecd
+
+sub updatediskgraph {
+        my $period    = $_[0];
+        my $disk    = $_[1];
+
+        RRDs::graph ("$graphs/disk-$disk-$period.png",
+        "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", "-v $Lang::tr{'bytes per second'}",
+        "--alt-y-grid", "-w 600", "-h 125", "-r", "-z",
+                               "--color", "SHADEA".$color{"color19"},
+        "--color", "SHADEB".$color{"color19"},
+        "--color", "BACK".$color{"color21"},
+        "-t $disk $Lang::tr{'disk access per'} $Lang::tr{$period}",
+        "DEF:read=$rrdlog/collectd/localhost/disk-$disk/disk_octets.rrd:read:AVERAGE",
+        "DEF:write=$rrdlog/collectd/localhost/disk-$disk/disk_octets.rrd:write:AVERAGE",
+        "CDEF:writen=write,-1,*",
+        "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE",
+        "CDEF:st=standby,INF,*",
+        "CDEF:st1=standby,-INF,*",
+                               "COMMENT:".sprintf("%-25s",$Lang::tr{'caption'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",
+        "AREA:st".$color{"color20"}."A0:",
+        "AREA:st1".$color{"color20"}."A0:standby\\j",
+        "AREA:read".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'read bytes'}),
+        "GPRINT:read:MAX:%8.1lf %sBps",
+        "GPRINT:read:AVERAGE:%8.1lf %sBps",
+        "GPRINT:read:MIN:%8.1lf %sBps",
+        "GPRINT:read:LAST:%8.1lf %sBps\\j",
+        "AREA:writen".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'written bytes'}),
+                               "GPRINT:write:MAX:%8.1lf %sBps",
+        "GPRINT:write:AVERAGE:%8.1lf %sBps",
+        "GPRINT:write:MIN:%8.1lf %sBps",
+        "GPRINT:write:LAST:%8.1lf %sBps\\j");
+        $ERROR = RRDs::error;
+        print "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
+
+sub updateifgraph {
+        my $interface = $_[0];
+        my $period    = $_[1];
+
+                               RRDs::graph ("$graphs/$interface-$period.png",
+                               "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", "-v $Lang::tr{'bytes per second'}",
+                               "--alt-y-grid", "-w 600", "-h 125", "-z", "-r",
+                               "--color", "SHADEA".$color{"color19"},
+                               "--color", "SHADEB".$color{"color19"},
+                               "--color", "BACK".$color{"color21"},
+                               "-t $Lang::tr{'traffic on'} $interface $Lang::tr{'graph per'} $Lang::tr{$period}",
+                               "-v$Lang::tr{'bytes per second'}",
+                               "DEF:incoming=$rrdlog/collectd/localhost/interface/if_octets-$interface.rrd:rx:AVERAGE",
+                               "DEF:outgoing=$rrdlog/collectd/localhost/interface/if_octets-$interface.rrd:tx:AVERAGE",
+                               "CDEF:outgoingn=outgoing,-1,*",
+                               "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",
+                               "AREA:incoming".$color{"color12"}."A0:".sprintf("%-20s",$Lang::tr{'incoming traffic in bytes per second'}),
+                               "GPRINT:incoming:MAX:%8.1lf %sBps",
+                               "GPRINT:incoming:AVERAGE:%8.1lf %sBps",
+                               "GPRINT:incoming:MIN:%8.1lf %sBps",
+                               "GPRINT:incoming:LAST:%8.1lf %sBps\\j",
+                               "AREA:outgoingn".$color{"color13"}."A0:".sprintf("%-20s",$Lang::tr{'outgoing traffic in bytes per second'}),
+                               "GPRINT:outgoing:MAX:%8.1lf %sBps",
+                               "GPRINT:outgoing:AVERAGE:%8.1lf %sBps",
+                               "GPRINT:outgoing:MIN:%8.1lf %sBps",
+                               "GPRINT:outgoing:LAST:%8.1lf %sBps\\j");
+                               $ERROR = RRDs::error;
+                               print "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
+
+sub updatefwhitsgraph {
+                               my $period = $_[0];
+                               RRDs::graph ("$graphs/fwhits-$period.png",
+                               "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
+                               "--alt-y-grid", "-w 600", "-h 125", "-r", "-v $Lang::tr{'bytes per second'}",
+                               "--color", "SHADEA".$color{"color19"},
+                               "--color", "SHADEB".$color{"color19"},
+                               "--color", "BACK".$color{"color21"},
+                               "-t $Lang::tr{'firewall hits per'} $Lang::tr{$period}",
+                               "DEF:output=$rrdlog/collectd/localhost/iptables-filter-FORWARD/ipt_bytes-DROP_OUTPUT.rrd:value:AVERAGE",
+                               "DEF:input=$rrdlog/collectd/localhost/iptables-filter-INPUT/ipt_bytes-DROP_INPUT.rrd:value:AVERAGE",
+                               "DEF:newnotsyn=$rrdlog/collectd/localhost/iptables-filter-NEWNOTSYN/ipt_bytes-DROP_NEWNOTSYN.rrd:value:AVERAGE",
+                               "DEF:portscan=$rrdlog/collectd/localhost/iptables-filter-PSCAN/ipt_bytes-DROP_PScan.rrd:value:AVERAGE",
+                               "CDEF:amount=output,input,newnotsyn,+,+",
+               "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",
+                               "AREA:amount".$color{"color24"}."A0:".sprintf("%-20s",$Lang::tr{'firewallhits'}),
+                               "GPRINT:amount:MAX:%8.1lf %sBps",
+                               "GPRINT:amount:AVERAGE:%8.1lf %sBps",
+                               "GPRINT:amount:MIN:%8.1lf %sBps",
+                               "GPRINT:amount:LAST:%8.1lf %sBps\\j",
+                               "STACK:portscan".$color{"color25"}."A0:".sprintf("%-20s",$Lang::tr{'portscans'}),
+                               "GPRINT:portscan:MAX:%8.1lf %sBps",
+                               "GPRINT:portscan:MIN:%8.1lf %sBps",
+                               "GPRINT:portscan:AVERAGE:%8.1lf %sBps",
+                               "GPRINT:portscan:LAST:%8.1lf %sBps\\j");
+                               $ERROR = RRDs::error;
+    print "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
+
+sub updatelqgraph {
+                               my $period    = $_[0];
+                               RRDs::graph ("$graphs/lq-$period.png",
+                               "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
+                               "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-r", "-v ms",
+                               "-t $Lang::tr{'linkq'} $Lang::tr{'graph per'} $Lang::tr{$period}",
+                               "--color", "SHADEA".$color{"color19"},
+                               "--color", "SHADEB".$color{"color19"},
+                               "--color", "BACK".$color{"color21"},
+                               "DEF:roundtrip=$rrdlog/collectd/localhost/ping/ping-gateway.rrd:ping:AVERAGE",
+                               "COMMENT:$Lang::".sprintf("%-20s",$Lang::tr{'caption'})."\\j",
+                               "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/",
+                               "CDEF:r0=roundtrip,30,MIN",
+                               "CDEF:r1=roundtrip,70,MIN",
+                               "CDEF:r2=roundtrip,150,MIN",
+                               "CDEF:r3=roundtrip,300,MIN",
+                               "AREA:roundtrip".$color{"color25"}."A0:>300 ms",
+                               "AREA:r3".$color{"color18"}."A0:150-300 ms",
+                               "AREA:r2".$color{"color14"}."A0:70-150 ms",
+                               "AREA:r1".$color{"color17"}."A0:30-70 ms",
+                               "AREA:r0".$color{"color12"}."A0:<30 ms\\j",
+                               "COMMENT:".sprintf("%-15s",$Lang::tr{'maximal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),
+                               "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j",
+                               "LINE1:roundtrip#707070:",
+                               "GPRINT:roundtrip:MAX:%3.2lf ms",
+                               "GPRINT:roundtrip:AVERAGE:%3.2lf ms",
+                               "GPRINT:roundtrip:MIN:%3.2lf ms",
+                               "GPRINT:roundtrip:LAST:%3.2lf ms\\j");
+                               $ERROR = RRDs::error;
+                               print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR;
+}
+
+# Generate the Hdd Graph for the current period of time for values given by collecd
+
+sub updatehddgraph {
+
+  my $disk = $_[0];
+  my $period = $_[1];
+
+  RRDs::graph ("$graphs/hddtemp-$disk-$period.png",
+  "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",
+  "--alt-y-grid", "-w 600", "-h 125",
+  "--color", "SHADEA".$color{"color19"},
+  "--color", "SHADEB".$color{"color19"},
+  "--color", "BACK".$color{"color21"},
+  "-t $disk $Lang::tr{'harddisk temperature'} $Lang::tr{'graph per'} $Lang::tr{$period}",
+  "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE",
+  "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE",
+  "CDEF:st=standby,INF,*",
+  "AREA:st".$color{"color20"}."A0:standby",
+  "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} C\\j",
+  "COMMENT:$Lang::tr{'maximal'}",
+  "COMMENT:$Lang::tr{'average'}",
+  "COMMENT:$Lang::tr{'minimal'}",
+  "COMMENT:$Lang::tr{'current'}\\j",
+  "GPRINT:temperature:MAX:%3.0lf Grad C",
+  "GPRINT:temperature:AVERAGE:%3.0lf Grad C",
+  "GPRINT:temperature:MIN:%3.0lf Grad C",
+  "GPRINT:temperature:LAST:%3.0lf Grad C\\j",
+  );
+  $ERROR = RRDs::error;
+  print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR;
+}
+
+# Generate the QoS Graph for the current period of time
+
+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 125", "-r", "-v $Lang::tr{'bytes per second'}",
+    "--color", "SHADEA".$color{"color19"},
+    "--color", "SHADEB".$color{"color19"},
+    "--color", "BACK".$color{"color21"},
+               "COMMENT:".sprintf("%-28s",$Lang::tr{'caption'}),
+               "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),
+               "COMMENT:".sprintf("%15s",$Lang::tr{'average'}),
+               "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),
+               "COMMENT:".sprintf("%15s",$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]=$rrdlog/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:%8.1lf %sBps");
+                       push(@command, "GPRINT:$classline[1]:AVERAGE:%8.1lf %sBps");
+                       push(@command, "GPRINT:$classline[1]:MIN:%8.1lf %sBps");
+                       push(@command, "GPRINT:$classline[1]:LAST:%8.1lf %sBps\\j");
+                       $count++;
+               }
+       }
+       RRDs::graph (@command);
+       $ERROR = RRDs::error;
+       print "$ERROR";
+}
+
+# Generate the Temperature Graph for the current period of time for values given by collecd and lm_sensors
+
+sub updatehwtempgraph {
+
+  my $period = $_[0];
+
+  my @command = ("$graphs/sensors-hwtemp-$period.png",
+       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
+       "--alt-y-grid", "-w 600", "-h 125",
+       "--color", "SHADEA".$color{"color19"},"--color",
+       "SHADEB".$color{"color19"},"--color",
+       "BACK".$color{"color21"},
+       "-t $Lang::tr{'sensors temp'} $Lang::tr{'graph per'} $Lang::tr{$period}");
+
+       foreach(@sensorsgraphs){
+               chomp($_);
+               if ( $_ =~ /temperature/ ) {
+                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+                       my $label = $2.$3;$label=~ s/-//g;
+                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
+                       push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
+               }
+       }
+       push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j");
+       foreach(@sensorsgraphs){
+               chomp($_);
+               if ( $_ =~ /temperature/ ){
+                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+                       my $label = $2.$3;$label=~ s/-//g;
+                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
+                       push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf C\\j",);
+               }
+       }
+       RRDs::graph (@command);
+       $ERROR = RRDs::error;
+       print "$ERROR";
+}
+
+# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors
+
+sub updatehwvoltgraph {
+
+  my $period = $_[0];
+
+  my @command = ("$graphs/sensors-hwvolt-$period.png",
+       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
+       "--alt-y-grid", "-w 600", "-h 125",
+       "--color", "SHADEA".$color{"color19"},"--color",
+       "SHADEB".$color{"color19"},"--color",
+       "BACK".$color{"color21"},
+       "-t $Lang::tr{'mbmon volt'} $Lang::tr{'graph per'} $Lang::tr{$period}");
+
+       foreach(@sensorsgraphs){
+               chomp($_);
+               if ( $_ =~ /voltage/ ) {
+                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+                       my $label = $2.$3;$label=~ s/-//g;
+                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
+                       push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
+               }
+       }
+       push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j");
+       foreach(@sensorsgraphs){
+               chomp($_);
+               if ( $_ =~ /voltage/ ){
+                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+                       my $label = $2.$3;$label=~ s/-//g;
+                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
+                       push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf V\\j",);
+               }
+       }
+       RRDs::graph (@command);
+       $ERROR = RRDs::error;
+       print "$ERROR";
+}
+
+# Generate the Load Graph for the current period of time for values given by collecd and lm_sensors
+
+sub updatehwfangraph {
+
+  my $period = $_[0];
+
+  my @command = ("$graphs/sensors-hwfan-$period.png",
+       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
+       "--alt-y-grid", "-w 600", "-h 125",
+       "--color", "SHADEA".$color{"color19"},"--color",
+       "SHADEB".$color{"color19"},"--color",
+       "BACK".$color{"color21"},
+       "-t $Lang::tr{'mbmon fan'} $Lang::tr{'graph per'} $Lang::tr{$period}");
+
+       foreach(@sensorsgraphs){
+               chomp($_);
+               if ( $_ =~ /fanspeed/ ) {
+                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+                       my $label = $2.$3;$label=~ s/-//g;
+                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
+                       push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE");
+               }
+       }
+       push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j");
+       foreach(@sensorsgraphs){
+               chomp($_);
+               if ( $_ =~ /fanspeed/ ){
+                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+                       my $label = $2.$3;$label=~ s/-//g;
+                       if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;}
+                       push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf RPM\\j",);
+               }
+       }
+       RRDs::graph (@command);
+       $ERROR = RRDs::error;
+       print "$ERROR";
+}
+
+sub updateprocessesgraph {
+
+  my $period = $_[0];
+  my $count="0";
+
+  my @command = ("$graphs/processes-$period.png",
+       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
+       "--alt-y-grid", "-w 600", "-h 125",
+       "--color", "SHADEA".$color{"color19"},"--color",
+       "SHADEB".$color{"color19"},"--color",
+       "BACK".$color{"color21"},
+       "-t $Lang::tr{'processes'} $Lang::tr{'graph per'} $Lang::tr{$period}");
+
+       foreach(@processesgraph){
+                       chomp($_);my @name=split(/\-/,$_);chop($name[1]);
+                       push(@command,"DEF:".$name[1]."user=".$_."ps_cputime.rrd:user:AVERAGE");
+                       push(@command,"DEF:".$name[1]."system=".$_."ps_cputime.rrd:syst:AVERAGE");
+                       push(@command,"CDEF:".$name[1]."=".$name[1]."user,".$name[1]."system,+");}
+
+                       push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j");
+
+       foreach(@processesgraph){
+                       chomp($_);my @name=split(/\-/,$_);chop($name[1]);
+                       if ($count eq "0") {push(@command,"AREA:".$name[1].random_hex_color(6)."A0:".$name[1]);}
+                       else {push(@command,"STACK:".$name[1].random_hex_color(6)."A0:".$name[1]);}
+                       $count++;}
+
+       RRDs::graph (@command);
+       $ERROR = RRDs::error;
+       print "$ERROR";
+
+  my $count="0";
+
+  my @command = ("$graphs/processesmem-$period.png",
+       "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
+       "--alt-y-grid", "-w 600", "-h 125",
+       "--color", "SHADEA".$color{"color19"},"--color",
+       "SHADEB".$color{"color19"},"--color",
+       "BACK".$color{"color21"},
+       "-t $Lang::tr{'processes'} $Lang::tr{'memory'} $Lang::tr{'graph per'} $Lang::tr{$period}");
+
+       foreach(@processesgraph){
+                       chomp($_);my @name=split(/\-/,$_);chop($name[1]);
+                       push(@command,"DEF:".$name[1]."=".$_."ps_rss.rrd:value:AVERAGE");}
+                       push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j");
+
+       foreach(@processesgraph){
+                       chomp($_);my @name=split(/\-/,$_);chop($name[1]);
+                       if ($count eq "0") {push(@command,"AREA:".$name[1].random_hex_color(6)."A0:".$name[1]);}
+                       else {push(@command,"STACK:".$name[1].random_hex_color(6)."A0:".$name[1]);}
+                       $count++;}
+
+       RRDs::graph (@command);
+       $ERROR = RRDs::error;
+       print "$ERROR";
+}
+
+# Generate a random color, used by Qos Graph to be independent from the amount of values
+
+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);
+}
index 76f665d1efa181ce4819e178c9b17b2250ea35f2..911a63281f92af0c55c0fa74c3ba4fc0b5cd4490 100644 (file)
-#!/usr/bin/perl\r
-###############################################################################\r
-#                                                                             #\r
-# IPFire.org - A linux based firewall                                         #\r
-# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #\r
-#                                                                             #\r
-# This program is free software: you can redistribute it and/or modify        #\r
-# it under the terms of the GNU General Public License as published by        #\r
-# the Free Software Foundation, either version 3 of the License, or           #\r
-# (at your option) any later version.                                         #\r
-#                                                                             #\r
-# This program is distributed in the hope that it will be useful,             #\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of              #\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #\r
-# GNU General Public License for more details.                                #\r
-#                                                                             #\r
-# You should have received a copy of the GNU General Public License           #\r
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #\r
-#                                                                             #\r
-###############################################################################\r
-\r
-use strict;\r
-\r
-# enable only the following on debugging purpose\r
-#use warnings;\r
-#use CGI::Carp 'fatalsToBrowser';\r
-\r
-require '/var/ipfire/general-functions.pl';\r
-require "${General::swroot}/lang.pl";\r
-require "${General::swroot}/header.pl";\r
-require "${General::swroot}/graphs.pl";\r
-\r
-my %sensorsettings = ();\r
-my %cgiparams=();\r
-my @cgigraphs=();\r
-my $rrdlog = "/var/log/rrd";\r
-\r
-&Header::showhttpheaders();\r
-\r
-my $graphdir = "/srv/web/ipfire/html/graphs";\r
-\r
-$ENV{'QUERY_STRING'} =~ s/&//g;\r
-@cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});\r
-$cgigraphs[1] = '' unless defined $cgigraphs[1];\r
-\r
-my @sensorsgraphs = ();\r
-my @sensorsdir = `ls -dA $rrdlog/collectd/localhost/sensors-*/`;\r
-foreach (@sensorsdir)\r
-{\r
-       chomp($_);chop($_);\r
-       foreach (`ls $_/*`){\r
-               chomp($_);\r
-               push(@sensorsgraphs,$_);\r
-       }\r
-}\r
-\r
-&Header::getcgihash(\%sensorsettings);\r
-\r
-if ( $sensorsettings{'ACTION'} eq $Lang::tr{'save'} ) {\r
-       foreach(@sensorsgraphs){\r
-               chomp($_);\r
-                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;\r
-                       my $label = $2.$3;$label=~ s/-//g;\r
-                       if ( $sensorsettings{'LINE-'.$label} ne "on" ){$sensorsettings{'LINE-'.$label} = 'off';}\r
-                       elsif ( $sensorsettings{'LINE-'.$label} eq "on" ){$sensorsettings{'LINE-'.$label} = 'checked';}\r
-       }\r
-        &General::writehash("${General::swroot}/sensors/settings", \%sensorsettings);\r
-}\r
-\r
-my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;\r
-\r
-&Header::openpage($Lang::tr{'harddisk temperature graphs'}, 1, '');\r
-&Header::openbigbox('100%', 'left');\r
-\r
-if ($cgigraphs[1] =~ /hwtemp/) {&Graphs::updatehwtempgraph ("hour");&Graphs::updatehwtempgraph ("week");&Graphs::updatehwtempgraph ("month");&Graphs::updatehwtempgraph ("year");graphbox("hwtemp");}\r
-elsif ($cgigraphs[1] =~ /hwfan/) {&Graphs::updatehwfangraph ("hour");&Graphs::updatehwfangraph ("week");&Graphs::updatehwfangraph ("month");&Graphs::updatehwfangraph ("year");graphbox("hwfan");}\r
-elsif ($cgigraphs[1] =~ /hwvolt/) {&Graphs::updatehwvoltgraph ("hour");&Graphs::updatehwvoltgraph ("week");&Graphs::updatehwvoltgraph ("month");&Graphs::updatehwvoltgraph ("year");graphbox("hwvolt");}\r
-elsif ($cgigraphs[1] =~ /hddtemp/) {\r
- foreach (@disks){\r
-  my $disk = $_;\r
-  chomp $disk;\r
-  my @array = split(/\//,$disk);\r
-  &Graphs::updatehddgraph ($array[$#array],"week");&Graphs::updatehddgraph ($array[$#array],"month");&Graphs::updatehddgraph ($array[$#array],"year");\r
-  hddtempbox($array[$#array]);\r
-       }\r
-}\r
-else\r
-{\r
- &Graphs::updatehwtempgraph ("day");&Graphs::updatehwfangraph ("day");&Graphs::updatehwvoltgraph ("day");\r
- foreach (@disks){\r
-  my $disk = $_;\r
-  chomp $disk;\r
-  my @array = split(/\//,$disk);\r
-  &Graphs::updatehddgraph ($array[$#array],"day");\r
-       if (-e "$graphdir/hddtemp-$disk-day.png") {\r
-\r
-         &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");\r
-         my $ftime = localtime((stat("$graphdir/hddtemp-$disk-day.png"))[9]);\r
-         print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r
-         print "<a href='/cgi-bin/hardwaregraphs.cgi?graph=hddtemp'>";\r
-         print "<img src='/graphs/hddtemp-$disk-day.png' border='0' />";\r
-               print "</a>";\r
-         print "<br />\n";\r
-        &Header::closebox();\r
-               }\r
-  }\r
-\r
- my @graphs = ("hwtemp","hwfan","hwvolt");\r
- foreach (@graphs){\r
-                                                                       &Header::openbox('100%', 'center', "$_ $Lang::tr{'graph'}");\r
-                                                                       if (-e "$graphdir/sensors-$_-day.png"){\r
-                                                                                       my $ftime = localtime((stat("$graphdir/sensors-$_-day.png"))[9]);\r
-                                                                                       print "<center>";\r
-                                                                                       print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r
-                                                                               print "<a href='/cgi-bin/hardwaregraphs.cgi?graph=$_'>";\r
-                                                                                       print "<img src='/graphs/sensors-$_-day.png' border='0' />";\r
-                                                                                       print "</a><hr />";\r
-                                                                       }\r
-                                                                       else{print $Lang::tr{'no information available'};}\r
-                                                                       &Header::closebox();\r
- }\r
-       sensorsbox();\r
-}\r
-\r
-&Header::closebigbox();\r
-&Header::closepage();\r
-\r
-sub hddtempbox {\r
- my $disk = $_[0];\r
-    if (-e "$graphdir/hddtemp-$disk-week.png") {\r
-\r
-         &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");\r
-         my $ftime = localtime((stat("$graphdir/hddtemp-$disk-week.png"))[9]);\r
-         print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r
-         print "<img src='/graphs/hddtemp-$disk-week.png' border='0' />";\r
-         print "<br />\n";\r
-        &Header::closebox();\r
-  }\r
-      if (-e "$graphdir/hddtemp-$disk-month.png") {\r
-\r
-         &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");\r
-         my $ftime = localtime((stat("$graphdir/hddtemp-$disk-month.png"))[9]);\r
-         print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r
-         print "<img src='/graphs/hddtemp-$disk-month.png' border='0' />";\r
-         print "<br />\n";\r
-        &Header::closebox();\r
-  }\r
-      if (-e "$graphdir/hddtemp-$disk-year.png") {\r
-\r
-         &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");\r
-         my $ftime = localtime((stat("$graphdir/hddtemp-$disk-year.png"))[9]);\r
-         print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r
-         print "<img src='/graphs/hddtemp-$disk-year.png' border='0' />";\r
-         print "<br />\n";\r
-        &Header::closebox();\r
-  }\r
-}\r
-\r
-sub graphbox {\r
- my $graph = $_[0];\r
\r
-       &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}");\r
-       if (-e "$graphdir/sensors-$graph-week.png"){\r
-                        my $ftime = localtime((stat("$graphdir/sensors-$graph-week.png"))[9]);\r
-                        print "<center>";\r
-                        print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r
-                        print "<img src='/graphs/sensors-$graph-week.png' border='0' /><hr />";\r
-        }\r
-        else{print $Lang::tr{'no information available'};}\r
-        &Header::closebox();\r
-       &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}");\r
-       if (-e "$graphdir/sensors-$graph-month.png"){\r
-                        my $ftime = localtime((stat("$graphdir/sensors-$graph-month.png"))[9]);\r
-                        print "<center>";\r
-                        print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r
-                        print "<img src='/graphs/sensors-$graph-month.png' border='0' /><hr />";\r
-        }\r
-        else{print $Lang::tr{'no information available'};}\r
-        &Header::closebox();\r
-       &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}");\r
-       if (-e "$graphdir/sensors-$graph-year.png"){\r
-                        my $ftime = localtime((stat("$graphdir/sensors-$graph-year.png"))[9]);\r
-                        print "<center>";\r
-                        print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";\r
-                        print "<img src='/graphs/sensors-$graph-year.png' border='0' /><hr />";\r
-        }\r
-        else{print $Lang::tr{'no information available'};}\r
-        &Header::closebox();\r
-}\r
-\r
-sub sensorsbox{\r
-\r
- &Header::openbox('100%', 'center', "$Lang::tr{'mbmon settings'}");\r
- if ( $cgiparams{'ACTION'} eq $Lang::tr{'save'} ){print "Test";}\r
-\r
- print <<END\r
- <form method='post' action='$ENV{'SCRIPT_NAME'}'>\r
- <table width='100%' border='0' cellspacing='5' cellpadding='0' align='center'>\r
- <tr><td align='right' width='40%'><b>$Lang::tr{'mbmon display'}</b></td>\r
-                <td align='left'><b>$Lang::tr{'mbmon label'}</b></td>\r
- </tr>\r
-END\r
-;\r
-foreach (@sensorsgraphs){\r
-               $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;\r
-               my $label = $2.$3;$label=~ s/-//g;\r
-               $sensorsettings{'LABEL-'.$label}="$label";\r
-               $sensorsettings{'LINE-'.$label}="checked";\r
-               &General::readhash("${General::swroot}/sensors/settings", \%sensorsettings);\r
-               print("<tr><td align='right'><input type='checkbox' name='LINE-$label' $sensorsettings{'LINE-'.$label} /></td>");\r
-               print("<td><input type='text' name='LABEL-$label' value='$sensorsettings{'LABEL-'.$label}' size='25' /></td></tr>\n");\r
-}\r
- print <<END\r
- <tr><td align='center' colspan='2' ><input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td></tr>\r
- </table>\r
- </form>\r
-END\r
-;\r
- &Header::closebox();\r
-}\r
+#!/usr/bin/perl
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# 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;
+
+# enable only the following on debugging purpose
+#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";
+
+my %sensorsettings = ();
+my %cgiparams=();
+my @cgigraphs=();
+my $rrdlog = "/var/log/rrd";
+
+&Header::showhttpheaders();
+
+my $graphdir = "/srv/web/ipfire/html/graphs";
+
+$ENV{'QUERY_STRING'} =~ s/&//g;
+@cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
+$cgigraphs[1] = '' unless defined $cgigraphs[1];
+
+my @sensorsgraphs = ();
+my @sensorsdir = `ls -dA $rrdlog/collectd/localhost/sensors-*/`;
+foreach (@sensorsdir)
+{
+       chomp($_);chop($_);
+       foreach (`ls $_/*`){
+               chomp($_);
+               push(@sensorsgraphs,$_);
+       }
+}
+
+&Header::getcgihash(\%sensorsettings);
+
+if ( $sensorsettings{'ACTION'} eq $Lang::tr{'save'} ) {
+       foreach(@sensorsgraphs){
+               chomp($_);
+                       $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+                       my $label = $2.$3;$label=~ s/-//g;
+                       if ( $sensorsettings{'LINE-'.$label} ne "on" ){$sensorsettings{'LINE-'.$label} = 'off';}
+                       elsif ( $sensorsettings{'LINE-'.$label} eq "on" ){$sensorsettings{'LINE-'.$label} = 'checked';}
+       }
+        &General::writehash("${General::swroot}/sensors/settings", \%sensorsettings);
+}
+
+my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
+
+&Header::openpage($Lang::tr{'harddisk temperature graphs'}, 1, '');
+&Header::openbigbox('100%', 'left');
+
+if ($cgigraphs[1] =~ /hwtemp/) {&Graphs::updatehwtempgraph ("hour");&Graphs::updatehwtempgraph ("week");&Graphs::updatehwtempgraph ("month");&Graphs::updatehwtempgraph ("year");graphbox("hwtemp");}
+elsif ($cgigraphs[1] =~ /hwfan/) {&Graphs::updatehwfangraph ("hour");&Graphs::updatehwfangraph ("week");&Graphs::updatehwfangraph ("month");&Graphs::updatehwfangraph ("year");graphbox("hwfan");}
+elsif ($cgigraphs[1] =~ /hwvolt/) {&Graphs::updatehwvoltgraph ("hour");&Graphs::updatehwvoltgraph ("week");&Graphs::updatehwvoltgraph ("month");&Graphs::updatehwvoltgraph ("year");graphbox("hwvolt");}
+elsif ($cgigraphs[1] =~ /hddtemp/) {
+ foreach (@disks){
+  my $disk = $_;
+  chomp $disk;
+  my @array = split(/\//,$disk);
+  &Graphs::updatehddgraph ($array[$#array],"week");&Graphs::updatehddgraph ($array[$#array],"month");&Graphs::updatehddgraph ($array[$#array],"year");
+  hddtempbox($array[$#array]);
+       }
+}
+else
+{
+ &Graphs::updatehwtempgraph ("day");&Graphs::updatehwfangraph ("day");&Graphs::updatehwvoltgraph ("day");
+ foreach (@disks){
+  my $disk = $_;
+  chomp $disk;
+  my @array = split(/\//,$disk);
+  &Graphs::updatehddgraph ($array[$#array],"day");
+       if (-e "$graphdir/hddtemp-$disk-day.png") {
+
+         &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
+         my $ftime = localtime((stat("$graphdir/hddtemp-$disk-day.png"))[9]);
+         print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
+         print "<a href='/cgi-bin/hardwaregraphs.cgi?graph=hddtemp'>";
+         print "<img src='/graphs/hddtemp-$disk-day.png' border='0' />";
+               print "</a>";
+         print "<br />\n";
+        &Header::closebox();
+               }
+  }
+
+ my @graphs = ("hwtemp","hwfan","hwvolt");
+ foreach (@graphs){
+       &Header::openbox('100%', 'center', "$_ $Lang::tr{'graph'}");
+       if (-e "$graphdir/sensors-$_-day.png"){
+           my $ftime = localtime((stat("$graphdir/sensors-$_-day.png"))[9]);
+           print "<center>";
+           print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
+           print "<a href='/cgi-bin/hardwaregraphs.cgi?graph=$_'>";
+           print "<img src='/graphs/sensors-$_-day.png' border='0' />";
+           print "</a><hr />";
+           }
+           else{print $Lang::tr{'no information available'};}
+       &Header::closebox();
+ }
+       sensorsbox();
+}
+
+&Header::closebigbox();
+&Header::closepage();
+
+sub hddtempbox {
+ my $disk = $_[0];
+    if (-e "$graphdir/hddtemp-$disk-week.png") {
+
+         &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
+         my $ftime = localtime((stat("$graphdir/hddtemp-$disk-week.png"))[9]);
+         print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
+         print "<img src='/graphs/hddtemp-$disk-week.png' border='0' />";
+         print "<br />\n";
+        &Header::closebox();
+  }
+      if (-e "$graphdir/hddtemp-$disk-month.png") {
+
+         &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
+         my $ftime = localtime((stat("$graphdir/hddtemp-$disk-month.png"))[9]);
+         print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
+         print "<img src='/graphs/hddtemp-$disk-month.png' border='0' />";
+         print "<br />\n";
+        &Header::closebox();
+  }
+      if (-e "$graphdir/hddtemp-$disk-year.png") {
+
+         &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
+         my $ftime = localtime((stat("$graphdir/hddtemp-$disk-year.png"))[9]);
+         print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
+         print "<img src='/graphs/hddtemp-$disk-year.png' border='0' />";
+         print "<br />\n";
+        &Header::closebox();
+  }
+}
+
+sub graphbox {
+ my $graph = $_[0];
+       &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}");
+       if (-e "$graphdir/sensors-$graph-week.png"){
+                        my $ftime = localtime((stat("$graphdir/sensors-$graph-week.png"))[9]);
+                        print "<center>";
+                        print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
+                        print "<img src='/graphs/sensors-$graph-week.png' border='0' /><hr />";
+        }
+        else{print $Lang::tr{'no information available'};}
+        &Header::closebox();
+       &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}");
+       if (-e "$graphdir/sensors-$graph-month.png"){
+                        my $ftime = localtime((stat("$graphdir/sensors-$graph-month.png"))[9]);
+                        print "<center>";
+                        print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
+                        print "<img src='/graphs/sensors-$graph-month.png' border='0' /><hr />";
+        }
+        else{print $Lang::tr{'no information available'};}
+        &Header::closebox();
+       &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}");
+       if (-e "$graphdir/sensors-$graph-year.png"){
+                        my $ftime = localtime((stat("$graphdir/sensors-$graph-year.png"))[9]);
+                        print "<center>";
+                        print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
+                        print "<img src='/graphs/sensors-$graph-year.png' border='0' /><hr />";
+        }
+        else{print $Lang::tr{'no information available'};}
+        &Header::closebox();
+}
+
+sub sensorsbox{
+
+ &Header::openbox('100%', 'center', "$Lang::tr{'mbmon settings'}");
+ if ( $cgiparams{'ACTION'} eq $Lang::tr{'save'} ){print "Test";}
+
+ print <<END
+ <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <table width='100%' border='0' cellspacing='5' cellpadding='0' align='center'>
+ <tr><td align='right' width='40%'><b>$Lang::tr{'mbmon display'}</b></td>
+                <td align='left'><b>$Lang::tr{'mbmon label'}</b></td>
+ </tr>
+END
+;
+foreach (@sensorsgraphs){
+               $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+               my $label = $2.$3;$label=~ s/-//g;
+               $sensorsettings{'LABEL-'.$label}="$label";
+               $sensorsettings{'LINE-'.$label}="checked";
+               &General::readhash("${General::swroot}/sensors/settings", \%sensorsettings);
+               print("<tr><td align='right'><input type='checkbox' name='LINE-$label' $sensorsettings{'LINE-'.$label} /></td>");
+               print("<td><input type='text' name='LABEL-$label' value='$sensorsettings{'LABEL-'.$label}' size='25' /></td></tr>\n");
+}
+ print <<END
+ <tr><td align='center' colspan='2' ><input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td></tr>
+ </table>
+ </form>
+END
+;
+ &Header::closebox();
+}