<?xml version="1.0" encoding="UTF-8"?>
<plugin-url>
  <approved type="boolean">true</approved>
  <author>Highgroove Studios</author>
  <cached-tag-list>load</cached-tag-list>
  <canonical-name>load</canonical-name>
  <code>#
# Modified load_averages to show load/processor, as this is a more accurate
# measurement of CPU utilization.
#
# Requires /proc/cpuinfo
#
class LoadAverages &lt; Scout::Plugin

  OPTIONS=&lt;&lt;-EOS
    num_processors:
      name: Number of Processors
      notes: For calculating CPU load. If left blank, autodetects through /proc/cpuinfo
      default: 1
  EOS

   def build_report
     if `uptime` =~ /load average(s*): ([\d.]+)(,*) ([\d.]+)(,*) ([\d.]+)\Z/
       report :last_minute          =&gt; $2.to_f/num_processors,
              :last_five_minutes    =&gt; $4.to_f/num_processors,
              :last_fifteen_minutes =&gt; $6.to_f/num_processors
     else
       raise &quot;Couldn't use `uptime` as expected.&quot;
     end
  rescue Exception
    error &quot;Error determining load&quot;, $!.message
  end

  def num_processors
    # first, check if the options provided is &gt; 0. So leave the options blank to auto-detect
    processors = option('num_processors').to_i
    return processors if processors &gt; 0

    # otherwise, pull it from memory
    processors = memory(:processors)

    # if we didn't get it from memory, try to auto-detect through /proc/cpuinfo
    unless processors &amp;&amp; processors &gt; 0
      if `cat /proc/cpuinfo | grep 'model name' | wc -l` =~ /(\d+)/
        processors = $1.to_i
      else
        raise &quot;Couldn't use /proc/cpuinfo as expected.&quot;
      end
      raise &quot;Couldn't use /proc/cpuinfo as expected.&quot; unless processors &gt; 0
    end
    remember(:processors, processors)
    return processors
  end

end
</code>
  <created-at type="datetime">2007-12-21T09:54:23-08:00</created-at>
  <default-triggers type="yaml" nil="true"></default-triggers>
  <description>Monitors the load on server, generating an alert if the load over the last minute is greater than a specified amount. 

&quot;See our blog article&quot;:http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages for background on understanding load 
</description>
  <featured type="boolean">false</featured>
  <id type="integer">4</id>
  <metadata type="yaml">--- |
metadata:
  last_minute:
    precision: 2
  last_five_minutes:
    precision: 2
  last_fifteen_minutes:
    precision: 2

triggers:
  - type: peak
    dname: last_minute
    max_value: 3

</metadata>
  <name>Server Load</name>
  <plugins-count type="integer">725</plugins-count>
  <rating-avg type="decimal">4.0</rating-avg>
  <rating-count type="integer">2</rating-count>
  <rating-total type="integer">8</rating-total>
  <readme nil="true"></readme>
  <schema type="yaml" nil="true"></schema>
  <scout-version type="integer">3</scout-version>
  <short-description>Monitors the load on server, generating an alert if the load over the last minute is greater than a specified amount. </short-description>
  <tested-platforms>linux macosx</tested-platforms>
  <total-usage-count type="integer">0</total-usage-count>
  <updated-at type="datetime">2010-02-13T13:38:13-08:00</updated-at>
  <url>http://github.com/highgroove/scout-plugins/raw/master/load_averages/load_averages.rb</url>
</plugin-url>
