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=@_;
@readings = `/usr/local/bin/mbmon -rc1`
or print time," ",$args{MODNAME},": Unable to run /usr/local/bin/mbmon.\n";
foreach (keys(%args)) {
if (index($_,"SENSOR") >= 0 ) {
($undef,$dev)=split(/,/,$args{$_});
foreach(@readings){
# force it to scalar just in case
if(/$dev\s+:\s+(.*)/i){ $value = $1;$value++;$value--; }
}
# build new database if needed
if ( ! -e "rrd/$dev.rrd" ) { system("./makerrd","$dev","10000") }
# update database
RRDs::update "rrd/$dev.rrd",time.":".$value;
if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},": unable to update `$dev.rrd': $ERROR\n"; }
}
}
}
1;