jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [sensors/] [platform/] [freebsd.pm] - Blame information for rev 33

 

Line No. Rev Author Line
11simandlpackage HotSaNICmod::OSdep;
2 
3use RRDs;
4 
5sub version {
6 ($VERSION = '$Revision: 1.9 $') =~ s/.*(\d+\.\d+).*/$1/;
7 return "$^O.pm $VERSION";
8}
9 
10sub sample {
11 my %args=@_;
12 
13 # read mbmon data into a hash
14 my $mbmon_bin = "/usr/local/bin/mbmon";
15 open MBMON, "$mbmon_bin -rc1 |" || HotSaNIClog::error("Unable to open $mbmon_min.");
16 my @lines=<MBMON>;
17 close MBMON;
18 my %mbmon=();
19 foreach my $line (@lines) {
20 ( $key = $line ) =~ s/^(\w*) .+$/$1/;
21 ( $value = $line ) =~ s/^.*:\s*(.*)$/$1/;
22 chomp $key; chomp $value;
23 $mbmon{$key}=$value;
24 }
25 
26 foreach $entry (@{$args{SENSOR}}) {
27 my (undef,undef,$item,$dbname,undef,undef,undef,$num,$scale,$add)=HotSaNICmod::common::get_names($entry);
28 ($file)=split /\s+/,$item;
29 if ( $item = "mbmon" ) {
30 my $value = $mbmon{$dbname} *$scale + $add;
31 HotSaNICmod::do_rrd($dbname,"50000",time,$value);
32 } elsif (-e $file) {
33 open(DEVFILE,"$item") || HotSaNIClog::error("Unable to open $item.");
34 my @lines=<DEVFILE>;
35 close DEVFILE;
36 my $value = $lines[$num];
37 chomp $value;
38 $value =~ s/^.*:\s*(.*)$/$1/;
39 $value = $value*$scale + $add;
40 
41 HotSaNICmod::do_rrd($dbname,"50000",time,$value);
42 }
43 }
44}
45 
461;
47 

Powered by WebSVN 2.2.1