| 1 | 11 | simandl | package HotSaNICmod::OSdep; |
| 2 | | | |
| 3 | | | use RRDs; |
| 4 | | | |
| 5 | | | sub 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 | | | |
| 12 | | | sub 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 | | | |
| 29 | 12 | simandl | $IWCONF = $args{IWCONFIG}; |
| 30 | | | $IWLIST = $args{IWLIST}; |
| 31 | | | $hostap = $args{HOSTAP}; |
| 32 | | | |
| 33 | | | |
| 34 | 11 | simandl | my @IFACES=(); |
| 35 | 12 | simandl | my @IFMACS=(); |
| 36 | 11 | simandl | |
| 37 | | | foreach (keys(%args)) { |
| 38 | 13 | simandl | if (index($_,"IFACE:") >=0 ) { |
| 39 | 11 | simandl | (undef,$device)=split /:/; |
| 40 | | | push @IFACES,$device; |
| 41 | | | } |
| 42 | | | } |
| 43 | 12 | simandl | foreach (keys(%args)) { |
| 44 | | | if (index($_,"MAC,") >=0 ) { |
| 45 | | | (undef,$dev,$mac)=split /,/; |
| 46 | | | push @IFMACS,"$dev,$mac"; |
| 47 | | | } |
| 48 | | | } |
| 49 | 11 | simandl | |
| 50 | | | foreach $device (@IFACES) { |
| 51 | | | my $rate = 0; |
| 52 | 12 | simandl | my $tempin = 0; |
| 53 | 11 | simandl | 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=$_; |
| 61 | 12 | simandl | #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 |
| 69 | 11 | simandl | close(FILE); |
| 70 | | | $rate=$rate*1; |
| 71 | | | |
| 72 | | | if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") } |
| 73 | 12 | simandl | RRDs::update "rrd/$device.rrd",time.":".$rate.":".$tempin.":".$signal.":".$noise; |
| 74 | 11 | simandl | if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$device.rrd': $ERROR"; } |
| 75 | 12 | simandl | } # foreach |
| 76 | 11 | simandl | |
| 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 | | | } |
| 83 | | | 1; |