def parse_config(data)
      config = {'graph' => {}, 'metrics' => {}}
      data.each do |l|
        if l =~ /^graph_/
          key_name, value = l.scan(/^graph_([\w]+)\s(.*)/).flatten
          config['graph'][key_name] = value
        # according to http://munin-monitoring.org/wiki/notes_on_datasource_names
        elsif l =~ /^[a-zA-Z_][a-zA-Z\d_]*\./
          # according to http://munin-monitoring.org/wiki/fieldnames the second one
          # can only be [a-z]
          matches = l.scan(/^([a-zA-Z_][a-zA-Z\d_]*)\.([a-z]+)\s(.*)/).flatten
          config['metrics'][matches[0]] ||= {}
          config['metrics'][matches[0]][matches[1]] = matches[2]
        end
      end

      # Now, lets process the args hash
      if config['graph'].key?('args')
        config['graph']['args'] = parse_config_args(config['graph']['args'])
      end

      config
    end
def parse_config(data)
      config = {'graph' => {}, 'metrics' => {}}
      data.each do |l|
        if l =~ /^graph_/
          key_name, value = l.scan(/^graph_([\w]+)\s(.*)/).flatten
          config['graph'][key_name] = value
        # according to http://munin-monitoring.org/wiki/notes_on_datasource_names
        elsif l =~ /^[a-zA-Z_][a-zA-Z\d_]*\./
          # according to http://munin-monitoring.org/wiki/fieldnames the second one
          # can only be [a-z]
          matches = l.scan(/^([a-zA-Z_][a-zA-Z\d_]*)\.([a-z]+)\s(.*)/).flatten
          config['metrics'][matches[0]] ||= {}
          config['metrics'][matches[0]][matches[1]] = matches[2]
        end
      end

      # Now, lets process the args hash
      if config['graph'].key?('args')
        config['graph']['args'] = parse_config_args(config['graph']['args'])
      end

      config
    end
Parse 'config' request