Sha256: 43ab545ac2e2d6addeb02066364c4c19a8238cde4d4d3701c9cfde707f26e70c

Contents?: true

Size: 922 Bytes

Versions: 8

Compression:

Stored size: 922 Bytes

Contents

# for more info check 
# http://juliano.info/en/Blog:Memory_Leak/Understanding_the_Linux_load_average

class ZabbixRubyClient
  module Plugins
    module Load
      extend self

      def collect(*args)
        host = args[0]
        #cpuinfo = `mpstat | grep " all "`
        cpuinfo = `cat /proc/loadavg`
        if $?.to_i == 0
          one, five, fifteen, procs_t = cpuinfo.split(/\s+/)
        else
          logger.warn "Oh you don't have a /proc ?"
          return []
        end

        procs, _ = procs_t.split(/\//)

        time = Time.now.to_i
        back = []
        back << "#{host} load[one] #{time} #{one}"
        back << "#{host} load[five] #{time} #{five}"
        back << "#{host} load[fifteen] #{time} #{fifteen}"
        back << "#{host} load[procs] #{time} #{procs}"
        return back

      end

    end
  end
end

ZabbixRubyClient::Plugins.register('load', ZabbixRubyClient::Plugins::Load)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.0.15 lib/zabbix-ruby-client/plugins/load.rb
zabbix-ruby-client-0.0.14 lib/zabbix-ruby-client/plugins/load.rb
zabbix-ruby-client-0.0.13 lib/zabbix-ruby-client/plugins/load.rb
zabbix-ruby-client-0.0.12 lib/zabbix-ruby-client/plugins/load.rb
zabbix-ruby-client-0.0.11 lib/zabbix-ruby-client/plugins/load.rb
zabbix-ruby-client-0.0.10 lib/zabbix-ruby-client/plugins/load.rb
zabbix-ruby-client-0.0.9 lib/zabbix-ruby-client/plugins/load.rb
zabbix-ruby-client-0.0.8 lib/zabbix-ruby-client/plugins/load.rb