diff --git a/ATxCommon/SystemChecks.cs b/ATxCommon/SystemChecks.cs index 6cbcd665657e7963ef38ff8b193bd702895a3d02..bddd1ae331c73f2f705c86e606bd1c08d7540f3e 100644 --- a/ATxCommon/SystemChecks.cs +++ b/ATxCommon/SystemChecks.cs @@ -151,6 +151,24 @@ namespace ATxCommon } } + /// <summary> + /// Generate an overall system health report with free space, grace location status, etc. + /// </summary> + /// <param name="storage">StorageStatus object used for space and grace reports.</param> + /// <returns>A multi-line string containing the details assembled in the report. These + /// comprise system uptime, free RAM, free storage space and current grace location status. + /// </returns> + public static string HealthReport(StorageStatus storage) { + var report = "------ System health report ------\n\n" + + $" - hostname: {Environment.MachineName}\n" + + $" - uptime: {TimeUtils.SecondsToHuman(Uptime(), false)}\n" + + $" - free system memory: {GetFreeMemory()} MB" + "\n\n"; + + report += storage.Summary(); + + return report; + } + /// <summary> /// Get the current system uptime in seconds. Note that this will miss all times where the /// system had been suspended / hibernated, as it is based on the OS's ticks counter. diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index 334f25ecb1042fb385cc50f01598828ea07904a5..0b1537c7d3dd3632e6dbef7c7953e09295c795cf 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -395,28 +395,10 @@ namespace ATxService "\n------ Loaded configuration settings ------\n" + _config.Summary(); - msg += "\n------ Current system parameters ------\n" + - "Hostname: " + Environment.MachineName + "\n" + - "Free system memory: " + SystemChecks.GetFreeMemory() + " MB" + "\n"; - foreach (var driveToCheck in _config.SpaceMonitoring) { - msg += "Free space on drive '" + driveToCheck.DriveName + "': " + - Conv.BytesToString(SystemChecks.GetFreeDriveSpace(driveToCheck.DriveName)) + "\n"; - } - + var health = SystemChecks.HealthReport(_storage); + msg += "\n" + health; - msg += "\n------ Grace location status, threshold: " + _config.GracePeriod + " days " + - "(" + TimeUtils.DaysToHuman(_config.GracePeriod) + ") ------\n"; - try { - var tmp = SendGraceLocationSummary(_config.GracePeriod); - if (string.IsNullOrEmpty(tmp)) { - msg += " -- NO EXPIRED folders in grace location! --\n"; - } else { - msg += tmp; - } - } - catch (Exception ex) { - Log.Error("GraceLocationSummary() failed: {0}", ex.Message); - } + // TODO: send health report! Log.Debug(msg);