jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [crusader/] [platform/] [default.pm] - Rev 11 Go to most recent revision

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");

#print "l1 ahoj \n";

        my %args=@_;

        $mtime=(stat("rrd"))[9];
        $now=time;

        utime $now,$now,"rrd";

        my @IFACES=();

        foreach (keys(%args)) {
                if (index($_,"IFACE:") >=0 ) {
                        (undef,$device)=split /:/;
                        push @IFACES,$device;
                }
        }


        foreach $device (@IFACES) {
                my $rate = 0;
                my $quality = 0;
                my $signal = 0;
                my $noise = 0;
                my $mode = 0;

                $command = "/opt/HotSaNIC/modules/crusader/crgetsig";
                $command = "cat /tmp/crusader.txt";
                open (FILE,"$command|");
                while(<FILE>) {
                        $var=$_;
                        if ($var =~ /^\+ (.*) #.*/) {
                                $signal = $1;
                        } 
                }
                close(FILE);
                $rate=$rate*1;
                print "l1 $device $signal \n";

                        if ( ! -e "rrd/$device.rrd" ) { system("./makerrd","$device","U") }
                        RRDs::update "rrd/$device.rrd",time.":".$rate.":".$quality.":".$signal.":".$noise;
                        if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$device.rrd': $ERROR"; }

        }
#uncomment this for debug output to temp.txt
#all print will be done into the file
#       close (TEMPFILE);
#       close (STDERR);
#       close (STDOUT);
}
1;

Powered by WebSVN 2.2.1