def check
      begin
        checker_identity = "#{@agent[:identity]}-rchk"
        pid_file = PidFile.new(checker_identity, @agent[:pid_dir])

        if @options[:stop]
          # Stop checker
          pid_data = pid_file.read_pid
          if pid_data[:pid]
            info("Stopping checker daemon")
            if RightScale::Platform.windows?
              begin
                send_command({:name => :terminate}, verbose = @options[:verbose], timeout = 30) do |r|
                  info(r)
                  terminate
                end
              rescue Exception => e
                error("Failed stopping checker daemon, confirm it is still running", e, abort = true)
              end
            else
              Process.kill('TERM', pid_data[:pid])
              terminate
            end
          else
            terminate
          end
        elsif @options[:daemon]
          # Run checker as daemon
          pid_file.check rescue error("Cannot start checker daemon because already running", nil, abort = true)
          daemonize(checker_identity, @options) unless RightScale::Platform.windows?
          pid_file.write
          at_exit { pid_file.remove }

          listen_port = CommandConstants::BASE_INSTANCE_AGENT_CHECKER_SOCKET_PORT
          @command_runner = CommandRunner.start(listen_port, checker_identity, AgentCheckerCommands.get(self))

          info("Checker daemon options:")
          log_options = @options.inject([]) { |t, (k, v)| t << "-  #{k}: #{v}" }
          log_options.each { |l| info(l, to_console = false, no_check = true) }

          info("Starting checker daemon with #{elapsed(@options[:time_limit])} polling " +
               "and #{elapsed(@options[:time_limit])} last communication limit")

          iteration = 0
          EM.add_periodic_timer(@options[:time_limit]) do
            iteration += 1
            debug("Checker iteration #{iteration}")
            check_communication(0)
          end
        else
          # Perform one check
          check_communication(0, @options[:ping])
        end
      rescue SystemExit => e
        raise e
      rescue Exception => e
        error("Internal checker failure", e, abort = true)
      end
      true
    end
def check
      begin
        checker_identity = "#{@agent[:identity]}-rchk"
        pid_file = PidFile.new(checker_identity, @agent[:pid_dir])

        if @options[:stop]
          # Stop checker
          pid_data = pid_file.read_pid
          if pid_data[:pid]
            info("Stopping checker daemon")
            if RightScale::Platform.windows?
              begin
                send_command({:name => :terminate}, verbose = @options[:verbose], timeout = 30) do |r|
                  info(r)
                  terminate
                end
              rescue Exception => e
                error("Failed stopping checker daemon, confirm it is still running", e, abort = true)
              end
            else
              Process.kill('TERM', pid_data[:pid])
              terminate
            end
          else
            terminate
          end
        elsif @options[:daemon]
          # Run checker as daemon
          pid_file.check rescue error("Cannot start checker daemon because already running", nil, abort = true)
          daemonize(checker_identity, @options) unless RightScale::Platform.windows?
          pid_file.write
          at_exit { pid_file.remove }

          listen_port = CommandConstants::BASE_INSTANCE_AGENT_CHECKER_SOCKET_PORT
          @command_runner = CommandRunner.start(listen_port, checker_identity, AgentCheckerCommands.get(self))

          info("Checker daemon options:")
          log_options = @options.inject([]) { |t, (k, v)| t << "-  #{k}: #{v}" }
          log_options.each { |l| info(l, to_console = false, no_check = true) }

          info("Starting checker daemon with #{elapsed(@options[:time_limit])} polling " +
               "and #{elapsed(@options[:time_limit])} last communication limit")

          iteration = 0
          EM.add_periodic_timer(@options[:time_limit]) do
            iteration += 1
            debug("Checker iteration #{iteration}")
            check_communication(0)
          end
        else
          # Perform one check
          check_communication(0, @options[:ping])
        end
      rescue SystemExit => e
        raise e
      rescue Exception => e
        error("Internal checker failure", e, abort = true)
      end
      true
    end
Perform required checks

 === Return
 true:: Always return true