jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [sensors/] [platform/] [linux.pm.orig] - Rev 31 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=@_;

  foreach (keys(%args)) {

    if (index($_,"SENSOR") >= 0 ) {
      ($dev,$dbname,undef,$num,$scale,$add,undef)=split(/,/,$args{$_});
      open(DEVFILE,"$dev") || print time," ",$args{MODNAME},": Unable to open $dev.\n";
      $_=<DEVFILE>;
      chomp;
      close DEVFILE;
      @array=split;
      $value=$array[$num-1]*$scale+$add;
            
      # build new database if needed
      if ( ! -e "rrd/$dbname.rrd" ) { system("./makerrd","$dbname","10000") }

      # update database
      RRDs::update "rrd/$dbname.rrd",time.":".$value;  
      if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},":  unable to update `$dbname.rrd': $ERROR\n"; }
      }
    }
  }

1;


Powered by WebSVN 2.2.1