Changeset ac12e51369119edd57d0699062ab00ae200ac562

Show
Ignore:
Timestamp:
12/11/08 16:59:06 (5 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1229014746 +0000
git-parent:

[9388834a964cf8c12dc67ed5efca3141c123dc1b]

git-author:
Mark Harrison <mark@omniti.com> 1229014746 +0000
Message:

Solaris/BSD support + show individual user/sys/wait times in the output

git-svn-id: https://labs.omniti.com/resmon/trunk@152 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Resmon/Module/CPU.pm

    r9388834 rac12e51  
    2424    $cpusys  = 0; 
    2525    $cpuwait = 0; 
     26    $havewait = 0; 
    2627 
    2728    $fieldcount = @headers; 
     29    # Look at the field header names to determine which values to use 
    2830    for (my $i=0; $i < $fieldcount; $i++) { 
    29         if ($headers[$i] eq 'us') { 
     31        # Need to compare previous/next header because solaris has two 'sy' 
     32        # values - one for cpu and one for interrupts 
     33        if ($headers[$i] eq 'us' && $headers[$i+1] eq 'sy') { 
    3034            $cpuuser = $vals[$i]; 
    3135        } 
    32         if ($headers[$i] eq 'sy') { 
     36        if ($headers[$i] eq 'sy' && $headers[$i-1] eq 'us') { 
    3337            $cpusys = $vals[$i]; 
    3438        } 
     39        # Wait appears to be a linux thing, so on other platforms it will just 
     40        # be 0 
    3541        if ($headers[$i] eq 'wa') { 
    3642            $cpuwait = $vals[$i]; 
     43            $havewait = 1; 
    3744        } 
    3845    } 
     
    4148    $total = $cpuuser + $cpusys + $cpuwait; 
    4249 
     50    $summary = "- us:$cpuuser sy:$cpusys"; 
     51    if ($havewait) { 
     52        $summary = "$summary wa:$cpuwait"; 
     53    } 
     54 
    4355    if ($total > $limit) { 
    44         return "BAD", "$total > $limit"; 
     56        return "BAD", "$total > $limit $summary"; 
    4557    } else { 
    46         return "OK", "$total <= $limit"; 
     58        return "OK", "$total <= $limit $summary"; 
    4759    } 
    4860