Class: Zabbix::Agent::Configuration
- Inherits:
-
Object
- Object
- Zabbix::Agent::Configuration
- Defined in:
- lib/zabbix/agent/configuration.rb
Class Method Summary collapse
Instance Method Summary collapse
- #arbitrary(key) ⇒ Object
- #debug_level ⇒ Object
- #disable_active ⇒ Object
- #enable_remote_commands ⇒ Object
-
#initialize(config = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #listen_ip ⇒ Object
- #listen_port ⇒ Object
- #log_file ⇒ Object
- #pid_file ⇒ Object
- #refresh_active_checks ⇒ Object
- #server ⇒ Object
- #server_port ⇒ Object
- #source_ip ⇒ Object
- #start_agents ⇒ Object
- #timeout ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Configuration
Returns a new instance of Configuration.
3 4 5 |
# File 'lib/zabbix/agent/configuration.rb', line 3 def initialize(config={}) @config = config end |
Class Method Details
.read(zabbix_conf_file = nil) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/zabbix/agent/configuration.rb', line 63 def self.read(zabbix_conf_file=nil) zabbix_conf_file ||= "/etc/zabbix/zabbix-agentd.conf" zabbix_conf = {} File.open(zabbix_conf_file).each do |line| ## skip comments next if line =~ /^(\s+)?#/ ## strip tail comments line.gsub!(/#.*/, '') ## zabbix splits on equals key, value = line.split("=", 2) key.chomp! value.chomp! ## zabbix keys look like strings next unless key =~ /[A-Za-z0-9]+/ ## cool zabbix_conf[key] = value end Configuration.new(zabbix_conf) end |
Instance Method Details
#arbitrary(key) ⇒ Object
59 60 61 |
# File 'lib/zabbix/agent/configuration.rb', line 59 def arbitrary(key) @config[key] end |
#debug_level ⇒ Object
43 44 45 |
# File 'lib/zabbix/agent/configuration.rb', line 43 def debug_level @config['DebugLevel'] end |
#disable_active ⇒ Object
35 36 37 |
# File 'lib/zabbix/agent/configuration.rb', line 35 def disable_active @config['DisableActive'] end |
#enable_remote_commands ⇒ Object
39 40 41 |
# File 'lib/zabbix/agent/configuration.rb', line 39 def enable_remote_commands @config['EnableRemoteCommands'] end |
#listen_ip ⇒ Object
19 20 21 |
# File 'lib/zabbix/agent/configuration.rb', line 19 def listen_ip @config['ListenIP'] end |
#listen_port ⇒ Object
15 16 17 |
# File 'lib/zabbix/agent/configuration.rb', line 15 def listen_port @config['ListenPort'] end |
#log_file ⇒ Object
51 52 53 |
# File 'lib/zabbix/agent/configuration.rb', line 51 def log_file @config['LogFile'] end |
#pid_file ⇒ Object
47 48 49 |
# File 'lib/zabbix/agent/configuration.rb', line 47 def pid_file @config['PidFile'] end |
#refresh_active_checks ⇒ Object
31 32 33 |
# File 'lib/zabbix/agent/configuration.rb', line 31 def refresh_active_checks @config['RefreshActiveChecks'] end |
#server ⇒ Object
7 8 9 |
# File 'lib/zabbix/agent/configuration.rb', line 7 def server @config['Server'] end |
#server_port ⇒ Object
11 12 13 |
# File 'lib/zabbix/agent/configuration.rb', line 11 def server_port @config['ServerPort'] end |
#source_ip ⇒ Object
23 24 25 |
# File 'lib/zabbix/agent/configuration.rb', line 23 def source_ip @config['SourceIP'] end |
#start_agents ⇒ Object
27 28 29 |
# File 'lib/zabbix/agent/configuration.rb', line 27 def start_agents @config['StartAgents'] end |
#timeout ⇒ Object
55 56 57 |
# File 'lib/zabbix/agent/configuration.rb', line 55 def timeout @config['Timeout'] end |