Skip to content

Commit

Permalink
Version 5.3.11 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
RudolfHenning committed Jul 16, 2022
1 parent c2d32e9 commit 14ab887
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 46 deletions.
2 changes: 1 addition & 1 deletion QuickMon5/Installer/Product.wxs
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<Product Id="*" Name="QuickMon 5" Language="1033" Version="5.3.11.0082" Manufacturer="Hen IT" UpgradeCode="59162023-5478-4668-A279-41c950000000">
<Product Id="*" Name="QuickMon 5" Language="1033" Version="5.3.11.0083" Manufacturer="Hen IT" UpgradeCode="59162023-5478-4668-A279-41c950000000">
<Package Id='*' Keywords='Installer' Description="QuickMon 5 Installer" Comments='QuickMon 5 is a simple monitoring and alerting tool'
Manufacturer='Hen IT' InstallerVersion='200' Languages='1033' Compressed='yes' SummaryCodepage='1252' />

Expand Down
2 changes: 1 addition & 1 deletion QuickMon5/Installer/Productx64.wxs
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<Product Id="*" Name="QuickMon 5" Language="1033" Version="5.3.11.0082" Manufacturer="Hen IT" UpgradeCode="59162023-5478-4668-A279-41c950000000">
<Product Id="*" Name="QuickMon 5" Language="1033" Version="5.3.11.0083" Manufacturer="Hen IT" UpgradeCode="59162023-5478-4668-A279-41c950000000">
<Package Id='*' Keywords='Installer' Description="QuickMon 5 Installer" Comments='QuickMon 5 is a simple monitoring and alerting tool'
Manufacturer='Hen IT' InstallerVersion='200' Languages='1033' Compressed='yes' SummaryCodepage='1252' Platform="x64" />

Expand Down
6 changes: 4 additions & 2 deletions QuickMon5/QuickMon5/Forms/CollectorDetails.cs
Expand Up @@ -1050,7 +1050,8 @@ private void UpdateRawView()
rtfBuilder.FontStyle(FontStyle.Bold).Append("Time: ").FontStyle(FontStyle.Regular).AppendLine(c.CurrentState.Timestamp.ToString("yyyy-MM-dd HH:mm:ss"));
rtfBuilder.FontStyle(FontStyle.Bold).Append("State: ").FontStyle(FontStyle.Regular).AppendLine(c.CurrentState.State.ToString());
rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("Value(s): ").FontStyle(FontStyle.Regular).AppendLine(c.CurrentState.ReadAgentValues());
if (c.CurrentState.State != CollectorState.Good && c.CurrentState.RawDetails != null && c.CurrentState.RawDetails.Length > 0)
if (c.CurrentState.RawDetails != null && c.CurrentState.RawDetails.Length > 0)
//if (c.CurrentState.State != CollectorState.Good && c.CurrentState.RawDetails != null && c.CurrentState.RawDetails.Length > 0)
{
rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("Raw details: ").FontStyle(FontStyle.Regular).AppendLine(c.CurrentState.RawDetails);
}
Expand Down Expand Up @@ -1114,7 +1115,8 @@ private void WriteMonitorState(RTFBuilder rtfBuilder, MonitorState ms)
rtfBuilder.FontStyle(FontStyle.Bold).Append("Executed on: ").FontStyle(FontStyle.Regular).AppendLine(FormatUtils.N(ms.ExecutedOnHostComputer));
rtfBuilder.FontStyle(FontStyle.Bold).Append("Ran as: ").FontStyle(FontStyle.Regular).AppendLine(FormatUtils.N(ms.RanAs));
rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("Value(s): ").FontStyle(FontStyle.Regular).AppendLine(ms.ReadAgentValues());
if (ms.State != CollectorState.Good && ms.RawDetails != null && ms.RawDetails.Length > 0)
if (ms.RawDetails != null && ms.RawDetails.Length > 0)
//if (ms.State != CollectorState.Good && ms.RawDetails != null && ms.RawDetails.Length > 0)
{
rtfBuilder.FontStyle(FontStyle.Bold).AppendLine("Raw details: ").FontStyle(FontStyle.Regular).AppendLine(ms.RawDetails);
}
Expand Down
2 changes: 1 addition & 1 deletion QuickMon5/QuickMon5/app.manifest
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="5.3.11.0082" name="QuickMon.app"/>
<assemblyIdentity version="5.3.11.0083" name="QuickMon.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
Expand Down
53 changes: 43 additions & 10 deletions QuickMon5/QuickMon5Core/Agents/Collectors/Ping/PingCollector.cs
Expand Up @@ -106,6 +106,7 @@ public void FromXml(string configurationString)
hostEntry.TelnetPassword = host.ReadXmlElementAttr("password");
hostEntry.IgnoreInvalidHTTPSCerts = host.ReadXmlElementAttr("ignoreInvalidHTTPSCerts", false);
hostEntry.HttpsSecurityProtocol = host.ReadXmlElementAttr("httpsSecurityProtocol");
hostEntry.AllowHTTP3xx = host.ReadXmlElementAttr("allowHTTP3xx", false);
hostEntry.SocketPingMsgBody = host.ReadXmlElementAttr("socketPingMsgBody", "QuickMon Ping Test");
hostEntry.PrimaryUIValue = host.ReadXmlElementAttr("primaryUIValue", false);

