Compare commits
	
		
			3 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 8cae455a50 | |||
| 8311e26759 | |||
| 6eb36f44c5 | 
							
								
								
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							| @ -10,6 +10,7 @@ | |||||||
|     "**/node_modules": true |     "**/node_modules": true | ||||||
|   }, |   }, | ||||||
|   "cSpell.words": [ |   "cSpell.words": [ | ||||||
|     "Gatus" |     "Gatus", | ||||||
|  |     "Infineon" | ||||||
|   ] |   ] | ||||||
| } | } | ||||||
| @ -16,7 +16,7 @@ | |||||||
|     <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" /> |     <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" /> | ||||||
|     <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" /> |     <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" /> | ||||||
|     <PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.1" /> |     <PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.1" /> | ||||||
|     <PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.14" /> |     <PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.15" /> | ||||||
|     <PackageReference Include="System.Text.Json" Version="9.0.2" /> |     <PackageReference Include="System.Text.Json" Version="9.0.2" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| </Project> | </Project> | ||||||
| @ -1,4 +1,5 @@ | |||||||
| using System.Collections.ObjectModel; | using System.Collections.ObjectModel; | ||||||
|  | using System.Net.Http.Headers; | ||||||
|  |  | ||||||
| using Gatus.To.MonA.Infineon.Monitoring.MonA; | using Gatus.To.MonA.Infineon.Monitoring.MonA; | ||||||
| using Gatus.To.MonA.Models; | using Gatus.To.MonA.Models; | ||||||
| @ -8,11 +9,52 @@ namespace Gatus.To.MonA.Helpers; | |||||||
| internal static partial class HelperGatusToMona { | internal static partial class HelperGatusToMona { | ||||||
|  |  | ||||||
|     private static IMonIn? _MonIn; |     private static IMonIn? _MonIn; | ||||||
|  |     private static HttpClient? _HttpClient; | ||||||
|  |  | ||||||
|     private static string GetFile(AppSettings appSettings) => |     private static string GetFile(AppSettings appSettings) => | ||||||
|         Path.Combine(appSettings.GatusToMonaConfiguration.Directory, appSettings.GatusConfiguration.FileName); |         Path.Combine(appSettings.GatusToMonaConfiguration.Directory, appSettings.GatusConfiguration.FileName); | ||||||
|  |  | ||||||
|     internal static bool UpdateCount(AppSettings appSettings, ILogger<Worker> logger, CancellationToken cancellationToken) { |     internal static void Heartbeat(AppSettings appSettings, IHttpClientFactory httpClientFactory, ILogger<Worker> logger, State state, CancellationToken cancellationToken) { | ||||||
|  |         _MonIn ??= MonIn.GetInstance(httpClientFactory); | ||||||
|  |         CreateEmptyFile(appSettings); | ||||||
|  |         Task<HttpResponseMessage> httpResponseMessage = _MonIn.SendStatus(appSettings.MonAConfiguration.Site, | ||||||
|  |                                                                           appSettings.MonAConfiguration.Resource, | ||||||
|  |                                                                           appSettings.MonAConfiguration.StateName, | ||||||
|  |                                                                           state); | ||||||
|  |         httpResponseMessage.Wait(cancellationToken); | ||||||
|  |         logger.LogInformation("Line {line}: {OriginalString} => {Resource} : {StateName} ; {state}", | ||||||
|  |                               99, | ||||||
|  |                               httpResponseMessage.Result.RequestMessage.RequestUri.OriginalString, | ||||||
|  |                               appSettings.MonAConfiguration.Resource, | ||||||
|  |                               appSettings.MonAConfiguration.StateName, | ||||||
|  |                               state); | ||||||
|  |         if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK) | ||||||
|  |             throw new Exception(httpResponseMessage.Result.StatusCode.ToString()); | ||||||
|  |         Task<string> body = httpResponseMessage.Result.Content.ReadAsStringAsync(cancellationToken); | ||||||
|  |         body.Wait(cancellationToken); | ||||||
|  |         logger.LogInformation("Line {line}: {Result}", | ||||||
|  |                               10, | ||||||
|  |                               body.Result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private static void CreateEmptyFile(AppSettings appSettings) { | ||||||
|  |         if (!Directory.Exists(appSettings.GatusToMonaConfiguration.Directory)) | ||||||
|  |             _ = Directory.CreateDirectory(appSettings.GatusToMonaConfiguration.Directory); | ||||||
|  |         string file = GetFile(appSettings); | ||||||
|  |         File.WriteAllText(file, string.Empty); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     internal static bool UpdateCount(AppSettings appSettings, IHttpClientFactory httpClientFactory, ILogger<Worker> logger, CancellationToken cancellationToken) { | ||||||
|  |         _MonIn ??= MonIn.GetInstance(httpClientFactory); | ||||||
|  |         if (_HttpClient is null) { | ||||||
|  |             _HttpClient = httpClientFactory.CreateClient(); | ||||||
|  |             _HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", appSettings.GatusConfiguration.Token); | ||||||
|  |         } | ||||||
|  |         Task<HttpResponseMessage> httpResponseMessage = _HttpClient.PostAsync($"{appSettings.GatusConfiguration.BaseUniformResourceLocator}/api/v1/endpoints/{appSettings.GatusConfiguration.Key}/external?success=true&error=", null, cancellationToken); | ||||||
|  |         httpResponseMessage.Wait(cancellationToken); | ||||||
|  |         if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK) | ||||||
|  |             logger.LogWarning("Result is {statusCode}", httpResponseMessage.Result.StatusCode); | ||||||
|  |         Heartbeat(appSettings, httpClientFactory, logger, State.Up, cancellationToken); | ||||||
|         ReadOnlyCollection<string> successMatches = GetSuccessMatches(appSettings, logger, cancellationToken); |         ReadOnlyCollection<string> successMatches = GetSuccessMatches(appSettings, logger, cancellationToken); | ||||||
|         SendPerformanceMessage(appSettings, logger, successMatches, cancellationToken); |         SendPerformanceMessage(appSettings, logger, successMatches, cancellationToken); | ||||||
|         return true; |         return true; | ||||||
| @ -35,10 +77,15 @@ internal static partial class HelperGatusToMona { | |||||||
|                 continue; |                 continue; | ||||||
|             if (value[^1] is not '0' and not '1') |             if (value[^1] is not '0' and not '1') | ||||||
|                 continue; |                 continue; | ||||||
|             logger.LogDebug(value); |             logger.LogInformation("Line {line}: {value}", | ||||||
|  |                                   39, | ||||||
|  |                                   value); | ||||||
|             if (line.EndsWith('1')) |             if (line.EndsWith('1')) | ||||||
|                 results.Add(string.Concat('{', value)); |                 results.Add(string.Concat('{', value)); | ||||||
|         } |         } | ||||||
|  |         logger.LogInformation("Line {line}: {results}", | ||||||
|  |                               45, | ||||||
|  |                               string.Join(Environment.NewLine, results)); | ||||||
|         return results.AsReadOnly(); |         return results.AsReadOnly(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -46,7 +93,7 @@ internal static partial class HelperGatusToMona { | |||||||
|         string[] results; |         string[] results; | ||||||
|         FileStream fileStream = new(file, FileMode.Truncate); |         FileStream fileStream = new(file, FileMode.Truncate); | ||||||
|         HttpClient httpClient = new(); |         HttpClient httpClient = new(); | ||||||
|         Task<Stream> streamTask = httpClient.GetStreamAsync(appSettings.GatusConfiguration.URL, cancellationToken); |         Task<Stream> streamTask = httpClient.GetStreamAsync($"{appSettings.GatusConfiguration.BaseUniformResourceLocator}/metrics", cancellationToken); | ||||||
|         streamTask.Wait(cancellationToken); |         streamTask.Wait(cancellationToken); | ||||||
|         Task task = streamTask.Result.CopyToAsync(fileStream, cancellationToken); |         Task task = streamTask.Result.CopyToAsync(fileStream, cancellationToken); | ||||||
|         task.Wait(cancellationToken); |         task.Wait(cancellationToken); | ||||||
| @ -59,39 +106,27 @@ internal static partial class HelperGatusToMona { | |||||||
|  |  | ||||||
|     private static void SendPerformanceMessage(AppSettings appSettings, ILogger<Worker> logger, ReadOnlyCollection<string> successMatches, CancellationToken cancellationToken) { |     private static void SendPerformanceMessage(AppSettings appSettings, ILogger<Worker> logger, ReadOnlyCollection<string> successMatches, CancellationToken cancellationToken) { | ||||||
|         string performanceName = string.Concat(appSettings.MonAConfiguration.Resource, appSettings.MonAConfiguration.Suffix); |         string performanceName = string.Concat(appSettings.MonAConfiguration.Resource, appSettings.MonAConfiguration.Suffix); | ||||||
|  |         double v = successMatches.Count / appSettings.MonAConfiguration.Expected; | ||||||
|  |         double value = Math.Round(v, 3) * 100; | ||||||
|         Task<HttpResponseMessage> httpResponseMessage = _MonIn.SendPerformanceMessage(appSettings.MonAConfiguration.Site, |         Task<HttpResponseMessage> httpResponseMessage = _MonIn.SendPerformanceMessage(appSettings.MonAConfiguration.Site, | ||||||
|                                                                                       appSettings.MonAConfiguration.Resource, |                                                                                       appSettings.MonAConfiguration.Resource, | ||||||
|                                                                                       performanceName, |                                                                                       performanceName, | ||||||
|                                                                                       value: successMatches.Count, |                                                                                       value, | ||||||
|                                                                                       description: string.Empty); |                                                                                       description: string.Empty); | ||||||
|         httpResponseMessage.Wait(cancellationToken); |         httpResponseMessage.Wait(cancellationToken); | ||||||
|         if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK) |         logger.LogInformation("Line {line}: {OriginalString} => {Resource} : {performanceName} ; {value}", | ||||||
|             throw new Exception(httpResponseMessage.Result.StatusCode.ToString()); |                               76, | ||||||
|         Task<string> body = httpResponseMessage.Result.Content.ReadAsStringAsync(cancellationToken); |                               httpResponseMessage.Result.RequestMessage.RequestUri.OriginalString, | ||||||
|         body.Wait(cancellationToken); |  | ||||||
|         logger.LogDebug(body.Result); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     internal static void Heartbeat(AppSettings appSettings, IHttpClientFactory httpClientFactory, ILogger<Worker> logger, State state, CancellationToken cancellationToken) { |  | ||||||
|         _MonIn ??= MonIn.GetInstance(httpClientFactory); |  | ||||||
|         CreateEmptyFile(appSettings); |  | ||||||
|         Task<HttpResponseMessage> httpResponseMessage = _MonIn.SendStatus(appSettings.MonAConfiguration.Site, |  | ||||||
|                               appSettings.MonAConfiguration.Resource, |                               appSettings.MonAConfiguration.Resource, | ||||||
|                                                                           appSettings.MonAConfiguration.StateName, |                               performanceName, | ||||||
|                                                                           state); |                               value); | ||||||
|         httpResponseMessage.Wait(cancellationToken); |  | ||||||
|         if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK) |         if (httpResponseMessage.Result.StatusCode != System.Net.HttpStatusCode.OK) | ||||||
|             throw new Exception(httpResponseMessage.Result.StatusCode.ToString()); |             throw new Exception(httpResponseMessage.Result.StatusCode.ToString()); | ||||||
|         Task<string> body = httpResponseMessage.Result.Content.ReadAsStringAsync(cancellationToken); |         Task<string> body = httpResponseMessage.Result.Content.ReadAsStringAsync(cancellationToken); | ||||||
|         body.Wait(cancellationToken); |         body.Wait(cancellationToken); | ||||||
|         logger.LogDebug(body.Result); |         logger.LogInformation("Line {line}: {Result}", | ||||||
|     } |                               86, | ||||||
|  |                               body.Result); | ||||||
|     private static void CreateEmptyFile(AppSettings appSettings) { |  | ||||||
|         if (!Directory.Exists(appSettings.GatusToMonaConfiguration.Directory)) |  | ||||||
|             _ = Directory.CreateDirectory(appSettings.GatusToMonaConfiguration.Directory); |  | ||||||
|         string file = GetFile(appSettings); |  | ||||||
|         File.WriteAllText(file, string.Empty); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
| @ -39,7 +39,9 @@ public record AppSettings(GatusConfiguration GatusConfiguration, | |||||||
|         if (string.IsNullOrEmpty(appSettings.GatusToMonaConfiguration.Company)) |         if (string.IsNullOrEmpty(appSettings.GatusToMonaConfiguration.Company)) | ||||||
|             throw new Exception("Company name must have a value!"); |             throw new Exception("Company name must have a value!"); | ||||||
|         if (appSettings.MonAConfiguration.Minutes < 1) |         if (appSettings.MonAConfiguration.Minutes < 1) | ||||||
|             throw new Exception("MonA Minutes must have a value more than one!"); |             throw new Exception("MonA Minutes must have a value more than zero!"); | ||||||
|  |         if (appSettings.MonAConfiguration.Expected < 1) | ||||||
|  |             throw new Exception("MonA Expected must have a value more than zero!"); | ||||||
|         TimeSpan timeSpan = new(DateTime.MinValue.AddMinutes(appSettings.MonAConfiguration.Minutes).Ticks - DateTime.MinValue.Ticks); |         TimeSpan timeSpan = new(DateTime.MinValue.AddMinutes(appSettings.MonAConfiguration.Minutes).Ticks - DateTime.MinValue.Ticks); | ||||||
|         if (appSettings.GatusToMonaConfiguration.MillisecondsDelay < timeSpan.TotalMilliseconds) |         if (appSettings.GatusToMonaConfiguration.MillisecondsDelay < timeSpan.TotalMilliseconds) | ||||||
|             throw new Exception($"MonA doesn't support more than once per five minutes ({timeSpan.TotalMilliseconds})!"); |             throw new Exception($"MonA doesn't support more than once per five minutes ({timeSpan.TotalMilliseconds})!"); | ||||||
|  | |||||||
| @ -3,9 +3,11 @@ using System.Text.Json.Serialization; | |||||||
|  |  | ||||||
| namespace Gatus.To.MonA.Models; | namespace Gatus.To.MonA.Models; | ||||||
|  |  | ||||||
| public record GatusConfiguration(string FileName, | public record GatusConfiguration(string BaseUniformResourceLocator, | ||||||
|  |                                  string FileName, | ||||||
|  |                                  string Key, | ||||||
|                                  string Metric, |                                  string Metric, | ||||||
|                                  string URL) { |                                  string Token) { | ||||||
|  |  | ||||||
|     public override string ToString() { |     public override string ToString() { | ||||||
|         string result = JsonSerializer.Serialize(this, GatusConfigurationSourceGenerationContext.Default.GatusConfiguration); |         string result = JsonSerializer.Serialize(this, GatusConfigurationSourceGenerationContext.Default.GatusConfiguration); | ||||||
|  | |||||||
| @ -3,7 +3,8 @@ using System.Text.Json.Serialization; | |||||||
|  |  | ||||||
| namespace Gatus.To.MonA.Models; | namespace Gatus.To.MonA.Models; | ||||||
|  |  | ||||||
| public record MonAConfiguration(int Minutes, | public record MonAConfiguration(int Expected, | ||||||
|  |                                 int Minutes, | ||||||
|                                 string Resource, |                                 string Resource, | ||||||
|                                 string Site, |                                 string Site, | ||||||
|                                 string StateName, |                                 string StateName, | ||||||
|  | |||||||
							
								
								
									
										208
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										208
									
								
								README.md
									
									
									
									
									
								
							| @ -1,20 +1,196 @@ | |||||||
| # Introduction  | --- | ||||||
| TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.  | created: 2024-11-07T00:14:29.000Z | ||||||
|  | type: note | ||||||
|  | --- | ||||||
|  |  | ||||||
| # Getting Started | # Gatus | ||||||
| TODO: Guide users through getting your code up and running on their own system. In this section you can talk about: |  | ||||||
| 1.	Installation process |  | ||||||
| 2.	Software dependencies |  | ||||||
| 3.	Latest releases |  | ||||||
| 4.	API references |  | ||||||
|  |  | ||||||
| # Build and Test | Gatus is an advanced automated status page that lets you monitor your applications and configure alerts to notify you if there's an issue | ||||||
| TODO: Describe and show how to build your code and run the tests.  |  | ||||||
|  |  | ||||||
| # Contribute | ## Links | ||||||
| TODO: Explain how other users and developers can contribute to make your code better.  |  | ||||||
|  |  | ||||||
| If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files: | - [gatus.io](https://gatus.io/) | ||||||
| - [ASP.NET Core](https://github.com/aspnet/Home) | - [github](https://github.com/TwiN/gatus) | ||||||
| - [Visual Studio Code](https://github.com/Microsoft/vscode) | - [techno-tim](https://technotim.live/posts/gatus-uptime-monitoring/#gatus-config) | ||||||
| - [Chakra Core](https://github.com/Microsoft/ChakraCore) |  | ||||||
|  | ## Install | ||||||
|  |  | ||||||
|  | - [ ] CasaOS | ||||||
|  | - [x] Docker | ||||||
|  | - [ ] Home Assistant | ||||||
|  | - [ ] lxc | ||||||
|  | - [ ] Snap | ||||||
|  | - [ ] TTeck | ||||||
|  | - [ ] Umbrel | ||||||
|  | - [ ] Yu No Host | ||||||
|  |  | ||||||
|  | ## Gatus | ||||||
|  |  | ||||||
|  | - Clone repo from github or local ADO | ||||||
|  | - Build using go lang | ||||||
|  | - Copy exe only to server | ||||||
|  | - Create *.yaml file for configuration | ||||||
|  |  | ||||||
|  | ## NSSM - the Non-Sucking Service Manager | ||||||
|  |  | ||||||
|  | - Copy zip to server and extract to directory | ||||||
|  | - Run a cmd window with administrator access | ||||||
|  |  | ||||||
|  | ### ecFIsysadmin-10.95.140.37-messa010ec(OI-Metrology-Viewer) | ||||||
|  |  | ||||||
|  | ```bash 1744999536292 = 638805963362920000 = 2025-1.Spring = Fri Apr 18 2025 11:05:35 GMT-0700 (Mountain Standard Time) | ||||||
|  | mklink /J "D:\web-sites\Gatus\current" "D:\web-sites\Gatus\v5.17.0" | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ```bash 1744999568664 = 638805963686640000 = 2025-1.Spring = Fri Apr 18 2025 11:06:08 GMT-0700 (Mountain Standard Time) | ||||||
|  | # cd "C:\Users\ecfisysadmin\AppData\Local\IFXApps\nssm-2.24\win64" | ||||||
|  | C: | ||||||
|  | cd "C:\Windows\System32\config\systemprofile\AppData\Local\IFXApps\nssm-2.24\win64" | ||||||
|  | nssm install gatus | ||||||
|  | nssm edit gatus | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ```yaml NSSM-Application 1743806212388 = 638794030123880000 = 2025-1.Spring = Fri Apr 04 2025 15:36:51 GMT-0700 (Mountain Standard Time) | ||||||
|  | Path: D:\web-sites\Gatus\current\gatus.exe | ||||||
|  | Startup Directory: D:\web-sites\Gatus\current | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ```yml NSSM-Details 1743806328796 = 638794031287960000 = 2025-1.Spring = Fri Apr 04 2025 15:38:48 GMT-0700 (Mountain Standard Time) | ||||||
|  | Startup type: Automatic (Delay Start) | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ```yml NSSM-I/O 1743806328796 = 638794031287960000 = 2025-1.Spring = Fri Apr 04 2025 15:38:48 GMT-0700 (Mountain Standard Time) | ||||||
|  | Input (stdin): | ||||||
|  | Output (stdout): D:\web-sites\Gatus\current\logs\service.out.log | ||||||
|  | Error (stderr): D:\web-sites\Gatus\current\logs\service.error.log | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ```yml NSSM-Environment 1743806359765 = 638794031597650000 = 2025-1.Spring = Fri Apr 04 2025 15:39:19 GMT-0700 (Mountain Standard Time) | ||||||
|  | GATUS_CONFIG_PATH=./oi-metrology-viewer.yaml | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ```bash Administrator 1743806328796 = 638794031287960000 = 2025-1.Spring = Fri Apr 04 2025 15:38:48 GMT-0700 (Mountain Standard Time) | ||||||
|  | sc start gatus | ||||||
|  | sc query gatus | ||||||
|  | sc stop gatus | ||||||
|  | sc start gatus | ||||||
|  | # systemctl start gatus | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ```bash 1745023773786 = 638806205737860000 = 2025-1.Spring = Fri Apr 18 2025 17:49:33 GMT-0700 (Mountain Standard Time) | ||||||
|  | mklink /J "D:\web-sites\Gatus\.Gatus-to-MonA" "C:\Windows\System32\config\systemProfile\AppData\Local\IFXApps\Gatus-to-MonA" | ||||||
|  | mkdir "D:/Tmp/Gatus-to-MonA" | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Nginx | ||||||
|  |  | ||||||
|  | - Add new server to proxy pass to 8081 | ||||||
|  | - Test nginx | ||||||
|  | - Restart nginx | ||||||
|  |  | ||||||
|  | ## MonA | ||||||
|  |  | ||||||
|  | - Create generic resource type | ||||||
|  | - On overview page click edit then click update without making any changes | ||||||
|  | - Wait a hour | ||||||
|  | - On data page click Edit Resource Name then click update without making any changes | ||||||
|  | - Wait a day | ||||||
|  | - On overview page click use for main status (Heartbeat) | ||||||
|  | - Refresh config page and search for threshold | ||||||
|  | - Define threshold | ||||||
|  |  | ||||||
|  | ## Sdk="Microsoft.NET.Sdk.Worker" | ||||||
|  |  | ||||||
|  | - Build with AOT task | ||||||
|  | - Copy publish directory to server | ||||||
|  | - Copy / edit secrets file | ||||||
|  | - Verify windows event viewer entry for company name | ||||||
|  |  | ||||||
|  | ```bash 1743817269373 = 638794140693730000 = 2025-1.Spring = Fri Apr 04 2025 18:41:08 GMT-0700 (Mountain Standard Time) | ||||||
|  | sc.exe create "Gatus-to-MonA" binpath="C:\Windows\System32\config\systemprofile\AppData\Local\IFXApps\Gatus-to-MonA\Gatus-to-MonA.exe" | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## MonA Instances | ||||||
|  |  | ||||||
|  | - [MES_APC_GATUS](https://mona.auc.infineon.com/auc/systems/563556/dependencies?config=true) | ||||||
|  |     - [messa013ec.infineon.com](http://messa013ec.infineon.com:8082) | ||||||
|  | - [MES_EAF_GATUS](https://mona.auc.infineon.com/auc/systems/563493/dependencies?config=true) | ||||||
|  |     - [messa08ec.infineon.com](http://messa08ec.infineon.com:8082) | ||||||
|  | - [MES_EAF_STAGE_GATUS](https://mona.auc.infineon.com/auc/systems/563516/dependencies?config=true) | ||||||
|  |     - [mestsa07ec.infineon.com](http://mestsa07ec.infineon.com:8082) | ||||||
|  | - [MES_FAB_APPROVAL_SYSTEM_GATUS](https://mona.auc.infineon.com/auc/systems/563517/dependencies?config=true) | ||||||
|  |     - [messa016ec.infineon.com](http://messa016ec.infineon.com:8082) | ||||||
|  |         - https://messa016ec.infineon.com | ||||||
|  | - [MES_FAB_TIME_GATUS](https://mona.auc.infineon.com/auc/systems/563518/dependencies?config=true) | ||||||
|  |     - [messa004.infineon.com](http://messa004.infineon.com:8082) | ||||||
|  | - [MES_INFINITY_QS_SI_GATUS](https://mona.auc.infineon.com/auc/systems/563519/dependencies?config=true) | ||||||
|  |     - [messa04ec.infineon.com](http://messa04ec.infineon.com:8082) | ||||||
|  | - [MES_OPEN_INSIGHT_GATUS](https://mona.auc.infineon.com/auc/systems/563520/dependencies?config=true) | ||||||
|  |     - GATUS_CONFIG_PATH=./oi.yaml | ||||||
|  |     - [messa01ec.infineon.com](http://messa01ec.infineon.com:8082) | ||||||
|  |         - http://messa014.infineon.com/api/heartbeat | ||||||
|  |         - http://messa014.infineon.com/API/RemoteHealthCheck/Mona/MonaEngines/DB-EN1 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN10 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN11 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN12 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN2 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN3 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN4 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN5 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN6 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN7 | ||||||
|  |         - http://messa014.infineon.com/api/RemoteHealthCheck/Mona/MonaEngines/DB-EN9 | ||||||
|  | - [MES_OPEN_INSIGHT_DEV_GATUS](https://mona.auc.infineon.com/auc/systems/563521/dependencies?config=true) | ||||||
|  |     - [mestsa01ec.infineon.com](http://mestsa01ec.infineon.com:8082) | ||||||
|  | - [MES_OI_METROLOGY_VIEWER_GATUS](https://mona.auc.infineon.com/auc/systems/557090/dependencies?config=true) | ||||||
|  |     - [messa010ec.infineon.com](http://messa010ec.infineon.com:8082) | ||||||
|  | - [MES_OI_WEB_SERVICES_GATUS](https://mona.auc.infineon.com/auc/systems/563522/dependencies?config=true) | ||||||
|  |     - [messa020ec.infineon.com](http://messa020ec.infineon.com:8082) | ||||||
|  |     - ~~messa014.infineon.com~~ | ||||||
|  |         - https://messa014.infineon.com/scan | ||||||
|  |         - https://messa014.infineon.com:50184 | ||||||
|  |         - https://messa014.infineon.com:5022 | ||||||
|  | - [LEO_EAF_GATUS](https://mona.auc.infineon.com/auc/systems/563522/dependencies?config=true) | ||||||
|  |     - [leosaec17.infineon.com](http://leosaec17.infineon.com:8082) | ||||||
|  |  | ||||||
|  | ## Prometheus config to consume Gatus metrics | ||||||
|  |  | ||||||
|  | - [prometheus](https://github.com/TwiN/gatus/blob/master/.examples/docker-compose-grafana-prometheus/README.md) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## Outline | ||||||
|  |  | ||||||
|  | ### Goal | ||||||
|  |  | ||||||
|  | - Monitor TLS Cert | ||||||
|  |  | ||||||
|  | ### Options | ||||||
|  |  | ||||||
|  | - Uptime Kuma | ||||||
|  |     - Configuration is GUI driven | ||||||
|  | - Prometheus | ||||||
|  |     - Not as easy to get started | ||||||
|  | - Grafana | ||||||
|  |     - Too many features | ||||||
|  |     - Open source but still have to login to use | ||||||
|  |  | ||||||
|  | ### Benefits | ||||||
|  |  | ||||||
|  | - [x] Open Source | ||||||
|  | - [x] Written in GoLang | ||||||
|  | - [x] Doesn't need WAN connectivity | ||||||
|  | - [x] Keeps history with simple graph | ||||||
|  | - [x] Metrics output built for Prometheus | ||||||
|  | - [x] Sends e-mail alerts and has other alerting | ||||||
|  | - [x] Check status more often than five minute intervals | ||||||
|  | - [x] Single Config file that can be put in source control | ||||||
|  | - [x] Can wait for pushed data as well as default pull data | ||||||
|  | - [x] Simple GUI (website) that can be accessed outside server | ||||||
|  | - [x] Badge api that can be embedded in website (see oi server?) | ||||||
|  | - [x] Easy deployment [one binary, one config, runs via Non-Sucking Service Manager (nssm) and outputs sqlite files] | ||||||
|  |  | ||||||
|  | ### Drawbacks | ||||||
|  |  | ||||||
|  | - [x] Another item to manage | ||||||
|  | - [x] Not part of the target solution | ||||||
|  | - [x] Haven't figured out how to push to MonIn directly with both heartbeat and performance | ||||||
							
								
								
									
										11
									
								
								Worker.cs
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								Worker.cs
									
									
									
									
									
								
							| @ -8,7 +8,6 @@ namespace Gatus.To.MonA; | |||||||
|  |  | ||||||
| public partial class Worker : BackgroundService { | public partial class Worker : BackgroundService { | ||||||
|  |  | ||||||
|     private bool? _First; |  | ||||||
|     private readonly bool _IsWindowsService; |     private readonly bool _IsWindowsService; | ||||||
|     private readonly ILogger<Worker> _Logger; |     private readonly ILogger<Worker> _Logger; | ||||||
|     private readonly AppSettings _AppSettings; |     private readonly AppSettings _AppSettings; | ||||||
| @ -20,7 +19,6 @@ public partial class Worker : BackgroundService { | |||||||
|         _HttpClientFactory = httpClientFactory; |         _HttpClientFactory = httpClientFactory; | ||||||
|         logger.LogInformation(string.Join(Environment.NewLine, collection)); |         logger.LogInformation(string.Join(Environment.NewLine, collection)); | ||||||
|         try { logger.LogInformation("<{folder}>", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); } catch (Exception) { } |         try { logger.LogInformation("<{folder}>", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); } catch (Exception) { } | ||||||
|         _First = null; |  | ||||||
|         _IsWindowsService = collection.Contains(nameof(WindowsServiceLifetime)); |         _IsWindowsService = collection.Contains(nameof(WindowsServiceLifetime)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -42,23 +40,20 @@ public partial class Worker : BackgroundService { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         while (_IsWindowsService && !cancellationToken.IsCancellationRequested) { |         while (_IsWindowsService && !cancellationToken.IsCancellationRequested) { | ||||||
|  |             try { | ||||||
|                 BodyInner(cancellationToken); |                 BodyInner(cancellationToken); | ||||||
|                 await Task.Delay(_AppSettings.GatusToMonaConfiguration.MillisecondsDelay, cancellationToken); |                 await Task.Delay(_AppSettings.GatusToMonaConfiguration.MillisecondsDelay, cancellationToken); | ||||||
|  |             } catch (Exception ex) { _Logger.LogError(ex, "Unexpected Error!"); } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void BodyInner(CancellationToken cancellationToken) { |     private void BodyInner(CancellationToken cancellationToken) { | ||||||
|         _Logger.LogInformation("A) Next execute will be at {date}", DateTime.Now.AddMilliseconds(_AppSettings.GatusToMonaConfiguration.MillisecondsDelay).ToString("yyyy-MM-dd hh:mm:ss.fff tt")); |         _Logger.LogInformation("A) Next execute will be at {date}", DateTime.Now.AddMilliseconds(_AppSettings.GatusToMonaConfiguration.MillisecondsDelay).ToString("yyyy-MM-dd hh:mm:ss.fff tt")); | ||||||
|         if (_First is null || _First.Value) { |  | ||||||
|             _First = false; |  | ||||||
|             if (_AppSettings.GatusToMonaConfiguration.Helper == nameof(Helpers.HelperGatusToMona)) |  | ||||||
|                 Helpers.HelperGatusToMona.Heartbeat(_AppSettings, _HttpClientFactory, _Logger, Infineon.Monitoring.MonA.State.Up, cancellationToken); |  | ||||||
|         } |  | ||||||
|         if (!Directory.Exists(_AppSettings.GatusToMonaConfiguration.Directory)) |         if (!Directory.Exists(_AppSettings.GatusToMonaConfiguration.Directory)) | ||||||
|             _ = Directory.CreateDirectory(_AppSettings.GatusToMonaConfiguration.Directory); |             _ = Directory.CreateDirectory(_AppSettings.GatusToMonaConfiguration.Directory); | ||||||
|         else { |         else { | ||||||
|             _ = _AppSettings.GatusToMonaConfiguration.Helper switch { |             _ = _AppSettings.GatusToMonaConfiguration.Helper switch { | ||||||
|                 nameof(Helpers.HelperGatusToMona) => Helpers.HelperGatusToMona.UpdateCount(_AppSettings, _Logger, cancellationToken), |                 nameof(Helpers.HelperGatusToMona) => Helpers.HelperGatusToMona.UpdateCount(_AppSettings, _HttpClientFactory, _Logger, cancellationToken), | ||||||
|                 _ => throw new NotSupportedException() |                 _ => throw new NotSupportedException() | ||||||
|             }; |             }; | ||||||
|         } |         } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user