jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [crusader/] [platform/] [default.pm] - Blame information for rev 13

 

Line No. Rev Author Line
111simandlpackage 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 
14#uncomment this for debug output to temp.txt
15#all print will be done into the file
16#$temp = "/opt/HotSaNIC/modules/crusader/temp.txt";
17#open (TEMPFILE,">$temp");
18#open (STDERR,">&TEMPFILE") || die ("open STDERR failed");
19#open (STDOUT,">&TEMPFILE") || die ("open STDOUT failed");
20 
21 
22 my %args=@_;
23 
24 $mtime=(stat("rrd"))[9];
25 $now=time;
26 
27 utime $now,$now,"rrd";
28 
2912simandl $IWCONF = $args{IWCONFIG};
30 $IWLIST = $args{IWLIST};
31 $hostap = $args{HOSTAP};
32 
33 
3411simandl my @IFACES=();
3512simandl my @IFMACS=();
3611simandl 
37 foreach (keys(%args)) {
3813simandl if (index($_,"IFACE:") >=0 ) {
3911simandl (undef,$device)=split /:/;
40 push @IFACES,$device;
41 }
42 }
4312simandl foreach (keys(%args)) {
44 if (index($_,"MAC,") >=0 ) {
45 (undef,$dev,$mac)=split /,/;
46 push @IFMACS,"$dev,$mac";
47 }
48 }
4911simandl 
50 foreach $device (@IFACES) {
51 my $rate = 0;
5212simandl my $tempin = 0;
5311simandl my $signal = 0;
54 my $noise = 0;
55 my $mode = 0;
56 
57 $command = "cat /tmp/crusader.txt";
58 open (FILE,"$command|");
59 while(<FILE>) {
60 $var=$_;
6112simandl #print "line: $_\n";
62 if ($var =~ /^(\d*)\s*(\d*)\s*(\d*)\s*(\d*)\s*([\w\.]*)\s*([\w\.]*)\s*([\w\.]*)\s*([\w\.]*)\s*([\w\.]*)/) {
63 $signal = $2;
64 $tempin = $9 * 10;
65 #print "signal: $signal\n";
66 #print "tempin: $tempin\n";
67 }
68 } # while
6911simandl close(FILE);
70 $rate=$rate*1;
71 
72 if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") }
7312simandl RRDs::update "rrd/$device.rrd",time.":".$rate.":".$tempin.":".$signal.":".$noise;
7411simandl if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$device.rrd': $ERROR"; }
7512simandl } # foreach
7611simandl 
77#uncomment this for debug output to temp.txt
78#all print will be done into the file
79# close (TEMPFILE);
80# close (STDERR);
81# close (STDOUT);
82}
831;

Powered by WebSVN 2.2.1