Method: Zabbix::Agent::Configuration.read
- Defined in:
- lib/zabbix/agent/configuration.rb
.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 |