using System; using System.Collections.Generic; namespace BizTalkCheckmkPulse { /// /// Definiert die von Checkmk erwarteten numerischen Service-Zustaende. /// internal enum CheckState { Ok = 0, Warning = 1, Critical = 2, Unknown = 3 } /// /// Unterscheidet fortsetzbare und nicht fortsetzbare suspendierte Instanzen. /// internal enum SuspendedKind { Resumable, NonResumable } /// /// Kennzeichnet den technischen Bereich, in dem eine Diagnose entstanden ist. /// internal enum DiagnosticArea { Wmi, Sql, EventLog, General } /// /// Klassifiziert Fehler, damit Bediener eine passende Massnahme erhalten. /// internal enum DiagnosticCategory { Permission, Connectivity, Timeout, Configuration, Schema, Provider, Unexpected } /// /// Strukturierte Diagnose mit Ursache und konkreter Handlungsempfehlung. /// internal sealed class ProbeDiagnostic { public DiagnosticArea Area { get; set; } public DiagnosticCategory Category { get; set; } public string Component { get; set; } public bool Required { get; set; } public string Summary { get; set; } public string Action { get; set; } public string TechnicalDetails { get; set; } /// /// Erstellt eine kompakte, fuer Checkmk geeignete Diagnosezeile. /// /// Menschenlesbarer Text mit Kategorie, Ursache und Massnahme. public string ToDisplayText() { var text = Area + "/" + Category + " [" + (Component ?? "unknown") + "]: " + (Summary ?? "Unbekannter Fehler."); if (!string.IsNullOrWhiteSpace(Action)) { text += " Massnahme: " + Action; } if (!string.IsNullOrWhiteSpace(TechnicalDetails)) { text += " Technik: " + TechnicalDetails; } return text; } } /// /// Sammelt alle Ergebnisse eines Programmlaufs. /// internal sealed class ProbeResult { /// /// Initialisiert leere Ergebnislisten und Zustandsobjekte. /// public ProbeResult() { Diagnostics = new List(); Platform = new PlatformState(); HostInstances = new List(); SuspendedInstances = new List(); ReceiveLocations = new List(); SendPorts = new List(); Applications = new List(); SqlTargets = new List(); EventLog = new EventLogState(); EndpointCandidates = new List(); EndpointConnectivity = new EndpointConnectivityState(); } public List Diagnostics { get; private set; } public PlatformState Platform { get; private set; } public List HostInstances { get; private set; } public List SuspendedInstances { get; private set; } public List ReceiveLocations { get; private set; } public List SendPorts { get; private set; } public List Applications { get; private set; } public List SqlTargets { get; private set; } public string ExecutionIdentity { get; set; } public string NetworkIdentityHint { get; set; } public EventLogState EventLog { get; private set; } public List EndpointCandidates { get; private set; } public EndpointConnectivityState EndpointConnectivity { get; private set; } } /// /// Beschreibt Erreichbarkeit und Teilverfuegbarkeit der BizTalk-WMI-Daten. /// internal sealed class PlatformState { public bool WmiConnected { get; set; } public bool PlatformDataAvailable { get; set; } public bool HostInstancesDataAvailable { get; set; } public bool SuspendedInstancesDataAvailable { get; set; } public bool ReceiveLocationsDataAvailable { get; set; } public bool SendPortsDataAvailable { get; set; } public bool OrchestrationsDataAvailable { get; set; } public string ServerName { get; set; } public string GroupName { get; set; } public string OperatorGroup { get; set; } public string ReadOnlyUserGroup { get; set; } public string ManagementDbServer { get; set; } public string ManagementDbName { get; set; } public string MessageBoxDbServer { get; set; } public string MessageBoxDbName { get; set; } } /// /// Ergebnis der integrierten Anmeldung an einer BizTalk-Datenbank. /// internal sealed class SqlAccessState { public string Role { get; set; } public string Server { get; set; } public string Database { get; set; } public bool Attempted { get; set; } public bool Available { get; set; } public DiagnosticCategory? FailureCategory { get; set; } public string Failure { get; set; } } /// /// Laufzeitzustand einer BizTalk Host Instance. /// internal sealed class HostInstanceState { public string InstanceName { get; set; } public string HostName { get; set; } public string RunningServer { get; set; } public int ServiceState { get; set; } } /// /// Relevante Daten einer suspendierten BizTalk Service Instance. /// internal sealed class SuspendedInstance { public string ApplicationName { get; set; } public string ServiceName { get; set; } public string HostName { get; set; } public string ServiceClass { get; set; } public string InstanceId { get; set; } public string ErrorDescription { get; set; } public DateTime? SuspendTime { get; set; } public int ServiceClassId { get; set; } public SuspendedKind Kind { get; set; } public bool IsRoutingFailureReport { get { return ServiceClassId == 64; } } } /// /// Konfigurations- und Laufzeitzustand einer Receive Location. /// internal sealed class ReceiveLocationState { public string Name { get; set; } public string ApplicationName { get; set; } public bool? IsDisabled { get; set; } } /// /// Laufzeitzustand eines Send Ports. /// internal sealed class SendPortState { public string Name { get; set; } public string ApplicationName { get; set; } public int Status { get; set; } } /// /// Aggregierte Zustandszaehler einer BizTalk-Anwendung. /// internal sealed class ApplicationRuntimeState { public string ApplicationName { get; set; } public int ReceiveLocationTotal { get; set; } public int ReceiveLocationDisabled { get; set; } public int SendPortTotal { get; set; } public int SendPortStarted { get; set; } public int SendPortStopped { get; set; } public int SendPortBound { get; set; } public int SendPortUnknown { get; set; } public int OrchestrationTotal { get; set; } public int OrchestrationStarted { get; set; } public int OrchestrationStopped { get; set; } public int OrchestrationBound { get; set; } public int OrchestrationUnbound { get; set; } public int OrchestrationUnknown { get; set; } } /// /// Ergebnis der Auswertung des lokalen Windows Application Event Logs. /// internal sealed class EventLogState { public bool Available { get; set; } public int Errors { get; set; } public int Warnings { get; set; } public DateTime Since { get; set; } public string Failure { get; set; } } /// /// Rohdaten eines BizTalk-Transports aus einer bereits ausgefuehrten Runtime-Abfrage. /// Vollstaendige URIs werden nur im Speicher gehalten und weder persistiert noch ausgegeben. /// internal sealed class EndpointCandidate { public string ArtifactType { get; set; } public string ApplicationName { get; set; } public string ArtifactName { get; set; } public string TransportRole { get; set; } public string AdapterName { get; set; } public string Address { get; set; } public bool Active { get; set; } public bool Dynamic { get; set; } public string Key { get { return EndpointCatalogEntry.BuildKey( ArtifactType, ApplicationName, ArtifactName, TransportRole); } } } /// /// Ergebnis der geheimnisfreien Auswertung einer BizTalk-Transportadresse. /// internal enum EndpointResolutionStatus { Probeable, ExpectedNonProbeable, Unresolved } /// /// Klassifiziert einen Kandidaten und enthaelt nur bei sicherer Aufloesung ein Socket-Ziel. /// internal sealed class EndpointResolution { public EndpointResolutionStatus Status { get; set; } public EndpointCatalogEntry Entry { get; set; } public string Reason { get; set; } } /// /// Ein geheimnisfreier, lokal persistierbarer Netzwerk-Endpunkt. /// internal sealed class EndpointCatalogEntry { public string Key { get; set; } public string ArtifactType { get; set; } public string ApplicationName { get; set; } public string ArtifactName { get; set; } public string TransportRole { get; set; } public string AdapterName { get; set; } public string Protocol { get; set; } public string Host { get; set; } public int Port { get; set; } public bool Enabled { get; set; } public bool AutoDiscovered { get; set; } public static string BuildKey(string artifactType, string applicationName, string artifactName, string transportRole) { return NormalizeKeyPart(artifactType) + "|" + NormalizeKeyPart(applicationName) + "|" + NormalizeKeyPart(artifactName) + "|" + NormalizeKeyPart(transportRole); } private static string NormalizeKeyPart(string value) { return (value ?? string.Empty).Trim().ToUpperInvariant(); } } /// /// Versionierter Inhalt der automatisch gepflegten lokalen Endpoint-Konfiguration. /// internal sealed class EndpointCatalog { public EndpointCatalog() { Entries = new List(); } public DateTime SynchronizedUtc { get; set; } public string MachineName { get; set; } public string EnvironmentName { get; set; } public int ActiveCandidates { get; set; } public int UnresolvedCandidates { get; set; } public List Entries { get; private set; } } /// /// Ergebnis einer einzelnen TCP- beziehungsweise UDP-Netzwerkprobe. /// internal sealed class EndpointProbeResult { public EndpointCatalogEntry Endpoint { get; set; } public bool Available { get; set; } public long DurationMilliseconds { get; set; } public string Failure { get; set; } } /// /// Aggregierter Zustand des Endpoint-Katalogs und aller aktiven Netzwerkprobes. /// internal sealed class EndpointConnectivityState { public EndpointConnectivityState() { Results = new List(); ResolutionIssues = new List(); } public bool Disabled { get; set; } public bool CatalogAvailable { get; set; } public bool RuntimeStateAvailable { get; set; } public bool RefreshRequired { get; set; } public bool RefreshSucceeded { get; set; } public DateTime? CatalogSynchronizedUtc { get; set; } public int Configured { get; set; } public int Active { get; set; } public int SkippedInactive { get; set; } public int UnresolvedActive { get; set; } public int ExpectedNonProbeableActive { get; set; } public int ManualOverridesActive { get; set; } public int UniqueTargets { get; set; } public long ProbeDurationMilliseconds { get; set; } public string Failure { get; set; } public List Results { get; private set; } public List ResolutionIssues { get; private set; } } }