Sha256: a0262531d43ebe563a4ecea3109cb2c1ead258df1677e45fa2dc355ab3a04509

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

require "zabbix-ruby-client/logger"

module ZabbixRubyClient
  module Plugins
    module Apt
      extend self

      def collect(*args)
        host = args[0]
        info = get_info
        if info
          time = Time.now.to_i
          back = []
          back << "#{host} apt[security] #{time} #{info[0]}"
          back << "#{host} apt[pending] #{time} #{info[1]}"
          back << "#{host} apt[status] #{time} TODO apt #{info[0]}/#{info[1]}"
          return back
        else
          return []
        end
      end

    private

      def get_info
        info = aptinfo
        if info
          back = info.split(/;/).map(&:to_i)
          back
        else
          false
        end
      end

      def aptinfo
        output = `/usr/lib/update-notifier/apt-check 2>&1`
        if $?.to_i == 0
          Log.debug self
          Log.debug output
          output
        else
          Log.warn "Oh you don't have apt ?"
          false
        end
      end

    end
  end
end

ZabbixRubyClient::Plugins.register('apt', ZabbixRubyClient::Plugins::Apt)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.1.2 lib/zabbix-ruby-client/plugins/apt.rb
zabbix-ruby-client-0.1.1 lib/zabbix-ruby-client/plugins/apt.rb
zabbix-ruby-client-0.1.0 lib/zabbix-ruby-client/plugins/apt.rb
zabbix-ruby-client-0.0.23 lib/zabbix-ruby-client/plugins/apt.rb
zabbix-ruby-client-0.0.22 lib/zabbix-ruby-client/plugins/apt.rb
zabbix-ruby-client-0.0.21 lib/zabbix-ruby-client/plugins/apt.rb
zabbix-ruby-client-0.0.20 lib/zabbix-ruby-client/plugins/apt.rb
zabbix-ruby-client-0.0.19 lib/zabbix-ruby-client/plugins/apt.rb
zabbix-ruby-client-0.0.18 lib/zabbix-ruby-client/plugins/apt.rb