jablonka.czprosek.czf

hotsanic

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

 

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 
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 
43 print "creating images for $description...\n";
44 
45 foreach $range ("1h","6h","1day","1week","1month","1year") {
46 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
47 
48 my $FILENAME="$OUTDIR/$name-$file.$IMGFMT";
49 
50 my $make=$FORCE;
51 if ($range eq "1h") { $make++; }
52 elsif (! -e "$FILENAME") { $make++; }
53 else {
54 my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" );
55 if (time > ($mtime+$build)) { $make++; }
56 }
57 
58 if ($make>0) {
59 my ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024",
60 "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}*2, "-a", uc($IMGFMT),
61 "-l 0", "--title", "$name - last $descr ($DATESTRING)",
62 "DEF:all=rrd/$dev:all:AVERAGE",
63 "DEF:routers=rrd/$dev:routers:AVERAGE",
64 "DEF:cloud=rrd/$dev:cloud:AVERAGE",
65 "DEF:default=rrd/$dev:default:AVERAGE",
66 "DEF:ra=rrd/$dev:ra:AVERAGE",
67 "DEF:rb=rrd/$dev:rb:AVERAGE",
68 "DEF:rc=rrd/$dev:rc:AVERAGE",
69 "DEF:rd=rrd/$dev:rd:AVERAGE",
70 "DEF:re=rrd/$dev:re:AVERAGE",
71 "DEF:rf=rrd/$dev:rf:AVERAGE",
72 "DEF:rg=rrd/$dev:rg:AVERAGE",
73 "LINE2:all#000080:all_routes/10",
74 "LINE2:routers#800000:routes 10.33.0.X",
75 "LINE2:cloud#008000:10.33 routes",
76 "LINE2:default#808080:default_cost/100",
77 "LINE2:ra#FF6666:all ospd",
78 "LINE2:rb#FF0000:10.33 ospf",
79 "LINE2:rc#FFAADD:10.32 ospf",
80 "LINE2:rd#AA00AA:10.43 ospf",
81 "LINE2:re#FF9900:10.32 routes",
82 "LINE2:rf#00FF00:10.43 routes",
83 "LINE2:rg#0000FF:bgp /16 routes",
84 "HRULE:0#000000";
85 rename $TEMPNAME,$FILENAME;
86 printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME;
87 }
88 }
89 }
90print "\n";
91exit 0;
92 
93 

Powered by WebSVN 2.2.1