module Zabby::ShellHelpers

Useful helper methods for the Zabbix Shell. Methods added to this module are available in the scripting language and commande line. The following instance variable should be available to helper methods:

Public Class Methods

desc(text) click to toggle source

Save the documentation for a method about to be defined. @param text [String] Documentation of the method following the call to “desc”

# File lib/rbZabbix/shell_helpers.rb, line 20
def self.desc(text)
  @last_doc = text
end
helpers_doc() click to toggle source

Show the Shell helpers documentation

# File lib/rbZabbix/shell_helpers.rb, line 37
    def self.helpers_doc
      help = <<EOT
Available commands:
==================

EOT
      @helpers_doc.each do |name, text|
        help += name + ":\n"
        help += '-' * name.size + "\n"
        help += text + "\n\n"
      end
      help
    end
method_added(method) click to toggle source

Push helper documentation for the method just defined in a hash. @param [Symbol] method Helper method to document @todo Display functions in alphabetical or arbitrary order.

# File lib/rbZabbix/shell_helpers.rb, line 27
def self.method_added(method)
  if @last_doc.nil?
    @helpers_doc[method.id2name] = "** UNDOCUMENTED FUNCTION **"
  else
    @helpers_doc[method.id2name] = @last_doc
    @last_doc = nil
  end
end

Public Instance Methods

help() click to toggle source
# File lib/rbZabbix/shell_helpers.rb, line 97
def help
  puts Zabby::ShellHelpers.helpers_doc
end
logged_in?() click to toggle source
# File lib/rbZabbix/shell_helpers.rb, line 79
def logged_in?
  @connection.logged_in?
end
Also aliased as: loggedin?
loggedin?()
Alias for: logged_in?
login() click to toggle source
# File lib/rbZabbix/shell_helpers.rb, line 69
def login
  @connection.login(@config)
end
logout() click to toggle source
# File lib/rbZabbix/shell_helpers.rb, line 74
def logout
  @connection.logout
end
set(key_value = nil) click to toggle source
# File lib/rbZabbix/shell_helpers.rb, line 55
def set(key_value = nil)
  if key_value.nil?
    @config.list
  elsif [ String, Symbol ].include?(key_value.class)
    puts "#{key_value} = #{@config.send(key_value)}"
  elsif key_value.instance_of? Hash
    key = key_value.keys.first
    value = key_value[key]
    @config.send(key, value)
  end
end
version() click to toggle source
# File lib/rbZabbix/shell_helpers.rb, line 87
def version
  Zabby::VERSION
end
zabbix_classes() click to toggle source
# File lib/rbZabbix/shell_helpers.rb, line 92
def zabbix_classes
  Zabby::ZClass.zabbix_classes
end