Files
biztalk-checkmk-pulse/src/BizTalkCheckmkPulse/Models.cs
T

403 lines
14 KiB
C#

using System;
using System.Collections.Generic;
namespace BizTalkCheckmkPulse
{
/// <summary>
/// Definiert die von Checkmk erwarteten numerischen Service-Zustaende.
/// </summary>
internal enum CheckState
{
Ok = 0,
Warning = 1,
Critical = 2,
Unknown = 3
}
/// <summary>
/// Unterscheidet fortsetzbare und nicht fortsetzbare suspendierte Instanzen.
/// </summary>
internal enum SuspendedKind
{
Resumable,
NonResumable
}
/// <summary>
/// Kennzeichnet den technischen Bereich, in dem eine Diagnose entstanden ist.
/// </summary>
internal enum DiagnosticArea
{
Wmi,
Sql,
EventLog,
General
}
/// <summary>
/// Klassifiziert Fehler, damit Bediener eine passende Massnahme erhalten.
/// </summary>
internal enum DiagnosticCategory
{
Permission,
Connectivity,
Timeout,
Configuration,
Schema,
Provider,
Unexpected
}
/// <summary>
/// Strukturierte Diagnose mit Ursache und konkreter Handlungsempfehlung.
/// </summary>
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; }
/// <summary>
/// Erstellt eine kompakte, fuer Checkmk geeignete Diagnosezeile.
/// </summary>
/// <returns>Menschenlesbarer Text mit Kategorie, Ursache und Massnahme.</returns>
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;
}
}
/// <summary>
/// Sammelt alle Ergebnisse eines Programmlaufs.
/// </summary>
internal sealed class ProbeResult
{
/// <summary>
/// Initialisiert leere Ergebnislisten und Zustandsobjekte.
/// </summary>
public ProbeResult()
{
Diagnostics = new List<ProbeDiagnostic>();
Platform = new PlatformState();
HostInstances = new List<HostInstanceState>();
SuspendedInstances = new List<SuspendedInstance>();
ReceiveLocations = new List<ReceiveLocationState>();
SendPorts = new List<SendPortState>();
Applications = new List<ApplicationRuntimeState>();
SqlTargets = new List<SqlAccessState>();
EventLog = new EventLogState();
EndpointCandidates = new List<EndpointCandidate>();
EndpointConnectivity = new EndpointConnectivityState();
}
public List<ProbeDiagnostic> Diagnostics { get; private set; }
public PlatformState Platform { get; private set; }
public List<HostInstanceState> HostInstances { get; private set; }
public List<SuspendedInstance> SuspendedInstances { get; private set; }
public List<ReceiveLocationState> ReceiveLocations { get; private set; }
public List<SendPortState> SendPorts { get; private set; }
public List<ApplicationRuntimeState> Applications { get; private set; }
public List<SqlAccessState> SqlTargets { get; private set; }
public string ExecutionIdentity { get; set; }
public string NetworkIdentityHint { get; set; }
public EventLogState EventLog { get; private set; }
public List<EndpointCandidate> EndpointCandidates { get; private set; }
public EndpointConnectivityState EndpointConnectivity { get; private set; }
}
/// <summary>
/// Beschreibt Erreichbarkeit und Teilverfuegbarkeit der BizTalk-WMI-Daten.
/// </summary>
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; }
}
/// <summary>
/// Ergebnis der integrierten Anmeldung an einer BizTalk-Datenbank.
/// </summary>
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; }
}
/// <summary>
/// Laufzeitzustand einer BizTalk Host Instance.
/// </summary>
internal sealed class HostInstanceState
{
public string InstanceName { get; set; }
public string HostName { get; set; }
public string RunningServer { get; set; }
public int ServiceState { get; set; }
}
/// <summary>
/// Relevante Daten einer suspendierten BizTalk Service Instance.
/// </summary>
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; }
}
}
/// <summary>
/// Konfigurations- und Laufzeitzustand einer Receive Location.
/// </summary>
internal sealed class ReceiveLocationState
{
public string Name { get; set; }
public string ApplicationName { get; set; }
public bool? IsDisabled { get; set; }
}
/// <summary>
/// Laufzeitzustand eines Send Ports.
/// </summary>
internal sealed class SendPortState
{
public string Name { get; set; }
public string ApplicationName { get; set; }
public int Status { get; set; }
}
/// <summary>
/// Aggregierte Zustandszaehler einer BizTalk-Anwendung.
/// </summary>
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; }
}
/// <summary>
/// Ergebnis der Auswertung des lokalen Windows Application Event Logs.
/// </summary>
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; }
}
/// <summary>
/// Rohdaten eines BizTalk-Transports aus einer bereits ausgefuehrten Runtime-Abfrage.
/// Vollstaendige URIs werden nur im Speicher gehalten und weder persistiert noch ausgegeben.
/// </summary>
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);
}
}
}
/// <summary>
/// Ergebnis der geheimnisfreien Auswertung einer BizTalk-Transportadresse.
/// </summary>
internal enum EndpointResolutionStatus
{
Probeable,
ExpectedNonProbeable,
Unresolved
}
/// <summary>
/// Klassifiziert einen Kandidaten und enthaelt nur bei sicherer Aufloesung ein Socket-Ziel.
/// </summary>
internal sealed class EndpointResolution
{
public EndpointResolutionStatus Status { get; set; }
public EndpointCatalogEntry Entry { get; set; }
public string Reason { get; set; }
}
/// <summary>
/// Ein geheimnisfreier, lokal persistierbarer Netzwerk-Endpunkt.
/// </summary>
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; }
/// <summary>
/// Gibt an, dass ein automatisch abgeleiteter Adaptertest nur Diagnosewert besitzt
/// und ein Fehlschlag deshalb keinen Checkmk-Alarm ausloest.
/// </summary>
public bool BestEffort { get; set; }
/// <summary>
/// Erstellt den stabilen, adressunabhaengigen Schluessel eines BizTalk-Transports.
/// </summary>
/// <param name="artifactType">Typ des BizTalk-Artefakts.</param>
/// <param name="applicationName">Name der BizTalk-Anwendung.</param>
/// <param name="artifactName">Name des Send Ports oder der Receive Location.</param>
/// <param name="transportRole">Primaer-, Sekundaer- oder Inbound-Rolle.</param>
/// <returns>Normalisierter Katalogschluessel.</returns>
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();
}
}
/// <summary>
/// Versionierter Inhalt der automatisch gepflegten lokalen Endpoint-Konfiguration.
/// </summary>
internal sealed class EndpointCatalog
{
public EndpointCatalog()
{
Entries = new List<EndpointCatalogEntry>();
}
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<EndpointCatalogEntry> Entries { get; private set; }
}
/// <summary>
/// Ergebnis einer einzelnen TCP- beziehungsweise UDP-Netzwerkprobe.
/// </summary>
internal sealed class EndpointProbeResult
{
public EndpointCatalogEntry Endpoint { get; set; }
public bool Available { get; set; }
public long DurationMilliseconds { get; set; }
public string Failure { get; set; }
}
/// <summary>
/// Aggregierter Zustand des Endpoint-Katalogs und aller aktiven Netzwerkprobes.
/// </summary>
internal sealed class EndpointConnectivityState
{
public EndpointConnectivityState()
{
Results = new List<EndpointProbeResult>();
ResolutionIssues = new List<string>();
}
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; }
/// <summary>
/// Anzahl der automatisch abgeleiteten, nicht alarmierenden Adapterziele.
/// </summary>
public int BestEffortActive { get; set; }
/// <summary>
/// Anzahl fehlgeschlagener Best-Effort-Probes im aktuellen Lauf.
/// </summary>
public int BestEffortIgnoredFailures { get; set; }
public int ManualOverridesActive { get; set; }
public int UniqueTargets { get; set; }
public long ProbeDurationMilliseconds { get; set; }
public string Failure { get; set; }
public List<EndpointProbeResult> Results { get; private set; }
public List<string> ResolutionIssues { get; private set; }
}
}