Expand Down Expand Up @@ -138,6 +139,7 @@ public string ToXml()
hostXmlNode.SetAttributeValue("password", hostEntry.TelnetPassword);
hostXmlNode.SetAttributeValue("ignoreInvalidHTTPSCerts", hostEntry.IgnoreInvalidHTTPSCerts);
hostXmlNode.SetAttributeValue("httpsSecurityProtocol", hostEntry.HttpsSecurityProtocol);
hostXmlNode.SetAttributeValue("allowHTTP3xx", hostEntry.AllowHTTP3xx);
hostXmlNode.SetAttributeValue("socketPingMsgBody", hostEntry.SocketPingMsgBody);
hostXmlNode.SetAttributeValue("primaryUIValue", hostEntry.PrimaryUIValue);

Expand Down Expand Up @@ -273,11 +275,24 @@ public MonitorState GetCurrentState()
CurrentValue = pingResult.PingTime,
CurrentValueUnit = "ms"
};
if (pingResult.PingTime > -1)

if (!pingResult.Success)
{
currentState.CurrentValue = pingResult.ResponseDetails;
currentState.State = CollectorState.Error;
currentState.RawDetails = pingResult.ResponseDetails;
if (pingResult.ResponseContent != null && pingResult.ResponseContent.Length > 0)
{
currentState.RawDetails += $"\r\n{pingResult.ResponseContent}";
}
currentState.CurrentValueUnit = "";
}
else if (pingResult.PingTime > -1)
{
if (pingResult.PingTime >= TimeOutMS)
{
currentState.CurrentValue += " (Time out)";
currentState.CurrentValueUnit = "";
currentState.State = CollectorState.Error;
currentState.RawDetails = string.Format("Operation timed out! Max time allowed: {0}ms, {1}", TimeOutMS, pingResult.ResponseDetails);
}
Expand All @@ -290,11 +305,20 @@ public MonitorState GetCurrentState()
{
currentState.State = CollectorState.Warning;
currentState.RawDetails = string.Format("The returned HTML does not contain the specified string '{0}'", HTMLContentContain);
if (pingResult.ResponseContent != null && pingResult.ResponseContent.Length > 0)
{
currentState.RawDetails += $"\r\n{pingResult.ResponseContent}";
}
}
else
{
currentState.State = CollectorState.Good;
currentState.RawDetails = pingResult.ResponseDetails;
if (pingResult.ResponseContent != null && pingResult.ResponseContent.Length > 0)
{
if (currentState.RawDetails.Length > 0) currentState.RawDetails += "\r\n";
currentState.RawDetails += $"{pingResult.ResponseContent}";
}
}
}
else
Expand Down Expand Up @@ -337,8 +361,7 @@ public MonitorState GetCurrentState()
private int maxTimeMS = 1000;
public int MaxTimeMS { get { return maxTimeMS; } set { maxTimeMS = value; } }
private int timeOutMS = 5000;
public int TimeOutMS { get { return timeOutMS; } set { timeOutMS = value; } }
public bool IgnoreInvalidHTTPSCerts { get; set; }
public int TimeOutMS { get { return timeOutMS; } set { timeOutMS = value; } }
#endregion

