jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-jablonecka/] [modules/] [traffic/] [platform/] [sysrrcp.pm] - Blame information for rev 34

 

Line No. Rev Author Line
11simandlpackage sysrrcp;
2 
3use lib "../../../lib";
4 
5sub version {
6 ($VERSION = '$Revision: 1.11 $') =~ s/.*(\d+\.\d+).*/$1/;
7 return "sysrrcp.pm $VERSION";
8 }
9 
10sub do_rrcp {
11# print "###################################################################################\n";
12$rtlbin="";
13foreach (HotSaNICparser::read_settings(".")) {
14 my ($var,$value)=HotSaNICparser::parse_line($_);
15 if ($var eq "RTLBIN") {
16 $rtlbin= $value;
17 }
18}
19 if (! -e "$rtlbin" ) {
20# print "rtl binary $rtlbin not found!\n";
21 }
22 
23 my (%targets) = @_;
24 foreach ( keys(%targets) ) {
25 my ($host, $com) = split /_/;
26 my ($res, $lastnic);
27 my %nics = ();
28 my $i = 0;
29 my $portnum = "none";
30 
31 $res=`$rtlbin $com-$host\@eth0 counters | grep ^eth | sed 's/://g' | sed 's/eth0\\///g'`;
32 #print "tu je res \n$res \n";
33 @pole_res = split("\n",$res);
34 $pocet = scalar(@pole_res);
35 print "Vysledek pro $_ je dlouhy $pocet \n";
36 #vytvoreni asociativniho pole $nics s cislem portu a rychlostma
37 
38 for (@{$targets{$_}}) {
39 print "0b $_\n";
40 if($i == 0) {
41 $nics{$_} = 0;
42 $lastnic = $_;
43 $i++;
44 } else {
45 $nics{$lastnic} = $_;
46 $i = 0;
47 }
48 } # for
49 
50 print "3 $host a $com b $lastnic\n";
51 
52 foreach $port (keys(%nics) ){
53 print "3be $host $com $port $nics{$port}\n";
54 my $resfound = 0;
55 my $rx = 0;
56 my $tx = 0;
57 #projdeme vysledek a pokud najdeme hodnoty pro port tak zapisem do rrd
58 foreach $linka (@pole_res) {
59 @polozky = split(" ", $linka);
60 $resport = $polozky[0];
61 $resrx = $polozky[1];
62 $restx = $polozky[2];
63 
64 if ($port == $resport) {
65 $resfound = 1;
66 print "Pro $port je $resrx a $restx\n";
67 $rx = $resrx;
68 $tx = $restx;
69 }
70 } # foreach line in result
71 
72 #$host =~ s/://g;
73 
74 if ($resfound == 1) {
75 do_rrd($host."_".$port, $rx, $tx, $nics{$port});
76 
77 } else {
78 print "tady to je kdyz nejni spojeni tak se do rrd da undef\n";
79 do_rrd($host."_".$port, "U", "U", $nics{$port});
80 }
81 } # foreach port
82 } # foreach
83} # sub
84 
85sub do_rrd {
86 my ($name, $in, $out, $max) = @_;
87#print "mam tu $max";
88 if (! -e "rrd/$name.rrd" ) {
89 system("./makerrd","$name","$max")
90 }
91 
92 RRDs::update "rrd/$name.rrd",time.":".$in.":".$out;
93 if ($ERROR = RRDs::error) { print time,": ",$args{MODNAME},": unable to update `$name.rrd': $ERROR\n"; }
94}
95 
961;

Powered by WebSVN 2.2.1