jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [wireless/] [platform/] [linux.pm] - Rev 34 Go to most recent revision

Compare with Previous - Blame - Download


package HotSaNICmod::OSdep;

use RRDs;

sub version {
  ($VERSION = '$Revision: 1.4 $') =~ s/.*(\d+\.\d+).*/$1/;
  return "$^O.pm $VERSION";
  }

sub sample {
  my %args=@_;

#uncomment this for debug output to temp.txt
#all print will be done into the file
#$temp = "/opt/HotSaNIC/modules/sensors/temp.txt";
#open (TEMPFILE,">$temp");
#open (STDERR,">&TEMPFILE")  || die ("open STDERR failed");
#open (STDOUT,">&TEMPFILE")  || die ("open STDOUT failed");

  foreach (keys(%args)) {

    if (index($_,"IP") >= 0 ) {
      my ($dev,$oid,$name)=split(/,/,$args{$_});

#      print "zacatek: $_ $dev $oid $name \n";

#      open(FILE,"/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid | grep 1.1.1.8.1.12.2 ") || print time," ",$args{MODNAME},": Unable to tady open $dev $oid $name .\n";
#      $_=<FILE>;
#      chomp;
#      close FILE;

#      @array=split;
      my $num=4;
      my $scale1=0.001;
      my $scale2=0.01;
      my $add=0;

      my $freq=1;
      my $mcs=2;
      my $signal=3;
      my $txsec=4;
      my $rate=5;
      my $noise=0;

#                $command = "/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid | grep 1.1.1.8.1.12.2";
                $command = "/usr/bin/snmpwalk -Os -c public -v 1 $dev $oid";
                open (FILE,"$command|");
                while(<FILE>) {
                        $var=$_;
                        if      ($var =~ /^.*.1.1.1.8.1.6.. = INTEGER: +(.*)$/) {
                                $freq = $1;
                                $freq=$1*$scale1+$add;
                                #print "freq : $freq \n";
                        } elsif ($var =~ /^.*.1.1.1.8.1.7.. = INTEGER: +(.*)$/) {
                                $mcs = $1;
                        } elsif ($var =~ /^.*.1.1.1.8.1.8.. = INTEGER: +(.*)$/) {
                                $signal = $1;
                        } elsif ($var =~ /^.*.1.1.1.8.1.9.. = INTEGER: +(.*)$/) {
                                $txsec = $1;
                        } elsif ($var =~ /^.*.1.1.1.8.1.12.. = INTEGER: +(.*)$/) {
                                $rssi = $1;
                        } elsif ($var =~ /^.*.1.1.1.8.1.13.. = Gauge32: +(.*)$/) {
                                $rate = $1;
                                $rate=$1*$scale1+$add;
                        } elsif ($var =~ /^.*.1.1.1.8.1.14.. = INTEGER: +(.*)$/) {
                                $noise = $1;
                        }
                }
                close(FILE);

      # build new database if needed
      if ( ! -e "rrd/$name.rrd" ) { system("./makerrd","$name","U") }

      # update database
      RRDs::update "rrd/$name.rrd",time.":".$freq.":".$mcs.":".$signal.":".$txsec.":".$rssi.":".$rate.":".$noise;
      if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},":  unable to update `$name.rrd': $ERROR\n"; }

      }
    }
#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