From a399701755f2e29912de8d03c00ab641dad1e693 Mon Sep 17 00:00:00 2001 From: exsersewo Date: Sun, 15 Mar 2020 11:53:57 +0000 Subject: [PATCH] fix output --- Cachet-Monitor/Cachet-Monitor.csproj | 14 +++----- .../Configuration/Monitor/MonitorType.cs | 4 +-- Cachet-Monitor/Program.cs | 35 +++++++++++++------ 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Cachet-Monitor/Cachet-Monitor.csproj b/Cachet-Monitor/Cachet-Monitor.csproj index b561d2a..86c3ce8 100644 --- a/Cachet-Monitor/Cachet-Monitor.csproj +++ b/Cachet-Monitor/Cachet-Monitor.csproj @@ -1,11 +1,11 @@ - + Exe netcoreapp3.1 Cachet_Monitor - 0.1.1.0 - 0.1.1.0 + 2020.3.13.0 + 2020.3.13.0 0.1.1 @@ -23,15 +23,9 @@ - + - - - ..\CachNet.dll - - - diff --git a/Cachet-Monitor/Models/Configuration/Monitor/MonitorType.cs b/Cachet-Monitor/Models/Configuration/Monitor/MonitorType.cs index 9e373a2..cc9fd12 100644 --- a/Cachet-Monitor/Models/Configuration/Monitor/MonitorType.cs +++ b/Cachet-Monitor/Models/Configuration/Monitor/MonitorType.cs @@ -1,6 +1,4 @@ -using System; - -namespace Cachet_Monitor.Models.Config +namespace Cachet_Monitor.Models.Config { public enum MonitorType { diff --git a/Cachet-Monitor/Program.cs b/Cachet-Monitor/Program.cs index f52de2e..07f9ae2 100644 --- a/Cachet-Monitor/Program.cs +++ b/Cachet-Monitor/Program.cs @@ -12,6 +12,8 @@ using System.Net; using System.Diagnostics; using CachNet.Entities; using System.Net.NetworkInformation; +using System.Collections.Generic; +using System.Linq; namespace Cachet_Monitor { @@ -86,9 +88,10 @@ namespace Cachet_Monitor tcpClient.Connect(monitor.Target, monitor.Settings.Port); try { + componentStatus = ComponentStatus.Operational; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.Operational, + Status = componentStatus, }); Log.Debug("PortMonitorCheck", "Sent to Cachet successfully"); } @@ -103,9 +106,10 @@ namespace Cachet_Monitor try { + componentStatus = ComponentStatus.MajorOutage; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.MajorOutage, + Status = componentStatus, }); Log.Debug("PortMonitorCheck", "Sent to Cachet successfully"); } @@ -145,9 +149,10 @@ namespace Cachet_Monitor { try { + componentStatus = ComponentStatus.Operational; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.Operational, + Status = componentStatus, }); Log.Debug("IPMonitorCheck", "Sent to Cachet successfully"); } @@ -161,9 +166,10 @@ namespace Cachet_Monitor { try { + componentStatus = ComponentStatus.PerformanceIssues; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.PerformanceIssues, + Status = componentStatus, }); Log.Debug("IPMonitorCheck", "Sent to Cachet successfully"); } @@ -179,9 +185,10 @@ namespace Cachet_Monitor { try { + componentStatus = ComponentStatus.PartialOutage; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.PartialOutage, + Status = componentStatus, }); Log.Debug("IPMonitorCheck", "Sent to Cachet successfully"); } @@ -194,9 +201,10 @@ namespace Cachet_Monitor { try { + componentStatus = ComponentStatus.MajorOutage; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.MajorOutage, + Status = componentStatus, }); Log.Debug("IPMonitorCheck", "Sent to Cachet successfully"); } @@ -226,9 +234,10 @@ namespace Cachet_Monitor { try { + componentStatus = ComponentStatus.Operational; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.Operational, + Status = componentStatus, }); Log.Debug("WebMonitorCheck", "Sent to Cachet successfully"); } @@ -241,9 +250,10 @@ namespace Cachet_Monitor { try { + componentStatus = ComponentStatus.PartialOutage; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.PartialOutage, + Status = componentStatus, }); Log.Debug("WebMonitorCheck", "Sent to Cachet successfully"); } @@ -269,9 +279,10 @@ namespace Cachet_Monitor { try { + componentStatus = ComponentStatus.Operational; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.Operational, + Status = componentStatus, }); Log.Debug("WebMonitorCheck", "Sent to Cachet successfully"); } @@ -288,9 +299,10 @@ namespace Cachet_Monitor { try { + componentStatus = ComponentStatus.PerformanceIssues; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.PerformanceIssues, + Status = componentStatus, }); Log.Debug("WebMonitorCheck", "Sent to Cachet successfully"); } @@ -303,9 +315,10 @@ namespace Cachet_Monitor { try { + componentStatus = ComponentStatus.MajorOutage; await Cachet.UpdateComponentAsync(monitor.ComponentId, new PutComponent { - Status = ComponentStatus.MajorOutage, + Status = componentStatus, }); Log.Debug("WebMonitorCheck", "Sent to Cachet successfully"); }