Sha256: a87b6d216f8fe965f80f9238519c6e2e7a2dad94be3b881476c49c95bad16d3a

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require "zabbix-ruby-client/logger"

module ZabbixRubyClient
  module Plugins
    module Apt
      extend self
      extend ZabbixRubyClient::PluginBase

      def collect(*args)
        host = args[0]
        info = get_info
        if info
          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
        if os == :linux
          info = aptinfo
          if info
            back = info.split(/;/).map(&:to_i)
            back
          else
            false
          end
        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

1 entries across 1 versions & 1 rubygems

Version Path
zabbix-ruby-client-0.1.3 lib/zabbix-ruby-client/plugins/apt.rb