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

Send a system health report on service startup

Refers to #20
parent 331dcad8
Branches
No related tags found
No related merge requests found
...@@ -396,10 +396,9 @@ namespace ATxService ...@@ -396,10 +396,9 @@ namespace ATxService
var health = SystemChecks.HealthReport(_storage); var health = SystemChecks.HealthReport(_storage);
SendHealthReport(health);
msg += "\n" + health; msg += "\n" + health;
// TODO: send health report!
Log.Debug(msg); Log.Debug(msg);
// finally check if the validation gave warnings and send them to the admin: // finally check if the validation gave warnings and send them to the admin:
......
...@@ -233,5 +233,24 @@ namespace ATxService ...@@ -233,5 +233,24 @@ namespace ATxService
_status.LastGraceNotification = DateTime.Now; _status.LastGraceNotification = DateTime.Now;
return SendAdminEmail(report, "grace location summary"); return SendAdminEmail(report, "grace location summary");
} }
/// <summary>
/// Send a system health report if enough time has elapsed since the previous one.
/// </summary>
/// <param name="report">The health report.</param>
/// <returns>True in case the report was sent, false otherwise.</returns>
private bool SendHealthReport(string report) {
var elapsedHuman = TimeUtils.HumanSince(_status.LastStartupNotification);
if (TimeUtils.MinutesSince(_status.LastStartupNotification) < _config.StartupNotificationDelta) {
Log.Trace("Not sending system health report now, last one has been sent {0}",
elapsedHuman);
return false;
}
report += $"\nPrevious system health report notification was sent {elapsedHuman}.\n";
_status.LastStartupNotification = DateTime.Now;
return SendAdminEmail(report, "system health report");
}
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment