Пример #1
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         RpcInvokeMonitoringProbe.Reply reply = null;
         LocalizedException             ex    = null;
         try
         {
             Dictionary <string, string> dictionary = this.CreatePropertyBag();
             string text = string.Empty;
             if (dictionary != null && dictionary.Count != 0)
             {
                 text = CrimsonHelper.ConvertDictionaryToXml(dictionary);
             }
             this.ItemTargetExtension = (string.IsNullOrWhiteSpace(this.ItemTargetExtension) ? string.Empty : this.ItemTargetExtension);
             text  = (string.IsNullOrWhiteSpace(text) ? string.Empty : text);
             reply = RpcInvokeMonitoringProbe.Invoke(this.Server.Fqdn, this.Identity, text, this.ItemTargetExtension, 300000);
         }
         catch (ActiveMonitoringServerException ex2)
         {
             ex = ex2;
         }
         catch (ActiveMonitoringServerTransientException ex3)
         {
             ex = ex3;
         }
         if (ex != null)
         {
             this.WriteWarning(ex.LocalizedString);
         }
         else if (!string.IsNullOrEmpty(reply.ErrorMessage))
         {
             base.WriteWarning(reply.ErrorMessage);
         }
         else
         {
             MonitoringProbeResult sendToPipeline = new MonitoringProbeResult(this.Server.Fqdn, reply.ProbeResult);
             base.WriteObject(sendToPipeline);
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         Dictionary <string, string> dictionary = this.CreatePropertyBag();
         string text = null;
         if (dictionary.TryGetValue("ItemTargetExtension", out text))
         {
             dictionary.Remove("ItemTargetExtension");
         }
         string text2 = string.Empty;
         if (dictionary.Count != 0)
         {
             text2 = CrimsonHelper.ConvertDictionaryToXml(dictionary);
         }
         text  = (text ?? string.Empty);
         text2 = (text2 ?? string.Empty);
         RpcInvokeMonitoringProbe.Reply reply = RpcInvokeMonitoringProbe.Invoke(this.server.Fqdn, this.ProbeIdentity, text2, text, 300000);
         if (reply != null)
         {
             if (!string.IsNullOrEmpty(reply.ErrorMessage))
             {
                 throw new InvalidOperationException(reply.ErrorMessage);
             }
             MonitoringProbeResult monitoringProbeResult = new MonitoringProbeResult(this.server.Fqdn, reply.ProbeResult);
             this.WriteInfo(Strings.ProbeResult(monitoringProbeResult.ResultType.ToString()));
             if (monitoringProbeResult.ResultType != ResultType.Succeeded)
             {
                 string failedProbeResultDetailsString = string.Format("Error: {0}\r\nException: {1}", monitoringProbeResult.Error, monitoringProbeResult.Exception);
                 this.WriteWarning(Strings.FailedProbeResultDetails(failedProbeResultDetailsString));
             }
             base.WriteObject(monitoringProbeResult);
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Пример #3
0
        // Token: 0x06000062 RID: 98 RVA: 0x00004AA8 File Offset: 0x00002CA8
        public new void Publish(bool throwOnError)
        {
            string extensionXml = CrimsonHelper.ConvertDictionaryToXml(base.CustomProperties);

            NativeMethods.ProbeResultUnmanaged probeResultUnmanaged = new ProbeResult
            {
                ResultName         = base.ResultName,
                SampleValue        = base.SampleValue,
                ServiceName        = base.ServiceName,
                IsNotified         = true,
                ExecutionStartTime = base.TimeStamp,
                ExecutionEndTime   = base.TimeStamp,
                Error           = base.Message,
                ExtensionXml    = extensionXml,
                StateAttribute1 = base.StateAttribute1,
                StateAttribute2 = base.StateAttribute2,
                StateAttribute3 = base.StateAttribute3,
                StateAttribute4 = base.StateAttribute4,
                StateAttribute5 = base.StateAttribute5,
                WorkItemId      = DefinitionIdGenerator <ProbeDefinition> .GetIdForNotification(base.ResultName)
            }.ToUnmanaged();
            try
            {
                ComplianceCrimsonEvent complianceCrimsonEvent = ComplianceCrimsonEvents.EvtDarRuntimeLog;
                if (base.Severity == ResultSeverityLevel.Informational)
                {
                    complianceCrimsonEvent = ComplianceCrimsonEvents.EvtDiscoveryInfo;
                }
                complianceCrimsonEvent.LogGeneric(new object[]
                {
                    DateTime.UtcNow.Ticks.ToString(),
                    probeResultUnmanaged.ServiceName,
                    probeResultUnmanaged.ResultName,
                    probeResultUnmanaged.WorkItemId.ToString(),
                    LogItem.build,
                    probeResultUnmanaged.MachineName,
                    probeResultUnmanaged.Error,
                    probeResultUnmanaged.Exception,
                    probeResultUnmanaged.RetryCount.ToString(),
                    probeResultUnmanaged.StateAttribute1,
                    probeResultUnmanaged.StateAttribute2,
                    probeResultUnmanaged.StateAttribute3,
                    probeResultUnmanaged.StateAttribute4,
                    probeResultUnmanaged.StateAttribute5,
                    base.Severity.ToString(),
                    probeResultUnmanaged.ExecutionStartTime,
                    probeResultUnmanaged.ExtensionXml,
                    probeResultUnmanaged.Version.ToString()
                });
            }
            catch
            {
                if (throwOnError)
                {
                    throw;
                }
            }
            finally
            {
                if (LogSettings.IsMonitored(base.ResultName))
                {
                    base.Publish(throwOnError);
                }
            }
        }