jablonka.czprosek.czf

hotsanic

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

 

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) {
5114simandl my $power = 0;
5212simandl my $tempin = 0;
5311simandl my $signal = 0;
5414simandl my $voltage = 0;
5511simandl 
56 $command = "cat /tmp/crusader.txt";
57 open (FILE,"$command|");
58 while(<FILE>) {
59 $var=$_;
6014simandl print "line: $_\n";
6112simandl if ($var =~ /^(\d*)\s*(\d*)\s*(\d*)\s*(\d*)\s*([\w\.]*)\s*([\w\.]*)\s*([\w\.]*)\s*([\w\.]*)\s*([\w\.]*)/) {
62 $signal = $2;
6314simandl $power = $5 * 10;
64 $voltage = $7 * 10;
6512simandl $tempin = $9 * 10;
66 #print "signal: $signal\n";
67 #print "tempin: $tempin\n";
68 }
69 } # while
7011simandl close(FILE);
71 
72 if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") }
7314simandl RRDs::update "rrd/$device.rrd",time.":".$power.":".$tempin.":".$signal.":".$voltage;
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