X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=config%2Fcfgroot%2Fgraphs.pl;h=d3063929a8879a02705cbeb65de860132332e93e;hp=8523f61170b368e897ba151961eee6e73d8065fc;hb=6257cba2694fad77371004bd22d9d5b4b22b77f6;hpb=a332b303e428b5fa8f15e234b84d687c33b9f14a diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index 8523f61170..d3063929a8 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -17,24 +17,38 @@ 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 %mbmonsettings = (); &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); -my %mbmon_settings = (); -&General::readhash("${General::swroot}/mbmon/settings", \%mbmon_settings); -my %mbmon_values = (); -if ( -e "/var/log/mbmon-values" ){ -&General::readhash("/var/log/mbmon-values", \%mbmon_values); -} +# If the collection deamon is working and collecting mbmon data there will be +# some data source named after a common scheme, with the mbmonsettingsfile +# 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 enter +# custom graph names in order to change temp0 to cpu or motherboad my $key; my $value; my @args = (); my $count = 0; - +my @mbmongraphs = (); +if ( -e "/var/log/rrd/collectd/localhost/mbmon" ){ + @mbmongraphs = `ls /var/log/rrd/collectd/localhost/mbmon/`; + foreach (@mbmongraphs){ + chomp($_); + my @name=split(/\./,$_);my $label = $name[0]; $label=~ s/-//; + $mbmonsettings{'LABEL-'.$name[0]}="$label"; + $mbmonsettings{'LINE-'.$name[0]}="checked"; + } + } + +&General::readhash("${General::swroot}/mbmon/settings", \%mbmonsettings); use Encode 'from_to'; my %tr=(); @@ -50,39 +64,69 @@ if ((${Lang::language} eq 'el') || %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 cpu´s is working sub updatecpugraph { - my $period = $_[0]; - - RRDs::graph ("$graphs/cpu-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org",, "-v $Lang::tr{'percentage'}", - "--alt-y-grid", "-w 600", "-h 150", "-l 0", "-u 100", "-r", + 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}", - "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", - "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:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j", + "-t $Lang::tr{'cpu usage per'} $Lang::tr{$period}"); + + if ( -e "/var/log/rrd/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%%", @@ -123,28 +167,32 @@ sub updatecpugraph { "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 150", "-i", "-z", "-W www.ipfire.org", "-l 0", "-r", "--alt-y-grid", - "-t Load Average $Lang::tr{'graph per'} $Lang::tr{$period}", + "-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, letzter:", + "AREA:load1".$color{"color13"}."A0:1 Minute:", "GPRINT:load1:LAST:%5.2lf", - "AREA:load5".$color{"color18"}."A0:5 Minuten, letzter:", + "AREA:load5".$color{"color18"}."A0:5 Minuten:", "GPRINT:load5:LAST:%5.2lf", - "AREA:load15".$color{"color14"}."A0:15 Minuten, letzter:", + "AREA:load15".$color{"color14"}."A0:15 Minuten:", "GPRINT:load15:LAST:%5.2lf\\j", "LINE1:load5".$color{"color13"}, "LINE1:load1".$color{"color18"}); @@ -152,12 +200,14 @@ sub updateloadgraph { 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 150", "-l 0", "-u 100", "-r", + "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r", "--color", "SHADEA".$color{"color19"}, "--color", "SHADEB".$color{"color19"}, "--color", "BACK".$color{"color21"}, @@ -171,11 +221,11 @@ sub updatememgraph { "CDEF:bufferpct=buffer,total,/,100,*", "CDEF:cachepct=cache,total,/,100,*", "CDEF:freepct=free,total,/,100,*", - "COMMENT:$Lang::".sprintf("%-29s",$Lang::tr{'caption'}), - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j", + "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%%", @@ -201,7 +251,7 @@ sub updatememgraph { 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 150", "-l 0", "-u 100", "-r", + "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r", "--color", "SHADEA".$color{"color19"}, "--color", "SHADEB".$color{"color19"}, "--color", "BACK".$color{"color21"}, @@ -213,11 +263,11 @@ sub updatememgraph { "CDEF:usedpct=100,used,total,/,*", "CDEF:freepct=100,free,total,/,*", "CDEF:cachedpct=100,cached,total,/,*", - "COMMENT:$Lang::".sprintf("%-29s",$Lang::tr{'caption'}), - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j", + "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%%", @@ -237,13 +287,15 @@ sub updatememgraph { 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 150", "-r", "-z", + "--alt-y-grid", "-w 600", "-h 125", "-r", "-z", "--color", "SHADEA".$color{"color19"}, "--color", "SHADEB".$color{"color19"}, "--color", "BACK".$color{"color21"}, @@ -253,13 +305,13 @@ sub updatediskgraph { "CDEF:writen=write,-1,*", "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE", "CDEF:st=standby,INF,*", - "COMMENT:$Lang::".sprintf("%-25s",$Lang::tr{'caption'}), - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j", - "AREA:st".$color{"color20"}.":standby\\j", - "AREA:read".$color{"color14"}."A0:".sprintf("%-25s",$Lang::tr{'read bytes'}), + "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: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", @@ -273,13 +325,15 @@ sub updatediskgraph { 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 150", "-z", "-r", + "--alt-y-grid", "-w 600", "-h 125", "-z", "-r", "--color", "SHADEA".$color{"color19"}, "--color", "SHADEB".$color{"color19"}, "--color", "BACK".$color{"color21"}, @@ -288,17 +342,17 @@ sub updateifgraph { "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:$Lang::".sprintf("%-20s",$Lang::tr{'caption'}), - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j", - "AREA:incoming".$color{"color12"}."A0:$Lang::tr{'incoming traffic in bytes per second'}", + "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:$Lang::tr{'outgoing traffic in bytes per second'}", + "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", @@ -307,11 +361,13 @@ sub updateifgraph { 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 150", "-r", "-v $Lang::tr{'bytes per second'}", + "--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"}, @@ -321,11 +377,11 @@ sub updatefwhitsgraph { "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:$Lang::".sprintf("%-20s",$Lang::tr{'caption'}), - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j", + "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", @@ -337,33 +393,36 @@ sub updatefwhitsgraph { "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; + 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 150", "-l 0", "-r", "-v ms", + "--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:r0=roundtrip,30,-", - "CDEF:r1=r0,70,-", - "CDEF:r2=r1,150,-", - "CDEF:r3=r2,300,-", - "AREA:r0".$color{"color12"}."A0:<30 ms", - "STACK:r1".$color{"color17"}."A0:30-70 ms", - "STACK:r2".$color{"color14"}."A0:70-150 ms", - "STACK:r3".$color{"color18"}."A0:150-300 ms", - "STACK:roundtrip".$color{"color25"}.":>300 ms\\j", - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\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", @@ -373,6 +432,8 @@ sub updatelqgraph { 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]; @@ -380,7 +441,7 @@ sub updatehddgraph { RRDs::graph ("$graphs/hddtemp-$disk-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", - "--alt-y-grid", "-w 600", "-h 150", + "--alt-y-grid", "-w 600", "-h 125", "--color", "SHADEA".$color{"color19"}, "--color", "SHADEB".$color{"color19"}, "--color", "BACK".$color{"color21"}, @@ -388,8 +449,8 @@ sub updatehddgraph { "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE", "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE", "CDEF:st=standby,INF,*", - "AREA:st".$color{"color20"}.":standby", - "LINE2:temperature".$color{"color11"}.":$Lang::tr{'hdd temperature in'} C\\j", + "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'}", @@ -403,131 +464,7 @@ sub updatehddgraph { print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR; } -sub updatetempgraph -{ - my $type = "temp"; - my $period = $_[0]; - my $count = "11"; - - @args = ("$graphs/mbmon-$type-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", - "--alt-y-grid", "-w 600", "-h 150", "--alt-autoscale", - "--color", "SHADEA".$color{"color19"}, - "--color", "SHADEB".$color{"color19"}, - "--color", "BACK".$color{"color21"}, - "-t $Lang::tr{'mbmon temp'} ($Lang::tr{'graph per'} $Lang::tr{$period})", - "COMMENT:$Lang::tr{'caption'}\\t\\t", - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j",); - - foreach $key ( sort(keys %mbmon_values) ) - { - if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') ) - { - if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') ) - { - $mbmon_settings{'LABEL-'.$key} = $key; - } - push (@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE"); - push (@args, "LINE2:".$key.$color{"color$count"}.":$mbmon_settings{'LABEL-'.$key} Grad C"); - push (@args, "GPRINT:$key:MAX:%3.1lf"); - push (@args, "GPRINT:$key:AVERAGE:%3.1lf"); - push (@args, "GPRINT:$key:MIN:%3.1lf"); - push (@args, "GPRINT:$key:LAST:%3.1lf\\j"); - $count++; - } - } - - RRDs::graph ( @args ); - $ERROR = RRDs::error; - print("Error in RRD::graph for temp: $ERROR\n")if $ERROR; -} - -sub updatefangraph -{ - my $type = "fan"; - my $period = $_[0]; - my $count = "11"; - - @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", - "--alt-y-grid", "-w 600", "-h 150", "--alt-autoscale", - "--color", "SHADEA".$color{"color19"}, - "--color", "SHADEB".$color{"color19"}, - "--color", "BACK".$color{"color21"}, - "-t $Lang::tr{'mbmon fan'} ($Lang::tr{'graph per'} $Lang::tr{$period})", - "COMMENT:$Lang::tr{'caption'}\\t\\t", - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j",); - - foreach $key ( sort(keys %mbmon_values) ) - { - if ( (index($key, $type) != -1) && ($mbmon_settings{'LINE-'.$key} eq 'on') ) - { - if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') ) - { - $mbmon_settings{'LABEL-'.$key} = $key; - } - - push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE"); - push(@args, "LINE2:".$key.$color{"color$count"}.":$mbmon_settings{'LABEL-'.$key} rpm"); - push(@args, "GPRINT:$key:MAX:%5.0lf"); - push(@args, "GPRINT:$key:AVERAGE:%5.0lf"); - push(@args, "GPRINT:$key:MIN:%5.0lf"); - push(@args, "GPRINT:$key:LAST:%5.0lf\\j"); - $count++; - } - } - RRDs::graph ( @args ); - $ERROR = RRDs::error; - print("Error in RRD::graph for temp: $ERROR\n")if $ERROR; -} - -sub updatevoltgraph -{ - my $type = "volt"; - my $period = $_[0]; - my $count = "11"; - - @args = ("$graphs/mbmon-$type-$period.png", "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", - "--alt-y-grid", "-w 600", "-h 150", "--alt-autoscale", - "--color", "SHADEA".$color{"color19"}, - "--color", "SHADEB".$color{"color19"}, - "--color", "BACK".$color{"color21"}, - "-t $Lang::tr{'mbmon volt'} ($Lang::tr{'graph per'} $Lang::tr{$period})", - "COMMENT:$Lang::tr{'caption'}\\t", - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j",); - - foreach $key ( sort(keys %mbmon_values) ) - { - my $v = substr($key,0,1); - if ( ($v eq 'v') && ($mbmon_settings{'LINE-'.$key} eq 'on') ) - { - if ( !defined($mbmon_settings{'LABEL-'.$key}) || ($mbmon_settings{'LABEL-'.$key} eq '') ) - { - $mbmon_settings{'LABEL-'.$key} = $key; - } - - push(@args, "DEF:$key=$rrdlog/mbmon.rrd:$key:AVERAGE"); - push(@args, "LINE2:".$key.$color{"color$count"}.":$mbmon_settings{'LABEL-'.$key} Volt"); - push(@args, "GPRINT:$key:MAX:%3.2lf"); - push(@args, "GPRINT:$key:AVERAGE:%3.2lf"); - push(@args, "GPRINT:$key:MIN:%3.2lf"); - push(@args, "GPRINT:$key:LAST:%3.2lf\\j"); - $count++; - } - } - - RRDs::graph ( @args ); - $ERROR = RRDs::error; - print("Error in RRD::graph for temp: $ERROR\n")if $ERROR; -} +# Generate the QoS Graph for the current period of time sub overviewgraph { @@ -556,15 +493,15 @@ sub overviewgraph { my $color="#000000"; my @command=("/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'DEV'}-$period.png", "--start", $periodstring, "-aPNG", "-i", "-z", "-W www.ipfire.org", - "--alt-y-grid", "-w 600", "-h 150", "-r", + "--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:$Lang::tr{'caption'}\\t\\t\\t\\t ", - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j", + "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"; @@ -584,10 +521,10 @@ sub overviewgraph { push(@command, "STACK:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8])); } - push(@command, "GPRINT:$classline[1]:MAX:%5.2lf"); - push(@command, "GPRINT:$classline[1]:AVERAGE:%5.2lf"); - push(@command, "GPRINT:$classline[1]:MIN:%5.2lf"); - push(@command, "GPRINT:$classline[1]:LAST:%5.2lf\\j"); + 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++; } } @@ -596,6 +533,96 @@ sub overviewgraph { print "$ERROR"; } +# Generate the Temperature Graph for the current period of time for values given by collecd and mbmon + +sub updatehwtempgraph { + + my $period = $_[0]; + + my @command = ("$graphs/mbmon-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{'mbmon temp'} $Lang::tr{'graph per'} $Lang::tr{$period}"); + + foreach(@mbmongraphs){ + chomp($_); + if ( $_ =~ /temperature/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"DEF:".$mbmonsettings{'LABEL-'.$name[0]}."=$rrdlog/collectd/localhost/mbmon/".$_.":value:AVERAGE"); + } + } + push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"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"); + foreach(@mbmongraphs){ + chomp($_); + if ( $_ =~ /temperature/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"LINE3:".$mbmonsettings{'LABEL-'.$name[0]}.random_hex_color(6)."A0:".sprintf("%-25s",$mbmonsettings{'LABEL-'.$name[0]}), + "GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MAX:%3.2lf C","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":AVERAGE:%3.2lf C","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MIN:%3.2lf C","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":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 mbmon + +sub updatehwvoltgraph { + + my $period = $_[0]; + + my @command = ("$graphs/mbmon-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(@mbmongraphs){ + chomp($_); + if ( $_ =~ /voltage/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"DEF:".$mbmonsettings{'LABEL-'.$name[0]}."=$rrdlog/collectd/localhost/mbmon/".$_.":value:AVERAGE");} + } + push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"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"); + foreach(@mbmongraphs){ + chomp($_); + if ( $_ =~ /voltage/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"LINE3:".$mbmonsettings{'LABEL-'.$name[0]}.random_hex_color(6)."A0:".sprintf("%-25s",$mbmonsettings{'LABEL-'.$name[0]}), + "GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MAX:%3.2lf V","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":AVERAGE:%3.2lf V","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MIN:%3.2lf V","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":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 mbmon + +sub updatehwfangraph { + + my $period = $_[0]; + + my @command = ("$graphs/mbmon-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(@mbmongraphs){ + chomp($_); + if ( $_ =~ /fanspeed/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"DEF:".$mbmonsettings{'LABEL-'.$name[0]}."=$rrdlog/collectd/localhost/mbmon/".$_.":value:AVERAGE");} + } + push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"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"); + foreach(@mbmongraphs){ + chomp($_); + if ( $_ =~ /fanspeed/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"LINE3:".$mbmonsettings{'LABEL-'.$name[0]}.random_hex_color(6)."A0:".sprintf("%-25s",$mbmonsettings{'LABEL-'.$name[0]}), + "GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MAX:%5.0lf RPM","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":AVERAGE:%5.0lf RPM","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MIN:%5.0lf RPM","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":LAST:%5.0lf RPM\\j",);} + } + 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$/;