Graphen Hintergrundfarbe bei Standarttheme auf weiss gesetzt

Config Types in der Nettraffic angepasst
Erstellung der Week Month und Year Graphen nur noch bei Request


git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@573 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
maniacikarus
2007-05-22 19:04:48 +00:00
parent 57d5b13817
commit b05768be3b
8 changed files with 81 additions and 73 deletions

View File

@@ -11,12 +11,13 @@
use strict; use strict;
# enable only the following on debugging purpose # enable only the following on debugging purpose
#use warnings; use warnings;
#use CGI::Carp 'fatalsToBrowser'; use CGI::Carp 'fatalsToBrowser';
require '/var/ipfire/general-functions.pl'; require '/var/ipfire/general-functions.pl';
require "${General::swroot}/lang.pl"; require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl"; require "${General::swroot}/header.pl";
require "${General::swroot}/graphs.pl";
my %cgiparams=(); my %cgiparams=();
my %pppsettings=(); my %pppsettings=();
@@ -34,6 +35,24 @@ $ENV{'QUERY_STRING'} =~ s/&//g;
@cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'}); @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
$cgigraphs[1] = '' unless defined $cgigraphs[1]; $cgigraphs[1] = '' unless defined $cgigraphs[1];
if ($cgigraphs[1] =~ /(load)/) {&Graphs::updateloadgraph ("week");&Graphs::updateloadgraph ("month");&Graphs::updateloadgraph ("year");}
if ($cgigraphs[1] =~ /(cpu)/) {&Graphs::updatecpugraph ("week");&Graphs::updatecpugraph ("month");&Graphs::updatecpugraph ("year");}
if ($cgigraphs[1] =~ /(memory|swap)/) {&Graphs::updatememgraph ("week");&Graphs::updatememgraph ("month");&Graphs::updatememgraph ("year");}
if ($cgigraphs[1] =~ /disk/){
my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
foreach (@devices) {
my $device = $_;
chomp($device);
&Graphs::updatediskgraph ("week",$device);
&Graphs::updatediskgraph ("month",$device);
&Graphs::updatediskgraph ("year",$device);}}
if ($cgigraphs[1] =~ /lq/) {&Graphs::updatelqgraph("week");&Graphs::updatelqgraph("month");&Graphs::updatelqgraph("year");}
if ($cgigraphs[1] =~ /RED/) {&Graphs::updateifgraph("RED", "week");&Graphs::updateifgraph("RED", "month");&Graphs::updateifgraph("RED", "year");}
if ($cgigraphs[1] =~ /GREEN/) {&Graphs::updateifgraph("GREEN", "week");&Graphs::updateifgraph("GREEN", "month");&Graphs::updateifgraph("GREEN", "year");}
if ($cgigraphs[1] =~ /BLUE/) {&Graphs::updateifgraph("BLUE", "week");&Graphs::updateifgraph("BLUE", "month");&Graphs::updateifgraph("BLUE", "year");}
if ($cgigraphs[1] =~ /ORANGE/) {&Graphs::updateifgraph("ORANGE", "week");&Graphs::updateifgraph("ORANGE", "month");&Graphs::updateifgraph("ORANGE", "year");}
if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED|lq)/) { if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED|lq)/) {
&Header::openpage($Lang::tr{'network traffic graphs'}, 1, ''); &Header::openpage($Lang::tr{'network traffic graphs'}, 1, '');
} else { } else {

View File

@@ -30,23 +30,11 @@ foreach (@disks){
my $disk = $_; my $disk = $_;
chomp $disk; chomp $disk;
&Graphs::updatehddgraph ($disk,"day"); &Graphs::updatehddgraph ($disk,"day");
&Graphs::updatehddgraph ($disk,"week");
&Graphs::updatehddgraph ($disk,"month");
&Graphs::updatehddgraph ($disk,"year");
} }
&Graphs::updatetempgraph ("day"); &Graphs::updatetempgraph ("day");
&Graphs::updatetempgraph ("week");
&Graphs::updatetempgraph ("month");
&Graphs::updatetempgraph ("year");
&Graphs::updatefangraph ("day"); &Graphs::updatefangraph ("day");
&Graphs::updatefangraph ("week");
&Graphs::updatefangraph ("month");
&Graphs::updatefangraph ("year");
&Graphs::updatevoltgraph ("day"); &Graphs::updatevoltgraph ("day");
&Graphs::updatevoltgraph ("week");
&Graphs::updatevoltgraph ("month");
&Graphs::updatevoltgraph ("year");
my @graphs=(); my @graphs=();
@@ -159,6 +147,19 @@ if ($cgigraphs[1] =~ /hddtemp/)
} }
elsif ($cgigraphs[1] =~ /(temp|fan|volt)/) elsif ($cgigraphs[1] =~ /(temp|fan|volt)/)
{ {
if ($cgigraphs[1] =~ /temp/) {&Graphs::updatetempgraph ("week");&Graphs::updatetempgraph ("month");&Graphs::updatetempgraph ("year");}
if ($cgigraphs[1] =~ /fan/) {&Graphs::updatefangraph ("week");&Graphs::updatefangraph ("month");&Graphs::updatefangraph ("year");}
if ($cgigraphs[1] =~ /volt/) {&Graphs::updatevoltgraph ("week");&Graphs::updatevoltgraph ("month");&Graphs::updatevoltgraph ("year");}
if ($cgigraphs[1] =~ /hddtemp/){
my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
foreach (@devices) {
my $device = $_;
chomp($device);
&Graphs::updatehddgraph ($disk,"week");
&Graphs::updatehddgraph ($disk,"month");
&Graphs::updatehddgraph ($disk,"year");}}
my $graph = $cgigraphs[1]; my $graph = $cgigraphs[1];
my $graphname = $Lang::tr{"mbmon $cgigraphs[1]"}; my $graphname = $Lang::tr{"mbmon $cgigraphs[1]"};
&Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");

View File

@@ -39,8 +39,6 @@ foreach (@devices) {
my $device = $_; my $device = $_;
chomp($device); chomp($device);
&Graphs::updatediskgraph ("day",$device); &Graphs::updatediskgraph ("day",$device);
&Graphs::updatediskgraph ("week",$device);
&Graphs::updatediskgraph ("month",$device);
diskbox("$device"); diskbox("$device");
} }

View File

@@ -22,9 +22,6 @@ require "${General::swroot}/graphs.pl";
my %cgiparams=(); my %cgiparams=();
&Graphs::updatememgraph ("day"); &Graphs::updatememgraph ("day");
&Graphs::updatememgraph ("week");
&Graphs::updatememgraph ("month");
&Graphs::updatememgraph ("year");
&Header::showhttpheaders(); &Header::showhttpheaders();
&Header::getcgihash(\%cgiparams); &Header::getcgihash(\%cgiparams);

View File

@@ -55,19 +55,9 @@ if ($cgiparams[1] =~ /red/) {
foreach my $graphname (@graphs) { foreach my $graphname (@graphs) {
if ($graphname eq "lq" ) if ($graphname eq "lq" )
{ { &Graphs::updatelqgraph("day"); }
&Graphs::updatelqgraph("day");
&Graphs::updatelqgraph("week");
&Graphs::updatelqgraph("month");
&Graphs::updatelqgraph("year");
}
else else
{ { &Graphs::updateifgraph($graphname, "day"); }
&Graphs::updateifgraph($graphname, "day");
&Graphs::updateifgraph($graphname, "week");
&Graphs::updateifgraph($graphname, "month");
&Graphs::updateifgraph($graphname, "year");
}
&Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
if (-e "$Header::graphdir/${graphname}-day.png") { if (-e "$Header::graphdir/${graphname}-day.png") {

View File

@@ -67,13 +67,7 @@ if ($netsettings{'BLUE_DEV'} ne '') {
# Generate Graphs from rrd Data # Generate Graphs from rrd Data
&Graphs::updatecpugraph ("day"); &Graphs::updatecpugraph ("day");
&Graphs::updatecpugraph ("week");
&Graphs::updatecpugraph ("month");
&Graphs::updatecpugraph ("year");
&Graphs::updateloadgraph ("day"); &Graphs::updateloadgraph ("day");
&Graphs::updateloadgraph ("week");
&Graphs::updateloadgraph ("month");
&Graphs::updateloadgraph ("year");
&Header::showhttpheaders(); &Header::showhttpheaders();
&Header::getcgihash(\%cgiparams); &Header::getcgihash(\%cgiparams);

View File

@@ -129,13 +129,13 @@ my $netWidth = '34%';
my $inOutWidth = '17%'; my $inOutWidth = '17%';
# 4 networks # 4 networks
if ($netsettings{'CONFIG_TYPE'} =~ /^(5|7)$/) { if ($netsettings{'CONFIG_TYPE'} =~ /^(4)$/) {
$dateWidth = '12%'; $dateWidth = '12%';
$netWidth = '22%'; $netWidth = '22%';
$inOutWidth = '11%'; $inOutWidth = '11%';
} }
# 3 networks # 3 networks
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|3|4|6)$/) { if ($netsettings{'CONFIG_TYPE'} =~ /^(2|3)$/) {
$dateWidth = '16%'; $dateWidth = '16%';
$netWidth = '28%'; $netWidth = '28%';
$inOutWidth = '14%'; $inOutWidth = '14%';
@@ -148,16 +148,18 @@ print <<END;
<td width='$netWidth' align='center' class='boldbase' ><b>$Lang::tr{'trafficgreen'}</b></td> <td width='$netWidth' align='center' class='boldbase' ><b>$Lang::tr{'trafficgreen'}</b></td>
END END
if ($netsettings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/) { if ($netsettings{'CONFIG_TYPE'} =~ /^(3|4)$/) {
print "<td width='$netWidth' align='center' class='boldbase' ><b>$Lang::tr{'trafficblue'}</b></td>"; print "<td width='$netWidth' align='center' class='boldbase' ><b>$Lang::tr{'trafficblue'}</b></td>";
} }
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/) { if ($netsettings{'CONFIG_TYPE'} =~ /^(2|4)$/) {
print "<td width='$netWidth' align='center' class='boldbase' ><b>$Lang::tr{'trafficorange'}</b></td>"; print "<td width='$netWidth' align='center' class='boldbase' ><b>$Lang::tr{'trafficorange'}</b></td>";
} }
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/) {
print "<td width='$netWidth' align='center' class='boldbase'><b>$Lang::tr{'trafficred'}</b></td>";
}
print <<END; print <<END;
<td width='$netWidth' align='center' class='boldbase'><b>$Lang::tr{'trafficred'}</b></td>
</tr> </tr>
</table> </table>
<table width='100%'> <table width='100%'>
@@ -167,22 +169,23 @@ print <<END;
<td width='$inOutWidth' align='center' class='boldbase'><font color='#16A61D'><b>$Lang::tr{'trafficout'}</b></font></td> <td width='$inOutWidth' align='center' class='boldbase'><font color='#16A61D'><b>$Lang::tr{'trafficout'}</b></font></td>
END END
if ($netsettings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/) if ($netsettings{'CONFIG_TYPE'} =~ /^(3|4)$/)
{ {
print "<td width='$inOutWidth' align='center' class='boldbase'><font color='${Header::colourblue}'><b>$Lang::tr{'trafficin'}</b></font></td>"; print "<td width='$inOutWidth' align='center' class='boldbase'><font color='${Header::colourblue}'><b>$Lang::tr{'trafficin'}</b></font></td>";
print "<td width='$inOutWidth' align='center' class='boldbase'><font color='${Header::colourblue}'><b>$Lang::tr{'trafficout'}</b></font></td>"; print "<td width='$inOutWidth' align='center' class='boldbase'><font color='${Header::colourblue}'><b>$Lang::tr{'trafficout'}</b></font></td>";
} }
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/) if ($netsettings{'CONFIG_TYPE'} =~ /^(2|4)$/)
{ {
print "<td width='$inOutWidth' align='center' class='boldbase'><font color='#FF9933'><b>$Lang::tr{'trafficin'}</b></font></td>"; print "<td width='$inOutWidth' align='center' class='boldbase'><font color='#FF9933'><b>$Lang::tr{'trafficin'}</b></font></td>";
print "<td width='$inOutWidth' align='center' class='boldbase'><font color='#FF9933'><b>$Lang::tr{'trafficout'}</b></font></td>"; print "<td width='$inOutWidth' align='center' class='boldbase'><font color='#FF9933'><b>$Lang::tr{'trafficout'}</b></font></td>";
} }
print <<END; if ($netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/)
<td width='$inOutWidth' align='center' class='boldbase'><font color='#CE1B31'><b>$Lang::tr{'trafficin'}</b></font></td> {
<td width='$inOutWidth' align='center' class='boldbase'><font color='#CE1B31'><b>$Lang::tr{'trafficout'}</b></font></td> print "<td width='$inOutWidth' align='center' class='boldbase'><font color='#CE1B31'><b>$Lang::tr{'trafficin'}</b></font></td>";
</tr> print "<td width='$inOutWidth' align='center' class='boldbase'><font color='#CE1B31'><b>$Lang::tr{'trafficout'}</b></font></td>";
END }
print"</tr>";
my $total_blue_in=0; my $total_blue_in=0;
my $total_blue_out=0; my $total_blue_out=0;
@@ -214,21 +217,24 @@ foreach (@allDays) {
$total_green_in += $allDaysBytes{$_}{${Traffic::green_in}}; $total_green_in += $allDaysBytes{$_}{${Traffic::green_in}};
$total_green_out += $allDaysBytes{$_}{${Traffic::green_out}}; $total_green_out += $allDaysBytes{$_}{${Traffic::green_out}};
if ($netsettings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/) if ($netsettings{'CONFIG_TYPE'} =~ /^(3|4)$/)
{ {
$total_blue_in += $allDaysBytes{$_}{${Traffic::blue_in}}; $total_blue_in += $allDaysBytes{$_}{${Traffic::blue_in}};
$total_blue_out += $allDaysBytes{$_}{${Traffic::blue_out}}; $total_blue_out += $allDaysBytes{$_}{${Traffic::blue_out}};
} }
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/) if ($netsettings{'CONFIG_TYPE'} =~ /^(2|4)$/)
{ {
$total_orange_in += $allDaysBytes{$_}{${Traffic::orange_in}}; $total_orange_in += $allDaysBytes{$_}{${Traffic::orange_in}};
$total_orange_out += $allDaysBytes{$_}{${Traffic::orange_out}}; $total_orange_out += $allDaysBytes{$_}{${Traffic::orange_out}};
} }
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/)
{
$total_red_in += $allDaysBytes{$_}{${Traffic::red_in}}; $total_red_in += $allDaysBytes{$_}{${Traffic::red_in}};
$total_red_out += $allDaysBytes{$_}{${Traffic::red_out}}; $total_red_out += $allDaysBytes{$_}{${Traffic::red_out}};
}
if ($lines % 2) { if ($lines % 2) {
print "<tr bgcolor='$color{'color20'}'>"; } print "<tr bgcolor='$color{'color20'}'>"; }
else { else {
@@ -238,20 +244,21 @@ foreach (@allDays) {
printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::green_in}}/1048576); printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::green_in}}/1048576);
printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::green_out}}/1048576); printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::green_out}}/1048576);
if ($netsettings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/) if ($netsettings{'CONFIG_TYPE'} =~ /^(3|4)$/)
{ {
printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::blue_in}}/1048576); printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::blue_in}}/1048576);
printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::blue_out}}/1048576); printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::blue_out}}/1048576);
} }
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/) if ($netsettings{'CONFIG_TYPE'} =~ /^(2|4)$/)
{ {
printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::orange_in}}/1048576); printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::orange_in}}/1048576);
printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::orange_out}}/1048576); printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::orange_out}}/1048576);
} }
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/)
{
printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::red_in}}/1048576); printf "<td align='center' nowrap='nowrap'>%.3f</td>\n", ($allDaysBytes{$_}{${Traffic::red_in}}/1048576);
printf "<td align='center' nowrap='nowrap'>%.3f</td></tr>\n", ($allDaysBytes{$_}{${Traffic::red_out}}/1048576); printf "<td align='center' nowrap='nowrap'>%.3f</td></tr>\n", ($allDaysBytes{$_}{${Traffic::red_out}}/1048576);
}
$lines++; $lines++;
} }
@@ -273,21 +280,23 @@ print <<END;
<td align='center' class='boldbase' nowrap='nowrap'><b>$total_green_out MB</b></td> <td align='center' class='boldbase' nowrap='nowrap'><b>$total_green_out MB</b></td>
END END
if ($netsettings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/) if ($netsettings{'CONFIG_TYPE'} =~ /^(3|4)$/)
{ {
print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_blue_in MB</b></td>"; print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_blue_in MB</b></td>";
print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_blue_out MB</b></td>"; print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_blue_out MB</b></td>";
} }
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/) if ($netsettings{'CONFIG_TYPE'} =~ /^(2|4)$/)
{ {
print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_orange_in MB</b></td>"; print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_orange_in MB</b></td>";
print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_orange_out MB</b></td>"; print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_orange_out MB</b></td>";
} }
if ($netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/)
{
print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_red_in MB</b></td>";
print "<td align='center' class='boldbase' nowrap='nowrap'><b>$total_red_out MB</b></td>";
}
print <<END; print <<END;
<td align='center' class='boldbase' nowrap='nowrap'><b>$total_red_in MB</b></td>
<td align='center' class='boldbase' nowrap='nowrap'><b>$total_red_out MB</b></td>
</tr> </tr>
</table> </table>
END END

View File

@@ -1,13 +1,13 @@
colour1=#CD5B45 color1=#CD5B45
colour2=#EE6A50 color2=#EE6A50
colour3=#FF7256 color3=#FF7256
colour4=#EE9572 color4=#EE9572
colour5=#FFA07A color5=#FFA07A
colour6=#CDAF95 color6=#CDAF95
colour7=#EECBAD color7=#EECBAD
colour8=#FFDAB9 color8=#FFDAB9
colour9=#FFE4C4 color9=#FFE4C4
colour10=#FFCCCC color10=#FFCCCC
color11=#0000FF color11=#0000FF
color12=#00FF00 color12=#00FF00
color13=#FF0000 color13=#FF0000
@@ -18,7 +18,7 @@ color17=#90EE90
color18=#F4A460 color18=#F4A460
color19=#EAE9EE color19=#EAE9EE
color20=#E0E0E0 color20=#E0E0E0
color21=#EAE9EE color21=#FFFFFF
color22=#F0F0F0 color22=#F0F0F0
color23=#FF00FF color23=#FF00FF
color24=#6464FF color24=#6464FF