jablonka.czprosek.czf

hotsanic

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

 

Line No. Rev Author Line
11simandl#!/usr/bin/perl -w
2 
3use lib "../../lib";
4use HotSaNIC;
5use RRDs;
6#use DBI;
7 
8# get cmdline arguments (i.e. options passed by the daemon)
9# and other global parameters
10#
11%ARGS=arg2opt(@ARGV);
12 
13dupe_control("start",$ARGS{"MODNAME"},"");
14 
15# read module-specific settings
16#
17open (FILE,"settings");
18while (<FILE>) {
19 ($var,$value)=parse_line($_);
20 
21 if ($var eq "ALL") {$ALL=$value;}
22 if ($var eq "ROUTERS") {$ROUTERS=$value;}
23 if ($var eq "CLOUD") {$CLOUD=$value;}
24 if ($var eq "DEFAULT") {$DEFAULT=$value;}
25 if ($var eq "IFACE") {
26 ($iface)=split(/,/,$value);
27 push @IFACES,$iface;
28 next;
29 }
30 }
31close(FILE);
32 
33foreach $iface (@IFACES) {
34 if ( ! -e "rrd/$iface.rrd" ) { system("./makerrd","$iface", "U") }
35 
36 system("$ALL > $iface.all");
37 system("$ROUTERS > $iface.routers");
38 system("$CLOUD > $iface.cloud");
39 system("$DEFAULT > $iface.default");
40 system("wget -q http://localhost/cgi-bin/ospfd_database.cgi -O - | grep -c \"Advertising Router\" > $iface.ra");
41 system("wget -q http://localhost/cgi-bin/ospfd_database.cgi -O - | grep -c \"Advertising Router: 10.33\" > $iface.rb");
42 system("wget -q http://localhost/cgi-bin/ospfd_database.cgi -O - | grep -c \"Advertising Router: 10.32\" > $iface.rc");
43 system("wget -q http://localhost/cgi-bin/ospfd_database.cgi -O - | grep -c \"Advertising Router: 10.43\" > $iface.rd");
44 system("/sbin/ip ro ls | /bin/grep -c ^10.32 > $iface.re");
45 system("/sbin/ip ro ls | /bin/grep -c ^10.43 > $iface.rf");
46 system("/sbin/ip ro ls | /bin/grep -c \/16 > $iface.rg");
47 
48 open (FILE,"$iface.all");
49 while(<FILE>) {
50 $all=$_*1;
51 }
52 close(FILE);
53 open (FILE,"$iface.routers");
54 while(<FILE>) {
55 $routers=$_*1;
56 }
57 close(FILE);
58 open (FILE,"$iface.cloud");
59 while(<FILE>) {
60 $cloud=$_*1;
61 }
62 close(FILE);
63 open (FILE,"$iface.default");
64 while(<FILE>) {
65 $default=$_*1;
66 }
67 close(FILE);
68 
69# Routing ra
70 open (FILE,"$iface.ra");
71 while(<FILE>) {
72 $ra=$_*1;
73 }
74 close(FILE);
75 
76# Routing rb
77 open (FILE,"$iface.rb");
78 while(<FILE>) {
79 $rb=$_*1;
80 }
81 close(FILE);
82 
83# Routing rc
84 open (FILE,"$iface.rc");
85 while(<FILE>) {
86 $rc=$_*1;
87 }
88 close(FILE);
89 
90# Routing rd
91 open (FILE,"$iface.rd");
92 while(<FILE>) {
93 $rd=$_*1;
94 }
95 close(FILE);
96# Routing re
97 open (FILE,"$iface.re");
98 while(<FILE>) {
99 $re=$_*1;
100 }
101 close(FILE);
102# Routing rf
103 open (FILE,"$iface.rf");
104 while(<FILE>) {
105 $rf=$_*1;
106 }
107 close(FILE);
108# Routing rg
109 open (FILE,"$iface.rg");
110 while(<FILE>) {
111 $rg=$_*1;
112 }
113 close(FILE);
114 
115 $default=$default/100;
116 $all=$all/10;
117# RRDs::update "rrd/$iface.rrd",time.":".$all.":".$routers.":".$cloud.":".$default.":".$ra.":".$rb.":".$rc.":".$rd.":".$re.":".$rf.":".$rg;
118 RRDs::update "rrd/$iface.rrd",time.":".$all.":".$routers.":".$cloud.":".$default.":".$ra.":".$rb.":".$rc.":".$rd.":".$re.":".$rf.":".$rg;
119 if ($ERROR = RRDs::error) { dupe_control("warn",$ARGS{"MODNAME"},"unable to update `$iface.rrd': $ERROR"); }
120}
121 

Powered by WebSVN 2.2.1