1 | 1 | simandl | package HotSaNICmod::OSdep; |
2 | | | |
3 | | | use RRDs; |
4 | | | |
5 | | | sub version { |
6 | | | ($VERSION = '$Revision: 1.4 $') =~ s/.*(\d+\.\d+).*/$1/; |
7 | | | return "$^O.pm $VERSION"; |
8 | | | } |
9 | | | |
10 | | | sub sample { |
11 | | | my %args=@_; |
12 | | | |
13 | | | @readings = `/usr/local/bin/mbmon -rc1` |
14 | | | or print time," ",$args{MODNAME},": Unable to run /usr/local/bin/mbmon.\n"; |
15 | | | |
16 | | | foreach (keys(%args)) { |
17 | | | if (index($_,"SENSOR") >= 0 ) { |
18 | | | ($undef,$dev)=split(/,/,$args{$_}); |
19 | | | |
20 | | | foreach(@readings){ |
21 | | | # force it to scalar just in case |
22 | | | if(/$dev\s+:\s+(.*)/i){ $value = $1;$value++;$value--; } |
23 | | | } |
24 | | | |
25 | | | # build new database if needed |
26 | | | if ( ! -e "rrd/$dev.rrd" ) { system("./makerrd","$dev","10000") } |
27 | | | |
28 | | | # update database |
29 | | | RRDs::update "rrd/$dev.rrd",time.":".$value; |
30 | | | if ($ERROR = RRDs::error) { print time," ",$args{MODNAME},": unable to update `$dev.rrd': $ERROR\n"; } |
31 | | | } |
32 | | | } |
33 | | | } |
34 | | | |
35 | | | 1; |
36 | | | |