From dd8bfcf598edf60b23aa421537f794ef14bda624 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 26 Jul 2008 18:05:37 +0200 Subject: [PATCH] Added Graphs for wireless interface status --- config/cfgroot/graphs.pl | 32 ++++++++++++++++++++++++++++++++ html/cgi-bin/graphs.cgi | 36 +++++++++++++++++++++++++++--------- html/cgi-bin/network.cgi | 27 ++++++++++++++++++++++++++- 3 files changed, 85 insertions(+), 10 deletions(-) diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index 83de843930..229ee20c6c 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -711,6 +711,38 @@ sub updateprocessesgraph { print "$ERROR"; } +sub wireless { + my $period = $_[0]; + my $interface = $_[1]; + RRDs::graph ("$graphs/wireless-$interface-$period.png", + "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", + "--alt-y-grid", "-w 600", "-h 125", "-r", "-v dBm", "-z", + "-t Wireless $interface $Lang::tr{'graph per'} $Lang::tr{$period}", + "--color", "SHADEA".$color{"color19"}, + "--color", "SHADEB".$color{"color19"}, + "--color", "BACK".$color{"color21"}, + "DEF:noise=$rrdlog/collectd/localhost/wireless-$interface/signal_noise.rrd:value:AVERAGE", + "DEF:power=$rrdlog/collectd/localhost/wireless-$interface/signal_power.rrd:value:AVERAGE", + "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", + "LINE1:noise".$color{"color11"}."A0:".sprintf("%-20s","Signal Noise Ratio"), + "GPRINT:noise:MAX:%5.1lf %sdBm", + "GPRINT:noise:AVERAGE:%5.1lf %sdBm", + "GPRINT:noise:MIN:%5.1lf %sdBm", + "GPRINT:noise:LAST:%5.1lf %sdBm\\j", + "LINE1:power".$color{"color12"}."A0:".sprintf("%-20s","Signal Power Ratio"), + "GPRINT:power:MAX:%5.1lf %sdBm", + "GPRINT:power:AVERAGE:%5.1lf %sdBm", + "GPRINT:power:MIN:%5.1lf %sdBm", + "GPRINT:power:LAST:%5.1lf %sdBm\\j", + ); + $ERROR = RRDs::error; + print "Error in RRD::graph for Wireless: $ERROR\n" if $ERROR; +} + # Generate a random color, used by Qos Graph to be independent from the amount of values sub random_hex_color { diff --git a/html/cgi-bin/graphs.cgi b/html/cgi-bin/graphs.cgi index f2e5ef6550..e3d444c28f 100644 --- a/html/cgi-bin/graphs.cgi +++ b/html/cgi-bin/graphs.cgi @@ -48,10 +48,11 @@ $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");} -if ($cgigraphs[1] =~ /(cpu)/) {&Graphs::updatecpugraph ("hour");&Graphs::updatecpugraph ("week");&Graphs::updatecpugraph ("month");&Graphs::updatecpugraph ("year");} -if ($cgigraphs[1] =~ /(processes)/) {&Graphs::updateprocessesgraph ("hour");&Graphs::updateprocessesgraph ("week");&Graphs::updateprocessesgraph ("month");&Graphs::updateprocessesgraph ("year");} -if ($cgigraphs[1] =~ /(memory|swap)/) {&Graphs::updatememgraph ("hour");&Graphs::updatememgraph ("week");&Graphs::updatememgraph ("month");&Graphs::updatememgraph ("year");} -if ($cgigraphs[1] =~ /disk/){ +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");} +elsif ($cgigraphs[1] =~ /wireless/){ &Graphs::wireless("hour",$cgigraphs[2]); &Graphs::wireless("week",$cgigraphs[2]); &Graphs::wireless("month",$cgigraphs[2]); &Graphs::wireless("year",$cgigraphs[2]); } +elsif ($cgigraphs[1] =~ /disk/){ my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`; foreach (@devices) { my $device = $_; @@ -60,9 +61,9 @@ if ($cgigraphs[1] =~ /disk/){ &Graphs::updatediskgraph ("week",$device); &Graphs::updatediskgraph ("month",$device); &Graphs::updatediskgraph ("year",$device);}} -if ($cgigraphs[2] ne "" ) {&Graphs::updatepinggraph("hour",$cgigraphs[1]);&Graphs::updatepinggraph("week",$cgigraphs[1]);&Graphs::updatepinggraph("month",$cgigraphs[1]);&Graphs::updatepinggraph("year",$cgigraphs[1]);} -if ($cgigraphs[1] =~ /fwhits/) {&Graphs::updatefwhitsgraph("hour");&Graphs::updatefwhitsgraph("week");&Graphs::updatefwhitsgraph("month");&Graphs::updatefwhitsgraph("year");} -if ($cgigraphs[1] =~ /green/ || $cgigraphs[1] =~ /blue/ || $cgigraphs[1] =~ /ipsec/ || $cgigraphs[1] =~ /orange/ || $cgigraphs[1] =~ /ppp/ || $cgigraphs[1] =~ /red/ ) {&Graphs::updateifgraph($cgigraphs[1], "hour");&Graphs::updateifgraph($cgigraphs[1], "week");&Graphs::updateifgraph($cgigraphs[1], "month");&Graphs::updateifgraph($cgigraphs[1], "year");} +elsif ($cgigraphs[2] ne "" ) {&Graphs::updatepinggraph("hour",$cgigraphs[1]);&Graphs::updatepinggraph("week",$cgigraphs[1]);&Graphs::updatepinggraph("month",$cgigraphs[1]);&Graphs::updatepinggraph("year",$cgigraphs[1]);} +elsif ($cgigraphs[1] =~ /fwhits/) {&Graphs::updatefwhitsgraph("hour");&Graphs::updatefwhitsgraph("week");&Graphs::updatefwhitsgraph("month");&Graphs::updatefwhitsgraph("year");} +elsif ($cgigraphs[1] =~ /green/ || $cgigraphs[1] =~ /blue/ || $cgigraphs[1] =~ /ipsec/ || $cgigraphs[1] =~ /orange/ || $cgigraphs[1] =~ /ppp/ || $cgigraphs[1] =~ /red/ ) {&Graphs::updateifgraph($cgigraphs[1], "hour");&Graphs::updateifgraph($cgigraphs[1], "week");&Graphs::updateifgraph($cgigraphs[1], "month");&Graphs::updateifgraph($cgigraphs[1], "year");} if ($cgigraphs[1] =~ /(network|green|blue|orange|red|ppp|ipsec)/ || $cgigraphs[2] ne "") { &Header::openpage($Lang::tr{'network traffic graphs'}, 1, ''); @@ -72,7 +73,24 @@ if ($cgigraphs[1] =~ /(network|green|blue|orange|red|ppp|ipsec)/ || $cgigraphs[2 &Header::openbigbox('100%', 'left'); -if ($cgigraphs[1] =~ /(green|blue|orange|red|ppp|ipsec|cpu|memory|swap|disk|load|fwhits|processes)/ || $cgigraphs[2] ne "") { +if ($cgigraphs[1] =~ /wireless/){ + my $graphname = $cgigraphs[2]; + &Header::openbox('100%', 'center', "wireless $graphname $Lang::tr{'graph'}"); + if (-e "$graphdir/wireless-${graphname}-day.png") { + my $ftime = localtime((stat("$graphdir/wireless-${graphname}-day.png"))[9]); + print "
"; + print "$Lang::tr{'the statistics were last updated at'}: $ftime


