jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [apcusv/] [platform/] [default.pm] - Rev 36 Go to most recent revision

Compare with Previous - Blame - Download


package HotSaNICmod::OSdep;

use lib "../../lib";

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

sub sample {

  my %args=@_;
  my ($loadpct,$bcharge,$timeleft,$outputv,$itemp,$battv)=("nan","nan","nan","nan","nan","nan");
  my ($onbatt,$replacebatt)=(-1,-1);

  open FILE,"$args{APCACCESS}|" || HotSaNIClog::error("unable to run '$args{APCACCESS}': $!");
  while (<FILE>) {
    chomp;
    ($name,$value,undef)=split / *: */;
    ($firstvalue = $value) =~ s/ .*$//g;
    if ($name eq "LOADPCT") { $loadpct=$firstvalue; }
    if (($name eq "BCHARGE") || ($name eq "BATTPCT")) { $bcharge=$firstvalue; }
    if ($name eq "TIMELEFT") { $timeleft=$firstvalue; }
    if (($name eq "OUTPUTV") || ($name eq "OUTVOLT")) { $outputv=$firstvalue; }
    if (($name eq "ITEMP") || ($name eq "UPSTEMP")) { $itemp=$firstvalue; }
    if (($name eq "BATTV") || ($name eq "BATTVOLT")) { $battv=$firstvalue; }
    if ($name eq "STATUS") {
      if (index ($value,"ONBATT") >= 0 ) { $onbatt=1; }
      if (index ($value,"REPLACEBATT") >= 0 ) { $replacebatt=1; }
      }
    }
  close FILE;

  HotSaNICmod::do_rrd("usv","U",time,$loadpct,$bcharge,$timeleft,$outputv,$itemp,$battv,$onbatt,$replacebatt);
  }

1;



Powered by WebSVN 2.2.1