Class: ZabbixRubyClient::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/zabbix-ruby-client/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



9
10
11
# File 'lib/zabbix-ruby-client/cli.rb', line 9

def self.source_root
  File.expand_path("../../../templates", __FILE__)
end

Instance Method Details

#init(name = "zabbix-ruby-client") ⇒ Object



26
27
28
# File 'lib/zabbix-ruby-client/cli.rb', line 26

def init(name = "zabbix-ruby-client")
  directory "client", name
end

#showObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/zabbix-ruby-client/cli.rb', line 31

def show
  begin
    Bundler.require
  rescue Bundler::GemfileNotFound
    say "No Gemfile found", :red
    abort
  end
  config = YAML::load_file(options[:configfile])
  if File.exists? options[:taskfile]
    tasks = YAML::load_file(options[:taskfile])
  else
    tasks = config['plugins']
  end
  config['server'] = File.basename(options[:configfile],'.yml')
  config['taskfile'] = File.basename(options[:taskfile],'.yml')
  zrc = ZabbixRubyClient::Runner.new(config, tasks)
  zrc.collect
  zrc.show
end

#uploadObject



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/zabbix-ruby-client/cli.rb', line 52

def upload
  config = YAML::load_file(options[:configfile])
  if File.exists? options[:taskfile]
    tasks = YAML::load_file(options[:taskfile])
  else
    tasks = config['plugins']
  end
  config['server'] = File.basename(options[:configfile],'.yml')
  config['taskfile'] = File.basename(options[:taskfile],'.yml')
  zrc = ZabbixRubyClient::Runner.new(config, tasks)
  zrc.collect
  zrc.upload
end