diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs index 46080422680b94b25ee38d7a9d3b66ddba88c09e..c069730e149b437e602974f92b65004f913b4169 100644 --- a/AutoTx/AutoTx.cs +++ b/AutoTx/AutoTx.cs @@ -931,9 +931,10 @@ namespace AutoTx /// <summary> /// Generate a report on expired folders in the grace location. /// - /// Check all user-directories in the grace location for subdirectories whose - /// name-timestamp exceeds the configured grace period and generate a summary - /// containing the age and size of those directories. + /// Check all user-directories in the grace location for subdirectories whose timestamp + /// (the directory name) exceeds the configured grace period and generate a summary + /// 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> /// <param name="threshold">The number of days used as expiration threshold.</param> public string GraceLocationSummary(int threshold) { @@ -949,6 +950,13 @@ namespace AutoTx if (string.IsNullOrEmpty(report)) return ""; 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; } diff --git a/AutoTx/Resources/configuration-example.xml b/AutoTx/Resources/configuration-example.xml index 8917becb23b611ea39070ac8f3379720fe8dddb6..ec6bc1400363489de81452289fb7ef0cfee55619 100644 --- a/AutoTx/Resources/configuration-example.xml +++ b/AutoTx/Resources/configuration-example.xml @@ -87,6 +87,10 @@ messages to, e.g. on completed transfers. Can be empty. --> <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>0</InterPacketGap> diff --git a/AutoTx/XmlWrapper/ServiceConfig.cs b/AutoTx/XmlWrapper/ServiceConfig.cs index dd70309fcdf9f4cccbbf9869e1e590c55f5a93c8..0006b1f6ade03b6424be71a8dc59d52d379e364d 100644 --- a/AutoTx/XmlWrapper/ServiceConfig.cs +++ b/AutoTx/XmlWrapper/ServiceConfig.cs @@ -24,6 +24,7 @@ namespace AutoTx.XmlWrapper EmailPrefix = ""; AdminEmailAdress = ""; AdminDebugEmailAdress = ""; + GraceNotificationDelta = 720; InterPacketGap = 0; @@ -116,6 +117,8 @@ namespace AutoTx.XmlWrapper public string AdminEmailAdress { get; set; } public string AdminDebugEmailAdress { get; set; } + public int GraceNotificationDelta { get; set; } + public int InterPacketGap { get; set; } /// <summary> @@ -212,8 +215,8 @@ namespace AutoTx.XmlWrapper "AdminEmailAdress: " + AdminEmailAdress + "\n" + "AdminDebugEmailAdress: " + AdminDebugEmailAdress + "\n" + "StorageNotificationDelta: " + StorageNotificationDelta + "\n" + - "AdminNotificationDelta: " + AdminNotificationDelta + "\n"; - + "AdminNotificationDelta: " + AdminNotificationDelta + "\n" + + "GraceNotificationDelta: " + GraceNotificationDelta + "\n"; } return msg; } diff --git a/AutoTx/XmlWrapper/ServiceStatus.cs b/AutoTx/XmlWrapper/ServiceStatus.cs index 25f4ed826441dde7647da25629f8375983abd2de..50c25439d958acfc7d32b8d5796eed0e62fb8ce7 100644 --- a/AutoTx/XmlWrapper/ServiceStatus.cs +++ b/AutoTx/XmlWrapper/ServiceStatus.cs @@ -14,6 +14,7 @@ namespace AutoTx.XmlWrapper private DateTime _lastStatusUpdate; private DateTime _lastStorageNotification; private DateTime _lastAdminNotification; + private DateTime _lastGraceNotification; private string _limitReason; string _currentTransferSrc; @@ -49,6 +50,15 @@ namespace AutoTx.XmlWrapper } } + [XmlElement("LastGraceNotification", DataType = "dateTime")] + public DateTime LastGraceNotification { + get { return _lastGraceNotification; } + set { + _lastGraceNotification = value; + Serialize(); + } + } + public string LimitReason { get { return _limitReason; } set { @@ -209,7 +219,9 @@ namespace AutoTx.XmlWrapper "LastStorageNotification: " + LastStorageNotification.ToString("yyyy-MM-dd HH:mm:ss") + "\n" + "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"; } } }