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

Send an email on expired folders in the grace location.

An email will be sent only if the time since the last one exceeds the
new configuration option "GraceNotificationDelta", defaulting to 12
hours.

Fixes #1
parent 9497b5fa
Branches
Tags
No related merge requests found
...@@ -931,9 +931,10 @@ namespace AutoTx ...@@ -931,9 +931,10 @@ namespace AutoTx
/// <summary> /// <summary>
/// Generate a report on expired folders in the grace location. /// Generate a report on expired folders in the grace location.
/// ///
/// Check all user-directories in the grace location for subdirectories whose /// Check all user-directories in the grace location for subdirectories whose timestamp
/// name-timestamp exceeds the configured grace period and generate a summary /// (the directory name) exceeds the configured grace period and generate a summary
/// containing the age and size of those directories. /// containing the age and size of those directories. The summary will be sent to the admin
/// if the configured GraceNotificationDelta has passed since the last email.
/// </summary> /// </summary>
/// <param name="threshold">The number of days used as expiration threshold.</param> /// <param name="threshold">The number of days used as expiration threshold.</param>
public string GraceLocationSummary(int threshold) { public string GraceLocationSummary(int threshold) {
...@@ -949,6 +950,13 @@ namespace AutoTx ...@@ -949,6 +950,13 @@ namespace AutoTx
if (string.IsNullOrEmpty(report)) if (string.IsNullOrEmpty(report))
return ""; return "";
report = "Expired folders in grace location:\n" + report; report = "Expired folders in grace location:\n" + report;
var delta = (int)(DateTime.Now - _status.LastGraceNotification).TotalMinutes;
report += "\nTime since last grace notification: " + delta + "\n";
if (delta >= _config.GraceNotificationDelta) {
SendAdminEmail(report, "Grace location cleanup required.");
_status.LastGraceNotification = DateTime.Now;
report += "\nNotification sent to AdminEmailAdress.\n";
}
return report; return report;
} }
......
...@@ -87,6 +87,10 @@ ...@@ -87,6 +87,10 @@
messages to, e.g. on completed transfers. Can be empty. --> messages to, e.g. on completed transfers. Can be empty. -->
<AdminDebugEmailAdress>admin@mydomain.xy</AdminDebugEmailAdress> <AdminDebugEmailAdress>admin@mydomain.xy</AdminDebugEmailAdress>
<!-- GraceNotificationDelta: minimum time (in minutes) between two emails
about expired folders in the grace location (default: 720 (12h)) -->
<GraceNotificationDelta>720</GraceNotificationDelta>
<!-- InterPacketGap: RoboCopy parameter to limit the bandwidth --> <!-- InterPacketGap: RoboCopy parameter to limit the bandwidth -->
<InterPacketGap>0</InterPacketGap> <InterPacketGap>0</InterPacketGap>
......
...@@ -24,6 +24,7 @@ namespace AutoTx.XmlWrapper ...@@ -24,6 +24,7 @@ namespace AutoTx.XmlWrapper
EmailPrefix = ""; EmailPrefix = "";
AdminEmailAdress = ""; AdminEmailAdress = "";
AdminDebugEmailAdress = ""; AdminDebugEmailAdress = "";
GraceNotificationDelta = 720;
InterPacketGap = 0; InterPacketGap = 0;
...@@ -116,6 +117,8 @@ namespace AutoTx.XmlWrapper ...@@ -116,6 +117,8 @@ namespace AutoTx.XmlWrapper
public string AdminEmailAdress { get; set; } public string AdminEmailAdress { get; set; }
public string AdminDebugEmailAdress { get; set; } public string AdminDebugEmailAdress { get; set; }
public int GraceNotificationDelta { get; set; }
public int InterPacketGap { get; set; } public int InterPacketGap { get; set; }
/// <summary> /// <summary>
...@@ -212,8 +215,8 @@ namespace AutoTx.XmlWrapper ...@@ -212,8 +215,8 @@ namespace AutoTx.XmlWrapper
"AdminEmailAdress: " + AdminEmailAdress + "\n" + "AdminEmailAdress: " + AdminEmailAdress + "\n" +
"AdminDebugEmailAdress: " + AdminDebugEmailAdress + "\n" + "AdminDebugEmailAdress: " + AdminDebugEmailAdress + "\n" +
"StorageNotificationDelta: " + StorageNotificationDelta + "\n" + "StorageNotificationDelta: " + StorageNotificationDelta + "\n" +
"AdminNotificationDelta: " + AdminNotificationDelta + "\n"; "AdminNotificationDelta: " + AdminNotificationDelta + "\n" +
"GraceNotificationDelta: " + GraceNotificationDelta + "\n";
} }
return msg; return msg;
} }
......
...@@ -14,6 +14,7 @@ namespace AutoTx.XmlWrapper ...@@ -14,6 +14,7 @@ namespace AutoTx.XmlWrapper
private DateTime _lastStatusUpdate; private DateTime _lastStatusUpdate;
private DateTime _lastStorageNotification; private DateTime _lastStorageNotification;
private DateTime _lastAdminNotification; private DateTime _lastAdminNotification;
private DateTime _lastGraceNotification;
private string _limitReason; private string _limitReason;
string _currentTransferSrc; string _currentTransferSrc;
...@@ -49,6 +50,15 @@ namespace AutoTx.XmlWrapper ...@@ -49,6 +50,15 @@ namespace AutoTx.XmlWrapper
} }
} }
[XmlElement("LastGraceNotification", DataType = "dateTime")]
public DateTime LastGraceNotification {
get { return _lastGraceNotification; }
set {
_lastGraceNotification = value;
Serialize();
}
}
public string LimitReason { public string LimitReason {
get { return _limitReason; } get { return _limitReason; }
set { set {
...@@ -209,7 +219,9 @@ namespace AutoTx.XmlWrapper ...@@ -209,7 +219,9 @@ namespace AutoTx.XmlWrapper
"LastStorageNotification: " + "LastStorageNotification: " +
LastStorageNotification.ToString("yyyy-MM-dd HH:mm:ss") + "\n" + LastStorageNotification.ToString("yyyy-MM-dd HH:mm:ss") + "\n" +
"LastAdminNotification: " + "LastAdminNotification: " +
LastAdminNotification.ToString("yyyy-MM-dd HH:mm:ss") + "\n"; LastAdminNotification.ToString("yyyy-MM-dd HH:mm:ss") + "\n" +
"LastGraceNotification: " +
LastGraceNotification.ToString("yyyy-MM-dd HH:mm:ss") + "\n";
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment