Skip to content
Snippets Groups Projects
Commit 810c5188 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Add SystemChecks.HealthReport() and use it in AutoTx.StartupSummary()

Refers to #20
parent db61f557
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment