jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
116simandl#!/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 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 
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 my ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024",
63 "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, "-a", uc($IMGFMT),
64 "-l 0", "--title", "Stats for AS$name - last $descr ($DATESTRING)",
65 "DEF:rate=rrd/$dev:rate:AVERAGE",
66 "DEF:quality=rrd/$dev:quality:AVERAGE",
67 "DEF:signal=rrd/$dev:signal:AVERAGE",
68 "DEF:noise=rrd/$dev:noise:AVERAGE",
69 "LINE2:rate#000080:Path length",
70 "LINE2:quality#800000:",
71 "LINE2:signal#008000:",
72 "LINE2:noise#808080:",
73 "HRULE:0#000000";
74 rename $TEMPNAME,$FILENAME;
75 printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME;
76 }
77 }
78}
79print "\n";
80exit 0;
81 
82 

Powered by WebSVN 2.2.1