public void ExecuteCheckCommand(JObject check, bool withUpdateCheck) { Log.Debug("Attempting to execute check command {0}", JsonConvert.SerializeObject(check, SerializerSettings)); if (check["name"] == null) { CheckDidNotHaveValidName(check); return; } var checkName = check["name"].ToString(); if (!checksInProgress.Lock(checkName)) { return; } try { var commandParseErrors = ""; check["command"] = SensuClientHelper.SubstitueCommandTokens( check, out commandParseErrors, (JObject)_sensuClientConfigurationReader.Configuration.Config["client"]); if (!String.IsNullOrEmpty(commandParseErrors)) { Log.Warn("Errors parsing the command: {0}", commandParseErrors); CheckDidNotHaveValidParameters(check, commandParseErrors); throw new Exception(String.Format("Errors parsing the command {0}", commandParseErrors)); } Log.Debug("Preparing check to be launched: {0}", checkName); int?timeout = null; if (check["timeout"] != null) { timeout = SensuClientHelper.TryParseNullable(check["timeout"].ToString()); } CommandConfiguration configuration = new CommandConfiguration(); configuration.Plugins = _sensuClientConfigurationReader.SensuClientConfig.Client.Plugins; configuration.TimeOut = timeout; var commandToExcecute = CommandFactory.Create(configuration , check["command"].ToString()); if (commandToExcecute is Command.RemoteCommand) { try { Log.Debug("About to run update: " + checkName); UpdateScheduler scheduler = new UpdateScheduler(); scheduler.ExecuteUpdateCheck(configuration, check); } catch (Exception e) { Log.Warn(e, "Error preparing update {0}", checkName); } } Log.Debug("About to run command: " + checkName); var executingTask = ExecuteCheck(check, commandToExcecute); checksInProgress.SetTask(checkName, executingTask); executingTask.ContinueWith <JObject>(ReportCheckResultAfterCompletion).ContinueWith(CheckCompleted); } catch (Exception e) { Log.Error(e, "Error preparing check {0}", checkName); checksInProgress.UnlockAnyway(checkName); } }