jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [wireless-ml/] [diagrams.pl] - Blame information for rev 33

 

Line No. Rev Author Line
133simandl#!/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 
36#if (! (@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 print "creating images for $description...\n";
47 
48 foreach $range ("1h","6h","1day","1week","1month","1year") {
49 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
50 
51 my $FILENAME="$OUTDIR/$name-$file.$IMGFMT";
52# print "$OUTDIR/$name-$file.$IMGFMT\n";
53 my $make=$FORCE;
54 if ($range eq "1h") { $make++; }
55 elsif (! -e "$FILENAME") { $make++; }
56 else {
57 my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" );
58 if (time > ($mtime+$build)) { $make++; }
59 }
60 
61 if ($make>0) {
62# print "make: $make $TEMPNAME $range $CONFIG{'WIDTH'} \n";
63 my ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024",
64 "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, "-a", uc($IMGFMT),
65 "-l 0", "--title", "$dev - last $descr ($DATESTRING)",
66 "DEF:freq=rrd/$dev:freq:AVERAGE",
67 "DEF:power=rrd/$dev:power:AVERAGE",
68 "DEF:signal=rrd/$dev:signal:AVERAGE",
69 "DEF:temp=rrd/$dev:temp:AVERAGE",
70 "DEF:snr=rrd/$dev:snr:AVERAGE",
71 "DEF:qam=rrd/$dev:qam:AVERAGE",
72 "LINE2:freq#000080:freq",
73 "GPRINT:freq:AVERAGE: avg\\:%3.1lf %s \\g",
74 "GPRINT:freq:MIN: min\\:%3.1lf %s \\g",
75 "GPRINT:freq:MAX: max\\:%3.1lf %s \\g",
76 "GPRINT:freq:LAST: current\\:%3.1lf %s GHz\\n",
77 "LINE2:power#800000:power",
78 "GPRINT:power:AVERAGE: avg\\:%3.1lf %s \\g",
79 "GPRINT:power:MIN: min\\:%3.1lf %s \\g",
80 "GPRINT:power:MAX: max\\:%3.1lf %s \\g",
81 "GPRINT:power:LAST: current\\:%3.1lf %s \\n",
82 "LINE2:signal#008000:signal",
83 "GPRINT:signal:AVERAGE: avg\\:%3.1lf %s \\g",
84 "GPRINT:signal:MIN: min\\:%3.1lf %s \\g",
85 "GPRINT:signal:MAX: max\\:%3.1lf %s \\g",
86 "GPRINT:signal:LAST: current\\:%3.1lf %s \\n",
87 "LINE2:temp#808080:temp",
88 "GPRINT:temp:AVERAGE: avg\\:%3.1lf %s \\g",
89 "GPRINT:temp:MIN: min\\:%3.1lf %s \\g",
90 "GPRINT:temp:MAX: max\\:%3.1lf %s \\g",
91 "GPRINT:temp:LAST: current\\:%3.1lf %s \\n",
92 "LINE2:snr#0000FF:snr",
93 "GPRINT:snr:AVERAGE: avg\\:%3.1lf %s \\g",
94 "GPRINT:snr:MIN: min\\:%3.1lf %s \\g",
95 "GPRINT:snr:MAX: max\\:%3.1lf %s \\g",
96 "GPRINT:snr:LAST: current\\:%3.1lf %s dB\\n",
97 "LINE2:qam#FF0000:qam",
98 "GPRINT:qam:AVERAGE: avg\\:%3.1lf %s \\g",
99 "GPRINT:qam:MIN: min\\:%3.1lf %s \\g",
100 "GPRINT:qam:MAX: max\\:%3.1lf %s \\g",
101 "GPRINT:qam:LAST: current\\:%3.1lf %s \\n",
102 "HRULE:0#000000";
103# print "$TEMPNAME >> $FILENAME\n";
104 rename $TEMPNAME,$FILENAME;
105# $xs = 0;
106# $ys = 0;
107 printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME;
108 }
109 }
110}
111print "\n";
112exit 0;
113 
114# if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},": unable to generate `$FILENAME': $ERROR\n"; }
115#print "pred descr: $descr xs: $xs ys: $ys \n";
116 
117 
118 

Powered by WebSVN 2.2.1