jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [wifi/] [platform/] [linux.pm] - Rev 28

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 ) {
      ($dev,$oid,$name)=split(/,/,$args{$_});

      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 open $dev.\n";
      $_=<FILE>;
      chomp;
      close FILE;

      @array=split;
      $num=4;
      $scale=1;
      $add=0;

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

      $rssi=$array[$num-1]*$scale+$add;

      print "$dev $name $rssi\n";

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