Skip to content

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

@synthead

Description

@synthead

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions