From: Arne Fitzenreiter Date: Sat, 2 Aug 2008 09:22:30 +0000 (+0200) Subject: Add cpufreq graph X-Git-Tag: v2.3-beta3~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0950b1ec8eff6e1e8b700a23193cdfc5bb9989dc;p=ipfire-2.x.git Add cpufreq graph --- diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index 229ee20c6c..9ecc249a78 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -178,6 +178,58 @@ sub updatecpugraph { print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR; } +# Generate the CPU Frequency Graph for the current period of time for values given by +# only 1 or 2 cpus is working +sub updatecpufreqgraph { + if ( -e "$rrdlog/collectd/localhost/cpufreq/cpufreq-0.rrd" ){ + + my $period = $_[0]; + my @command = ("$graphs/cpufreq-$period.png", + "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v Mhz", + "-w 600", "-h 125", "-r", + "--color", "SHADEA".$color{"color19"}, + "--color", "SHADEB".$color{"color19"}, + "--color", "BACK".$color{"color21"}, + "-t $Lang::tr{'cpu frequency per'} $Lang::tr{$period}"); + + if ( -e "$rrdlog/collectd/localhost/cpufreq/cpufreq-1.rrd" ){ + push(@command,"DEF:cpu1_=$rrdlog/collectd/localhost/cpufreq/cpufreq-1.rrd:value:AVERAGE"); + } + push(@command,"DEF:cpu0_=$rrdlog/collectd/localhost/cpufreq/cpufreq-0.rrd:value:AVERAGE"); + + if ( -e "$rrdlog/collectd/localhost/cpufreq/cpufreq-1.rrd" ){ + push(@command,"CDEF:cpu1=cpu1_,1000000,/"); + } + push(@command,"CDEF:cpu0=cpu0_,1000000,/"); + + if ( -e "$rrdlog/collectd/localhost/cpufreq/cpufreq-1.rrd" ){ + push(@command,"LINE1:cpu1".$color{"color11"}."A0:cpu 1\\j", + "COMMENT:$Lang::tr{'maximal'}", + "COMMENT:$Lang::tr{'average'}", + "COMMENT:$Lang::tr{'minimal'}", + "COMMENT:$Lang::tr{'current'}\\j", + "GPRINT:cpu1:MAX:%3.0lf Mhz", + "GPRINT:cpu1:AVERAGE:%3.0lf Mhz", + "GPRINT:cpu1:MIN:%3.0lf Mhz", + "GPRINT:cpu1:LAST:%3.0lf Mhz\\j",); + } + push(@command,"LINE2:cpu0".$color{"color12"}."A1:cpu 0\\j", + "COMMENT:$Lang::tr{'maximal'}", + "COMMENT:$Lang::tr{'average'}", + "COMMENT:$Lang::tr{'minimal'}", + "COMMENT:$Lang::tr{'current'}\\j", + "GPRINT:cpu0:MAX:%3.0lf Mhz", + "GPRINT:cpu0:AVERAGE:%3.0lf Mhz", + "GPRINT:cpu0:MIN:%3.0lf Mhz", + "GPRINT:cpu0:LAST:%3.0lf Mhz\\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 { @@ -205,6 +257,7 @@ 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 { diff --git a/html/cgi-bin/graphs.cgi b/html/cgi-bin/graphs.cgi index e3d444c28f..9b397900f2 100644 --- a/html/cgi-bin/graphs.cgi +++ b/html/cgi-bin/graphs.cgi @@ -48,6 +48,7 @@ $cgigraphs[1] = '' unless defined $cgigraphs[1]; $cgigraphs[2] = '' unless defined $cgigraphs[2]; if ($cgigraphs[1] =~ /(load)/) {&Graphs::updateloadgraph ("hour");&Graphs::updateloadgraph ("week");&Graphs::updateloadgraph ("month");&Graphs::updateloadgraph ("year");} +elsif ($cgigraphs[1] =~ /(cpufreq)/) {&Graphs::updatecpufreqgraph ("hour");&Graphs::updatecpufreqgraph ("week");&Graphs::updatecpufreqgraph ("month");&Graphs::updatecpufreqgraph ("year");} elsif ($cgigraphs[1] =~ /(cpu)/) {&Graphs::updatecpugraph ("hour");&Graphs::updatecpugraph ("week");&Graphs::updatecpugraph ("month");&Graphs::updatecpugraph ("year");} elsif ($cgigraphs[1] =~ /(processes)/) {&Graphs::updateprocessesgraph ("hour");&Graphs::updateprocessesgraph ("week");&Graphs::updateprocessesgraph ("month");&Graphs::updateprocessesgraph ("year");} elsif ($cgigraphs[1] =~ /(memory|swap)/) {&Graphs::updatememgraph ("hour");&Graphs::updatememgraph ("week");&Graphs::updatememgraph ("month");&Graphs::updatememgraph ("year");} @@ -135,7 +136,7 @@ elsif ($cgigraphs[1] =~ /(green|blue|orange|red|ppp|ipsec|cpu|memory|swap|disk|l } print "
"; -if ( $cgigraphs[1] eq "cpu" || $cgigraphs[1] eq "load" ) { print ""; } +if ( $cgigraphs[1] eq "cpu" || $cgigraphs[1] eq "cpufreq" || $cgigraphs[1] eq "load" ) { print ""; } elsif ( $cgigraphs[1] eq "memory" || $cgigraphs[1] eq "swap" ) { print ""; } elsif ( $cgigraphs[1] eq "processes" ) { print ""; } elsif ( $cgigraphs[1] =~ /disk/ ) { print ""; } diff --git a/html/cgi-bin/system.cgi b/html/cgi-bin/system.cgi index 8f79970826..5d852176b9 100644 --- a/html/cgi-bin/system.cgi +++ b/html/cgi-bin/system.cgi @@ -39,6 +39,7 @@ my %cgiparams=(); # Generate Graphs from rrd Data &Graphs::updatecpugraph ("day"); +&Graphs::updatecpufreqgraph ("day"); &Graphs::updateloadgraph ("day"); &Header::showhttpheaders(); @@ -59,6 +60,17 @@ if (-e "$Header::graphdir/cpu-day.png") { print "
\n"; &Header::closebox(); +if (-e "$Header::graphdir/cpufreq-day.png") { + &Header::openbox('100%', 'center', "CPU Frequency $Lang::tr{'graph'}"); + my $ftime = localtime((stat("$Header::graphdir/cpufreq-day.png"))[9]); + print "
$Lang::tr{'the statistics were last updated at'}: $ftime

\n"; + print "
"; + print ""; + print ""; + print "
\n"; + &Header::closebox(); +} + &Header::openbox('100%', 'center', "Load $Lang::tr{'graph'}"); if (-e "$Header::graphdir/load-day.png") { my $ftime = localtime((stat("$Header::graphdir/load-day.png"))[9]);