jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [sensors/] [platform/] [freebsd.pm] - Rev 15 Go to most recent revision

Compare with Previous - Blame - Download


package HotSaNICmod::OSdep;

use RRDs;

sub version {
    ($VERSION = '$Revision: 1.9 $') =~ s/.*(\d+\.\d+).*/$1/;
    return "$^O.pm $VERSION";
}

sub sample {
    my %args=@_;

    # read mbmon data into a hash
    my $mbmon_bin = "/usr/local/bin/mbmon";
    open MBMON, "$mbmon_bin -rc1 |" || HotSaNIClog::error("Unable to open $mbmon_min.");
    my @lines=<MBMON>;
    close MBMON;
    my %mbmon=();
    foreach my $line (@lines) {
        ( $key = $line ) =~ s/^(\w*) .+$/$1/;
        ( $value = $line ) =~ s/^.*:\s*(.*)$/$1/;
        chomp $key; chomp $value;
        $mbmon{$key}=$value;
    }

    foreach $entry (@{$args{SENSOR}}) {
        my (undef,undef,$item,$dbname,undef,undef,undef,$num,$scale,$add)=HotSaNICmod::common::get_names($entry);
        ($file)=split /\s+/,$item;
        if ( $item = "mbmon" ) {
            my $value = $mbmon{$dbname} *$scale + $add;
            HotSaNICmod::do_rrd($dbname,"50000",time,$value);
        } elsif (-e $file) {
            open(DEVFILE,"$item") || HotSaNIClog::error("Unable to open $item.");
            my @lines=<DEVFILE>;
            close DEVFILE;
            my $value = $lines[$num];
            chomp $value;
            $value =~ s/^.*:\s*(.*)$/$1/;
            $value = $value*$scale + $add;
            
            HotSaNICmod::do_rrd($dbname,"50000",time,$value);
        }
    }
}

1;


Powered by WebSVN 2.2.1