jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-jablonecka/] [modules/] [sensors/] [platform/] [linux.pm.orig] - Blame information for rev 5

 

Line No. Rev Author Line
11simandlpackage HotSaNICmod::OSdep;
2 
3use RRDs;
4 
5sub version {
6 ($VERSION = '$Revision: 1.4 $') =~ s/.*(\d+\.\d+).*/$1/;
7 return "$^O.pm $VERSION";
8 }
9 
10sub sample {
11 my %args=@_;
12 
13 foreach (keys(%args)) {
14 
15 if (index($_,"SENSOR") >= 0 ) {
16 ($dev,$dbname,undef,$num,$scale,$add,undef)=split(/,/,$args{$_});
17 open(DEVFILE,"$dev") || print time," ",$args{MODNAME},": Unable to open $dev.\n";
18 $_=<DEVFILE>;
19 chomp;
20 close DEVFILE;
21 @array=split;
22 $value=$array[$num-1]*$scale+$add;
23 
24 # build new database if needed
25 if ( ! -e "rrd/$dbname.rrd" ) { system("./makerrd","$dbname","10000") }
26 
27 # update database
28 RRDs::update "rrd/$dbname.rrd",time.":".$value;
29 if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},": unable to update `$dbname.rrd': $ERROR\n"; }
30 }
31 }
32 }
33 
341;
35 

Powered by WebSVN 2.2.1