hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
package HotSaNICmod::OSdep;
use RRDs;
sub version {
($VERSION = '$Revision: 1.0 $') =~ s/.*(\d+\.\d+).*/$1/;
my $platform;
foreach (keys(%INC)) { $platform=$_ if $_ =~ /platform/; }
return "$platform $VERSION";
}
sub sample {
#uncomment this for debug output to temp.txt
#all print will be done into the file
#$temp = "/opt/HotSaNIC/modules/crusader/temp.txt";
#open (TEMPFILE,">$temp");
#open (STDERR,">&TEMPFILE") || die ("open STDERR failed");
#open (STDOUT,">&TEMPFILE") || die ("open STDOUT failed");
my %args=@_;
$mtime=(stat("rrd"))[9];
$now=time;
utime $now,$now,"rrd";
$IWCONF = $args{IWCONFIG};
$IWLIST = $args{IWLIST};
$hostap = $args{HOSTAP};
my @IFACES=();
my @IFMACS=();
foreach (keys(%args)) {
if (index($_,"IFACE:") >=0 ) {
(undef,$device)=split /:/;
push @IFACES,$device;
}
}
foreach (keys(%args)) {
if (index($_,"MAC,") >=0 ) {
(undef,$dev,$mac)=split /,/;
push @IFMACS,"$dev,$mac";
}
}
foreach $device (@IFACES) {
my $rate = 0;
my $tempin = 0;
my $signal = 0;
my $noise = 0;
my $mode = 0;
$command = "cat /tmp/crusader.txt";
open (FILE,"$command|");
while(<FILE>) {
$var=$_;
#print "line: $_\n";
if ($var =~ /^(\d*)\s*(\d*)\s*(\d*)\s*(\d*)\s*([\w\.]*)\s*([\w\.]*)\s*([\w\.]*)\s*([\w\.]*)\s*([\w\.]*)/) {
$signal = $2;
$tempin = $9 * 10;
#print "signal: $signal\n";
#print "tempin: $tempin\n";
}
} # while
close(FILE);
$rate=$rate*1;
if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") }
RRDs::update "rrd/$device.rrd",time.":".$rate.":".$tempin.":".$signal.":".$noise;
if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$device.rrd': $ERROR"; }
} # foreach
#uncomment this for debug output to temp.txt
#all print will be done into the file
# close (TEMPFILE);
# close (STDERR);
# close (STDOUT);
}
1;