Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an INI parser instead of reading config by hand #6

Open
synthead opened this issue Jul 8, 2016 · 0 comments
Open

Use an INI parser instead of reading config by hand #6

synthead opened this issue Jul 8, 2016 · 0 comments

Comments

@synthead
Copy link

synthead commented Jul 8, 2016

These lines are parsing the zabbix config file by hand:

      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

Use a Ruby INI parser instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant