Sha256: 3dc91a23fb088c606842fe2c1847db2c8824da3c8ab782b73f795de3ebd2838c

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

class ZabbixRubyClient
  module Plugins
    module Disk
      extend self

      def collect(*args)
        host = args[0]
        dev = args[1]
        diskinfo = `iostat -dx #{dev} | grep "^#{dev}"`
        if $?.to_i == 0
          _, rrqm, wrqm, r, w, rkb, wkb, avgrq, avgqu, await, rawait, wawait, svctm, util = diskinfo.split(/\s+/)
        else
          logger.warn "Please install sysstat."
          return []
        end
        back = []
        back << "#{host} disk[#{dev},read_req_per_sec] #{rrqm}"
        back << "#{host} disk[#{dev},write_req_per_sec] #{wrqm}"
        back << "#{host} disk[#{dev},read_per_sec] #{r}"
        back << "#{host} disk[#{dev},write_per_sec] #{w}"
        back << "#{host} disk[#{dev},read_sector_per_sec] #{rkb}"
        back << "#{host} disk[#{dev},write_sector_per_sec] #{wkb}"
        back << "#{host} disk[#{dev},avg_sector_size] #{avgrq}"
        back << "#{host} disk[#{dev},avg_queue_length] #{avgqu}"
        back << "#{host} disk[#{dev},time_waiting] #{await}"
        back << "#{host} disk[#{dev},time_waiting_read] #{rawait}"
        back << "#{host} disk[#{dev},time_waiting_write] #{wawait}"
        back << "#{host} disk[#{dev},service_time] #{svctm}"
        back << "#{host} disk[#{dev},percent_util] #{util}"
        return back
      end

      def discover(*args)
        device = args[0]
        mount = args[1]
        [ "disk.dev.discovery", "{\"{#DISK_DEVICE}\": \"#{device}\", \"{#DISK_MOUNT}\": \"#{mount}\"}" ]
      end

    end
  end
end

ZabbixRubyClient::Plugins.register('disk', ZabbixRubyClient::Plugins::Disk)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.0.6 lib/zabbix-ruby-client/plugins/disk.rb