#region HTTP ping
Expand All @@ -349,6 +372,8 @@ public MonitorState GetCurrentState()
public string HttpProxyPassword { get; set; }
public string HTMLContentContain { get; set; }
public string HttpsSecurityProtocol { get; set; }
public bool IgnoreInvalidHTTPSCerts { get; set; }
public bool AllowHTTP3xx { get; set; }
#endregion

#region Socket ping
Expand Down Expand Up @@ -447,6 +472,7 @@ private PingCollectorResult PingICMP()
private PingCollectorResult PingHTTP()
{
int httpCode = 200;
string httpCodeStr = "OK";
PingCollectorResult result = new PingCollectorResult();
string lastStep = "[Create WebClientEx]";
result.Success = false;
Expand Down Expand Up @@ -517,15 +543,17 @@ private PingCollectorResult PingHTTP()
}
else
wc.UseDefaultCredentials = true;
wc.AllowRedirect = AllowHTTP3xx;

sw.Start();
sw.Start();
lastStep = "[OpenRead]";
using (System.IO.Stream webRequest = wc.OpenRead(Address))
{
lastStep = "[CheckHTTPStatus]";
if (wc.LastWebResponse != null)
{
httpCode = (int)(((System.Net.HttpWebResponse)wc.LastWebResponse).StatusCode);
httpCodeStr = (((System.Net.HttpWebResponse)wc.LastWebResponse).StatusCode).ToString();
Trace.WriteLine($"HTTP Status Code: {httpCode}");
}

Expand All @@ -548,9 +576,8 @@ private PingCollectorResult PingHTTP()
}
}
if (chars > 1)
{
result.ResponseContent = docContents.ToString();
result.ResponseDetails = $"HTTP status code: {httpCode}, Characters returned: " + chars.ToString();
{
result.ResponseContent = $"Response length: {chars}\r\n{docContents}";
foreach (var rh in wc.ResponseHeaders)
{
Trace.WriteLine(rh.ToString());
Expand All @@ -575,17 +602,23 @@ private PingCollectorResult PingHTTP()
result.Success = false;
}
}
else if (httpCode < 400)
else if (httpCode < 400 && !AllowHTTP3xx)
{
result.PingTime = (int)sw.ElapsedMilliseconds;
result.PingTime = -1; // (int)sw.ElapsedMilliseconds;
result.Success = false;
result.ResponseDetails = $"HTTP code: {httpCode}";
}
else if (httpCode < 400)
{
result.PingTime = (int)sw.ElapsedMilliseconds;
result.Success = true;
//result.ResponseDetails = $"HTTP code: {httpCode}";
}
else
{
result.Success = false;
result.PingTime = -1;
result.ResponseDetails = $"HTTP error: {httpCode}";
result.ResponseDetails = $"HTTP code: {httpCode}";
}

}
Expand Down
Expand Up @@ -36,6 +36,7 @@ public bool KeepAlive
get { return keepAlive; }
set { keepAlive = value; }
}
public bool AllowRedirect { get; set; } = true;
public WebResponse LastWebResponse { get; private set; }


Expand All @@ -56,6 +57,7 @@ protected override WebRequest GetWebRequest(Uri address)
((HttpWebRequest)request).UserAgent = userAgent;
((HttpWebRequest)request).Timeout = timeout;
((HttpWebRequest)request).KeepAlive = keepAlive;
((HttpWebRequest)request).AllowAutoRedirect = AllowRedirect;
}

return request;
Expand Down
3 changes: 2 additions & 1 deletion QuickMon5/QuickMon5Core/Resources/ChangeLog.txt
Expand Up @@ -245,4 +245,5 @@ Debugging build - QuickMonService is creating temp dll's that is never cleared.
--------------
Version 5.3.11 (2022-07-15)
**************
Changing HTTP Ping Collector to show HTTP Status code error codes.
Changing HTTP Ping Collector to show HTTP Status code error codes.
Additional changes to Ping Collector to display more details in UI
4 changes: 2 additions & 2 deletions QuickMon5/QuickMon5Core/VersionInfo.cs
Expand Up @@ -15,5 +15,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("5.3.11.0082")]
[assembly: AssemblyFileVersion("5.3.11.0082")]
[assembly: AssemblyVersion("5.3.11.0083")]
[assembly: AssemblyFileVersion("5.3.11.0083")]

0 comments on commit 14ab887

Please sign in to comment.