From 18e851c9c2cfebbcf4f5472a44bbde572b605549 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 26 Jul 2018 20:09:05 +0000 Subject: [PATCH] --- Controllers/OpsController.cs | 134 ++++++++++++++++++++++++++++++----- Startup.cs | 17 +++-- util/OpsDiagnostics.cs | 37 ++++++++++ 3 files changed, 165 insertions(+), 23 deletions(-) create mode 100644 util/OpsDiagnostics.cs diff --git a/Controllers/OpsController.cs b/Controllers/OpsController.cs index d49c35d..1d0ed04 100644 --- a/Controllers/OpsController.cs +++ b/Controllers/OpsController.cs @@ -29,43 +29,139 @@ namespace rockfishCore.Controllers [HttpGet("status")] public dtoOpsStatus GetOpsStatus() { - dtoOpsStatus ret= new dtoOpsStatus(); - ret.MailMirrorOK=RfMail.MailIsMirroringProperly(); + dtoOpsStatus Ret = new dtoOpsStatus(); + + try + { + Ret.MailMirrorOK = RfMail.MailIsMirroringProperly(); + } + catch (Exception ex) + { + Ret.OpsCheckMessage += $"Mail mirror: {ex.Message}\r\n"; + } + + try + { + Ret.AyaNovaWebsiteOK = OpsDiagnostics.CheckWebsite("https://www.ayanova.com/", "Ground Zero Tech-Works Inc."); + } + catch (Exception ex) + { + Ret.OpsCheckMessage += $"AyaNova website: {ex.Message}\r\n"; + } + + try + { + Ret.APIWebsiteOK = OpsDiagnostics.CheckWebsite("https://api.ayanova.com/", "WorkorderTypes Enumeration"); + } + catch (Exception ex) + { + Ret.OpsCheckMessage += $"API website: {ex.Message}\r\n"; + } + + try + { + Ret.ContactFormOK = OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/contact", "Contact.Email"); + } + catch (Exception ex) + { + Ret.OpsCheckMessage += $"Contact form website: {ex.Message}\r\n"; + } + + try + { + Ret.RequestFormOK = OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/request", "Contact.Email"); + } + catch (Exception ex) + { + Ret.OpsCheckMessage += $"Request website: {ex.Message}\r\n"; + } + + try + { + Ret.RequestLiteFormOK = OpsDiagnostics.CheckWebsite("https://contact.ayanova.com/requestlite", "Contact.Email"); + } + catch (Exception ex) + { + Ret.OpsCheckMessage += $"RequestLite website: {ex.Message}\r\n"; + } + + try + { + Ret.SubversionOK = OpsDiagnostics.CheckWebsite("http://svn.helloayanova.com:3343/csvn/login/auth", "Subversion Edge"); + } + catch (Exception ex) + { + Ret.OpsCheckMessage += $"Subversion server: {ex.Message}\r\n"; + } + + try + { + Ret.ForumOK = OpsDiagnostics.CheckWebsite("http://forum.ayanova.com/", "AyaNova support resources"); + } + catch (Exception ex) + { + Ret.OpsCheckMessage += $"Forum: {ex.Message}\r\n"; + } + + try + { + Ret.DevOpsOK = OpsDiagnostics.CheckWebsite("https://test.helloayanova.com/api/v8/", "AyaNova server"); + } + catch (Exception ex) + { + Ret.OpsCheckMessage += $"DevOps: {ex.Message}\r\n"; + } + + //PING? - //Can ping Spaces and all the servers we have, maybe do that first then proceed - //https://docs.microsoft.com/en-us/dotnet/framework/network-programming/how-to-ping-a-host - //using System.Net.NetworkInformation; + //Can ping Spaces and all the servers we have, maybe do that first then proceed + //https://docs.microsoft.com/en-us/dotnet/framework/network-programming/how-to-ping-a-host + //using System.Net.NetworkInformation; //AyaNova website: https://www.ayanova.com/ //API website: https://api.ayanova.com/ //Contact form: https://contact.ayanova.com/contact //Request form: https://contact.ayanova.com/request - //Request lite form: https://contact.ayanova.com/requestlite - //subversion: https://svn.helloayanova.com:18080/svn/GZTWREPO/ (requires login) + //Request lite form: https://contact.ayanova.com/requestlite //subversion admin: http://svn.helloayanova.com:3343/csvn/login/auth //Forum: http://forum.ayanova.com/ //devops: https://test.helloayanova.com/api/v8/ //Spaces and backup: https://gztw1.nyc3.digitaloceanspaces.com/ - //Need S3 library for c# + //Need S3 library for c# - return ret; + return Ret; } public class dtoOpsStatus { - public bool MailMirrorOK; - public bool ForumOK; - public bool AyaNovaWebsiteOK; - public bool APIWebsiteOK; - public bool ContactFormOK; - public bool RequestFormOK; - public bool RequestLiteFormOK; - public bool SubversionOK; - public bool DevOpsOK; - public bool BackupOK; + public bool MailMirrorOK; + public bool ForumOK; + public bool AyaNovaWebsiteOK; + public bool APIWebsiteOK; + public bool ContactFormOK; + public bool RequestFormOK; + public bool RequestLiteFormOK; + public bool SubversionOK; + public bool DevOpsOK; + public bool BackupOK; + public string OpsCheckMessage; + public dtoOpsStatus() + { + MailMirrorOK = false; + ForumOK = false; + AyaNovaWebsiteOK = false; + APIWebsiteOK = false; + ContactFormOK = false; + RequestFormOK = false; + RequestLiteFormOK = false; + SubversionOK = false; + DevOpsOK = false; + BackupOK = false; + OpsCheckMessage = string.Empty; + } } diff --git a/Startup.cs b/Startup.cs index a5a86ea..47199ec 100644 --- a/Startup.cs +++ b/Startup.cs @@ -40,11 +40,12 @@ namespace rockfishCore { services.AddDbContext( - options => { - options.UseSqlite(Configuration.GetConnectionString("rfdb")); - options.EnableSensitiveDataLogging(false); + options => + { + options.UseSqlite(Configuration.GetConnectionString("rfdb")); + options.EnableSensitiveDataLogging(false); } - + ); //Added this so that can access configuration from anywhere else @@ -107,6 +108,14 @@ namespace rockfishCore RfSchema.CheckAndUpdate(dbContext); //bool bMM=RfMail.MailIsMirroringProperly(); + try + { + var test = OpsDiagnostics.CheckWebsite("https://test.helloayanova.com/api/v8/", "AyaNova server"); + } + catch (Exception ex) + { + string res = ex.Message; + } }//eof } diff --git a/util/OpsDiagnostics.cs b/util/OpsDiagnostics.cs new file mode 100644 index 0000000..84e8382 --- /dev/null +++ b/util/OpsDiagnostics.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; +using System.IO; +using System.Net.Http; +using System.Net.Http.Headers; + +namespace rockfishCore.Util +{ + public static class OpsDiagnostics + { + private static HttpClient Client = new HttpClient(); + + + public static bool CheckWebsite(string url, string mustContain) + { + bool Result = false; + var Response = Client.GetAsync(url).Result; + if (Response.IsSuccessStatusCode) + { + var PageText = Response.Content.ReadAsStringAsync().Result; + if(PageText.Contains(mustContain)) + { + Result=true; + } + } + return Result; + } + + + + + + }//eoc + +}//eons \ No newline at end of file