Sha256: aead087cb9a7d62255b080b7cb1b04bb863d5e47002027ed6ab7a00a60cd5b63

Contents?: true

Size: 956 Bytes

Versions: 2

Compression:

Stored size: 956 Bytes

Contents

# for more info check 
# http://juliano.info/en/Blog:Memory_Leak/Understanding_the_Linux_load_average
require "zabbix-ruby-client/logger"

module 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
          Log.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

2 entries across 2 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.0.17 lib/zabbix-ruby-client/plugins/load.rb
zabbix-ruby-client-0.0.16 lib/zabbix-ruby-client/plugins/load.rb