\n"; + print "
"; + print "
"; + print "
"; + print "
"; + print ""; + } else { + print $Lang::tr{'no information available'}; + } + &Header::closebox(); +} +elsif ($cgigraphs[1] =~ /(green|blue|orange|red|ppp|ipsec|cpu|memory|swap|disk|load|fwhits|processes)/ || $cgigraphs[2] ne "") { my $graph = $cgigraphs[1]; my $graphname = ucfirst(lc($cgigraphs[1])); &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); @@ -122,7 +140,7 @@ elsif ( $cgigraphs[1] eq "memory" || $cgigraphs[1] eq "swap" ) { print ""; } elsif ( $cgigraphs[1] =~ /disk/ ) { print ""; } elsif ( $cgigraphs[1] =~ /red/ || $cgigraphs[1] =~ /ppp/ || $cgigraphs[1] =~ /ipsec/ ) { print ""; } -elsif ( $cgigraphs[1] =~ /green/ || $cgigraphs[1] =~ /blue/ || $cgigraphs[1] =~ /orange/ ) { print ""; } +elsif ( $cgigraphs[1] =~ /green/ || $cgigraphs[1] =~ /blue/ || $cgigraphs[1] =~ /orange/ || $cgigraphs[1] =~ /wireless/ ) { print ""; } elsif ( $cgigraphs[1] eq "fwhits" || $cgigraphs[2] ne "" ) { print ""; } print "$Lang::tr{'back'}\n"; diff --git a/html/cgi-bin/network.cgi b/html/cgi-bin/network.cgi index 1c34ca7696..3543780578 100644 --- a/html/cgi-bin/network.cgi +++ b/html/cgi-bin/network.cgi @@ -36,6 +36,7 @@ my %netsettings=(); my @cgiparams=(); my @graphs=(); my @pings=(); +my @wireless=(); my $iface=''; my %dhcpsettings=(); my %dhcpinfo=(); @@ -67,6 +68,7 @@ if ($cgiparams[1] =~ /red/) { push(@pings,$2); } push (@graphs, ("fwhits")); + }else { &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, ''); push (@graphs, ($netsettings{'GREEN_DEV'})); @@ -74,6 +76,11 @@ if ($cgiparams[1] =~ /red/) { push (@graphs, ($netsettings{'BLUE_DEV'})); } if ($netsettings{'ORANGE_DEV'}) { push (@graphs, ($netsettings{'ORANGE_DEV'})); } + my @wirelessgraphs = `ls -dA /var/log/rrd/collectd/localhost/wireless*`; + foreach (@wirelessgraphs){ + $_ =~ /(.*)\/wireless-(.*)/; + push(@wireless,$2); + } } &Header::openbigbox('100%', 'left'); @@ -105,7 +112,7 @@ foreach my $graphname (@graphs) { { &Graphs::updatefwhitsgraph("day"); } else { &Graphs::updateifgraph($graphname, "day"); } - + &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); if (-e "$Header::graphdir/${graphname}-day.png") { my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]); @@ -120,6 +127,24 @@ foreach my $graphname (@graphs) { &Header::closebox(); } +foreach my $graphname (@wireless) { + + &Graphs::wireless("day",$graphname); + + &Header::openbox('100%', 'center', "wireless $graphname $Lang::tr{'graph'}"); + if (-e "$Header::graphdir/wireless-${graphname}-day.png") { + my $ftime = localtime((stat("$Header::graphdir/wireless-${graphname}-day.png"))[9]); + print "
$Lang::tr{'the statistics were last updated at'}: $ftime

\n"; + print ""; + print ""; + print ""; + } else { + print $Lang::tr{'no information available'}; + } + print "
\n"; + &Header::closebox(); +} + if ($cgiparams[1] =~ /red/) { if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") { -- 2.39.2