jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-jablonecka/] [modules/] [iwconf/] [platform/] [default.pm.jablonka] - Blame information for rev 4

 

Line No. Rev Author Line
11simandlpackage HotSaNICmod::OSdep;
2 
3use RRDs;
4 
5sub version {
6 ($VERSION = '$Revision: 1.0 $') =~ s/.*(\d+\.\d+).*/$1/;
7 my $platform;
8 foreach (keys(%INC)) { $platform=$_ if $_ =~ /platform/; }
9 return "$platform $VERSION";
10}
11 
12sub sample {
13 my %args=@_;
14 
15 $mtime=(stat("rrd"))[9];
16 $now=time;
17 
18 utime $now,$now,"rrd";
19 
20 $IWCONF = $args{IWCONFIG};
21 $hostap = $args{HOSTAP};
22 
23 my @IFACES=();
24 my @IFMACS=();
25 
26 foreach (keys(%args)) {
27 if (index($_,"IFACE:") >=0 ) {
28 (undef,$device)=split /:/;
29 push @IFACES,$device;
30 }
31 }
32 foreach (keys(%args)) {
33 if (index($_,"MAC,") >=0 ) {
34 (undef,$dev,$mac)=split /,/;
35 push @IFMACS,"$dev,$mac";
36 }
37 }
38 
39 foreach $device (@IFACES) {
40 my $rate = 0;
41 my $quality = 0;
42 my $signal = 0;
43 my $noise = 0;
44 my $mode = 0;
45 
46 $command = "$IWCONF $device";
47 open (FILE,"$command|");
48 while(<FILE>) {
49 $var=$_;
50 if ($var =~ /^.*Rate[=|:]+(.*)M.*/) {
51 $rate = $1;
52 } elsif ($var =~ /^.*Quality[=|:]+(.*)\/.*[=|:](.*)\sdBm.*[=|:](.*)\sdBm.*/) {
53 $quality = $1;
54 $signal = $2;
55 $noise = $3;
56 last;
57 } elsif ($var =~ /^.*Mode[=|:]+(.*) Fre.*/ ) {
58 $mode=$1;
59 }
60 }
61 close(FILE);
62 $rate=$rate*10;
63 
64 if ( $mode eq "Managed" ) {
65 if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") }
66 RRDs::update "rrd/$device.rrd",time.":".$rate.":".$quality.":".$signal.":".$noise;
67 if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$device.rrd': $ERROR"; }
68 }
69 if ( $mode eq "Master" ) {
70 if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") }
71 RRDs::update "rrd/$device.rrd",time.":".$rate.":".$quality.":".$signal.":".$noise;
72 if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$device.rrd': $ERROR"; }
73 }
74 
75 if ( $mode eq "Masters" ) {
76 @clients = glob( "/proc/net/hostap/$device/00*" );
77 $clients = @clients;
78 $clients = $clients*10;
79 $signal=0;
80 $noise=0;
81 @IFMACSNR=();
82 foreach $ifmac (@IFMACS)
83 {
84 ($ifmaci,$ifmacm)=split(/,/,$ifmac);
85 if ($ifmaci eq $device ) {
86 $iwmsnr=0;
87 if ( -r "/proc/net/hostap/$ifmaci/$ifmacm" )
88 {
89 open (FILE,"/proc/net/hostap/$ifmaci/$ifmacm");
90 while(<FILE>)
91 {
92 $var=$_;
93 if ($var =~ /^.*silence=+(.*) dBm.*signal=+(.*) dBm.*rate=.*/)
94 {
95 ($iwmsilence,undef)=split(/ /,$1);
96 ($iwmsignal,undef)=split(/ /,$2);
97 $iwmsnr=$iwmsignal-$iwmsilence;
98 last;
99 }
100 }
101 close(FILE);
102 }
103 push @IFMACSNR,$iwmsnr;
104 }
105 }
106 push @IFMACSNR,0;
107 push @IFMACSNR,0;
108 if ($IFMACSNR[0] eq "") {
109 $IFMACSNR[0]=0;
110 }
111 if ($IFMACSNR[1] eq "") {
112 $IFMACSNR[1]=0;
113 }
114 
115 if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") }
116 RRDs::update "rrd/$device.rrd",time.":".$rate.":".$clients.":".$IFMACSNR[0].":".$IFMACSNR[1];
117 if ($ERROR = RRDs::error) { dupe_control("warn",$ARGS{"MODNAME"},"unable to update `$device.rrd': $ERROR"); }
118 }
119 }
120}
1211;

Powered by WebSVN 2.2.1