hotsanic |
Subversion Repositories: |
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;