jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [iwconf/] [diagrams.pl] - Blame information for rev 11

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2use strict;
3use warnings;
4use diagnostics;
5 
6use lib "../../lib";
7use HotSaNICparser;
8use HotSaNICdiagram;
9use RRDs;
10 
11# read global settings
12#
13my $MODNAME=HotSaNICparser::get_module_name();
14my %CONFIG=HotSaNICparser::get_config("../..");
15 
16my $OUTDIR=$CONFIG{"WEBDIR"}."/".lc $MODNAME;
17if ( ! -e $OUTDIR ) { mkdir $OUTDIR,0755; }
18 
19my $IMGFMT=lc $CONFIG{"IMAGEFORMAT"};
20my $TEMPNAME="$OUTDIR/temp.$IMGFMT";
21 
22my ($LEGEND,@ITEMS,$name,$range,$descr);
23my $IOMIN=500;
24 
25my $FORCE=@ARGV;
26 
27$LEGEND="accesses";
28 
29# generate diagrams
30#
31 
32opendir DIR,"rrd";
33@ITEMS=grep /\.rrd/,readdir DIR;
34closedir DIR;
35 
36if (! (@ITEMS) ) { print " No database found\n Please check if the daemon is running.\n";next; }
37 
38# if database exists, create images...
39foreach my $dev (@ITEMS) {
40 ($name=$dev) =~ s/\.rrd//g;
41 my $description=$name;
42 my $var;
43 my $mode;
44 my $command;
45 
46 $command = "/sbin/iwconfig $description";
47 open (FILE,"$command|");
48 while(<FILE>) {
49 $var=$_;
50 if ($var =~ /^.*Mode[=|:]+(.*) Fre.*/ ) {
51 $mode=$1;
52 }
53 }
54 close(FILE);
55 
56 print "creating images for $description...\n";
57 
58 foreach $range ("1h","6h","1day","1week","1month","1year") {
59 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
60 
61 my $FILENAME="$OUTDIR/$name-$file.$IMGFMT";
62 
63 my $make=$FORCE;
64 if ($range eq "1h") { $make++; }
65 elsif (! -e "$FILENAME") { $make++; }
66 else {
67 my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" );
68 if (time > ($mtime+$build)) { $make++; }
69 }
70 
71 if ($make>0) {
72 if ($mode eq "Managed" ) {
73 my ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024",
74 "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, "-a", uc($IMGFMT),
75 "-l 0", "--title", "Stats for $name in Managed mode - last $descr ($DATESTRING)",
76 "DEF:rate=rrd/$dev:rate:AVERAGE",
77 "DEF:quality=rrd/$dev:quality:AVERAGE",
78 "DEF:signal=rrd/$dev:signal:AVERAGE",
79 "DEF:noise=rrd/$dev:noise:AVERAGE",
80 "LINE2:rate#000080:bitrate",
81 "LINE2:quality#800000:link quality",
82 "LINE2:signal#008000:signal level",
83 "LINE2:noise#808080:noise level",
84 "HRULE:0#000000";
85 rename $TEMPNAME,$FILENAME;
86 printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME;
87 } elsif ($mode eq "Ad-Hoc" ) {
88 my ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024",
89 "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, "-a", uc($IMGFMT),
90 "-l 0", "--title", "Stats for $name in Ad-Hoc mode - last $descr ($DATESTRING)",
91 "DEF:rate=rrd/$dev:rate:AVERAGE",
92 "DEF:quality=rrd/$dev:quality:AVERAGE",
93 "DEF:signal=rrd/$dev:signal:AVERAGE",
94 "DEF:noise=rrd/$dev:noise:AVERAGE",
95 "LINE2:rate#000080:bitrate",
96 "LINE2:quality#800000:link quality",
97 "LINE2:signal#008000:signal level",
98 "LINE2:noise#808080:noise level",
99 "HRULE:0#000000";
100 rename $TEMPNAME,$FILENAME;
101 printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME;
102 } elsif ($mode eq "Master" ) {
103 my ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024",
104 "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, "-a", uc($IMGFMT),
105 "-l 0", "--title", "Stats for $dev in Master mode - last $descr ($DATESTRING)",
106 "DEF:rate=rrd/$dev:rate:AVERAGE",
107 "DEF:quality=rrd/$dev:quality:AVERAGE",
108 "DEF:signal=rrd/$dev:signal:AVERAGE",
109 "DEF:noise=rrd/$dev:noise:AVERAGE",
110 "LINE2:rate#000080:bitrate",
111 "LINE2:quality#800000:number of associated clients",
112 "LINE2:signal#008000:SNR link 1",
113 "LINE2:noise#808080:SNR link 2",
114 "HRULE:0#000000";
115 rename $TEMPNAME,$FILENAME;
116 printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME;
117 }
118 }
119 }
120}
121print "\n";
122exit 0;
123 
124 

Powered by WebSVN 2.2.1