jablonka.czprosek.czf

hotsanic

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

 

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#uncomment this for debug output to temp.txt
14#all print will be done into the file
15#$temp = "/opt/HotSaNIC/modules/sensors/temp.txt";
16#open (TEMPFILE,">$temp");
17#open (STDERR,">&TEMPFILE") || die ("open STDERR failed");
18#open (STDOUT,">&TEMPFILE") || die ("open STDOUT failed");
19 
20 
21 
22 
23 foreach (keys(%args)) {
24 
25 if (index($_,"SENSOR") >= 0 ) {
26 ($dev,$dbname,$description,$num,$scale,$add,$units)=split(/,/,$args{$_});
27 
28 open(FILE,"$dev | grep \"^$description\" | sed \'s/°/ /g\' |") || print time," ",$args{MODNAME},": Unable to open $dev.\n";
29 $_=<FILE>;
30 chomp;
31 close FILE;
32 
33 @array=split;
34 $value=$array[$num-1]*$scale+$add;
35 #$value=$array[$num-1];
36# print "$dev $description $value\n";
37 # build new database if needed
38 if ( ! -e "rrd/$dbname.rrd" ) { system("./makerrd","$dbname","10000") }
39 
40 # update database
41 RRDs::update "rrd/$dbname.rrd",time.":".$value;
42 if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},": unable to update `$dbname.rrd': $ERROR\n"; }
43 }
44 }
45#uncomment this for debug output to temp.txt
46#all print will be done into the file
47# close (TEMPFILE);
48# close (STDERR);
49# close (STDOUT);
50 
51 
52 
53 }
54 
551;
56 

Powered by WebSVN 2.2.1