On Sat Mar 08, 2008 at 10:02:12 -0600, Peter Eisch wrote:

> I'm happy to take patches that keep the plugin universal and gather the
> stats better.

  How about something like this:

sub getLoad
{
    #
    #  Use the module if we can.
    #
    my $test  = "use Sys::CpuLoad;";
    eval( $test );

    if ( $@ )
    {
        #
        #  Fall back to running process.
        #
        my $res = `uptime`;
        if ($res =~ /aver\S+: (\d+\.\d+)/)
        {
            return( int( $1 ) );
        }
    }
    else
    {
        my @loads = Sys::CpuLoad::load();
        return( int($loads[0]) );
    }

    # fail?
    return undef;
}

Steve
-- 

Reply via email to