def control(options)

      # Initialize directory settings
      AgentConfig.cfg_dir = options[:cfg_dir]
      AgentConfig.pid_dir = options[:pid_dir]

      # List agents if requested
      list_configured_agents if options[:list]

      # Validate arguments
      action = options.delete(:action)
      fail("No action specified on the command line.", print_usage = true) unless action
      if action == 'kill' && (options[:pid_file].nil? || !File.file?(options[:pid_file]))
        fail("Missing or invalid pid file #{options[:pid_file]}", print_usage = true)
      end
      if options[:agent_name]
        if action == 'start'
          cfg = configure_agent(action, options)
        else
          cfg = AgentConfig.load_cfg(options[:agent_name])
          fail("Deployment is missing configuration file #{AgentConfig.cfg_file(options[:agent_name]).inspect}.") unless cfg
        end
        options.delete(:identity)
        options = cfg.merge(options)
        AgentConfig.root_dir = options[:root_dir]
        AgentConfig.pid_dir = options[:pid_dir]
        Log.program_name = syslog_program_name(options)
        Log.facility     = syslog_facility(options)
        Log.log_to_file_only(options[:log_to_file_only])
        configure_proxy(options[:http_proxy], options[:http_no_proxy]) if options[:http_proxy]
      elsif options[:identity]
        options[:agent_name] = AgentConfig.agent_name(options[:identity])
      end
      @options = DEFAULT_OPTIONS.clone.merge(options.merge(FORCED_OPTIONS))
      FileUtils.mkdir_p(@options[:pid_dir]) unless @options[:pid_dir].nil? || File.directory?(@options[:pid_dir])

      # Execute request
      success = case action
      when /show|killall/
        action = 'stop' if action == 'killall'
        s = true
        AgentConfig.cfg_agents.each { |agent_name| s &&= dispatch(action, agent_name) }
        s
      when 'kill'
        kill_process
      else
        dispatch(action, @options[:agent_name])
      end

      exit(1) unless success
    end
def control(options)

      # Initialize directory settings
      AgentConfig.cfg_dir = options[:cfg_dir]
      AgentConfig.pid_dir = options[:pid_dir]

      # List agents if requested
      list_configured_agents if options[:list]

      # Validate arguments
      action = options.delete(:action)
      fail("No action specified on the command line.", print_usage = true) unless action
      if action == 'kill' && (options[:pid_file].nil? || !File.file?(options[:pid_file]))
        fail("Missing or invalid pid file #{options[:pid_file]}", print_usage = true)
      end
      if options[:agent_name]
        if action == 'start'
          cfg = configure_agent(action, options)
        else
          cfg = AgentConfig.load_cfg(options[:agent_name])
          fail("Deployment is missing configuration file #{AgentConfig.cfg_file(options[:agent_name]).inspect}.") unless cfg
        end
        options.delete(:identity)
        options = cfg.merge(options)
        AgentConfig.root_dir = options[:root_dir]
        AgentConfig.pid_dir = options[:pid_dir]
        Log.program_name = syslog_program_name(options)
        Log.facility     = syslog_facility(options)
        Log.log_to_file_only(options[:log_to_file_only])
        configure_proxy(options[:http_proxy], options[:http_no_proxy]) if options[:http_proxy]
      elsif options[:identity]
        options[:agent_name] = AgentConfig.agent_name(options[:identity])
      end
      @options = DEFAULT_OPTIONS.clone.merge(options.merge(FORCED_OPTIONS))
      FileUtils.mkdir_p(@options[:pid_dir]) unless @options[:pid_dir].nil? || File.directory?(@options[:pid_dir])

      # Execute request
      success = case action
      when /show|killall/
        action = 'stop' if action == 'killall'
        s = true
        AgentConfig.cfg_agents.each { |agent_name| s &&= dispatch(action, agent_name) }
        s
      when 'kill'
        kill_process
      else
        dispatch(action, @options[:agent_name])
      end

      exit(1) unless success
    end
Parse arguments and execute request

 === Parameters
 options(Hash):: Command line options

 === Return
 true:: Always return true