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

Move generation of config and status summaries into their respective classes.

parent 51a4f062
No related branches found
Tags 1.2
No related merge requests found
......@@ -190,68 +190,31 @@ namespace AutoTx
/// Write a summary of loaded config + status to the log.
/// </summary>
private void StartupSummary() {
writeLogDebug("------ RoboSharp ------");
var msg = "\n\n------ RoboSharp ------\n";
var roboDll = System.Reflection.Assembly.GetAssembly(typeof(RoboCommand)).Location;
if (roboDll != null) {
var versionInfo = FileVersionInfo.GetVersionInfo(roboDll);
writeLogDebug(" > DLL file: " + roboDll);
writeLogDebug(" > DLL description: " + versionInfo.Comments);
writeLogDebug(" > DLL version: " + versionInfo.FileVersion);
}
writeLogDebug("");
writeLogDebug("------ Loaded status flags ------");
writeLogDebug("CurrentTransferSrc: " + _status.CurrentTransferSrc);
writeLogDebug("CurrentTargetTmp: " + _status.CurrentTargetTmp);
writeLogDebug("TransferInProgress: " + _status.TransferInProgress);
writeLogDebug("LastStorageNotification: " +
_status.LastStorageNotification.ToString("yyyy-MM-dd HH:mm:ss"));
writeLogDebug("LastAdminNotification: " +
_status.LastAdminNotification.ToString("yyyy-MM-dd HH:mm:ss"));
writeLogDebug("");
writeLogDebug("------ Loaded configuration settings ------");
writeLogDebug("HostAlias: " + _config.HostAlias);
writeLogDebug("SourceDrive: " + _config.SourceDrive);
writeLogDebug("IncomingDirectory: " + _config.IncomingDirectory);
writeLogDebug("MarkerFile: " + _config.MarkerFile);
writeLogDebug("ManagedDirectory: " + _config.ManagedDirectory);
writeLogDebug("GracePeriod: " + _config.GracePeriod);
writeLogDebug("DestinationDirectory: " + _config.DestinationDirectory);
writeLogDebug("TmpTransferDir: " + _config.TmpTransferDir);
writeLogDebug("EnforceInheritedACLs: " + _config.EnforceInheritedACLs);
writeLogDebug("ServiceTimer: " + _config.ServiceTimer);
writeLogDebug("InterPacketGap: " + _config.InterPacketGap);
writeLogDebug("MaxCpuUsage: " + _config.MaxCpuUsage);
writeLogDebug("MinAvailableMemory: " + _config.MinAvailableMemory);
foreach (var processName in _config.BlacklistedProcesses) {
writeLogDebug("BlacklistedProcess: " + processName);
msg += " > DLL file: " + roboDll + "\n" +
" > DLL description: " + versionInfo.Comments + "\n" +
" > DLL version: " + versionInfo.FileVersion + "\n";
}
foreach (var driveToCheck in _config.SpaceMonitoring) {
writeLogDebug("Drive to check free space: " + driveToCheck.DriveName +
" (threshold: " + driveToCheck.SpaceThreshold + ")");
}
writeLogDebug("StorageNotificationDelta: " + _config.StorageNotificationDelta);
writeLogDebug("AdminNotificationDelta: " + _config.AdminNotificationDelta);
if (string.IsNullOrEmpty(_config.SmtpHost)) {
writeLogDebug("SmtpHost: ====== Not configured, disabling notification emails! ======");
} else {
writeLogDebug("SmtpHost: " + _config.SmtpHost);
writeLogDebug("EmailFrom: " + _config.EmailFrom);
writeLogDebug("AdminEmailAdress: " + _config.AdminEmailAdress);
writeLogDebug("AdminDebugEmailAdress: " + _config.AdminDebugEmailAdress);
}
writeLogDebug("");
writeLogDebug(msg);
// finally some current information:
writeLogDebug("------ Current system parameters ------");
writeLogDebug("Hostname: " + Environment.MachineName);
writeLogDebug("Free system memory: " + GetFreeMemory() + " MB");
msg = "\n\n------ Loaded status flags ------\n" + _status.Summary() +
"\n------ Loaded configuration settings ------\n" + _config.Summary();
writeLogDebug(msg);
msg = "\n\n------ Current system parameters ------\n" +
"Hostname: " + Environment.MachineName + "\n" +
"Free system memory: " + GetFreeMemory() + " MB" + "\n";
foreach (var driveToCheck in _config.SpaceMonitoring) {
writeLogDebug("Free space on drive '" + driveToCheck.DriveName + "': " +
GetFreeDriveSpace(driveToCheck.DriveName));
msg += "Free space on drive '" + driveToCheck.DriveName + "': " +
GetFreeDriveSpace(driveToCheck.DriveName) + "\n";
}
writeLogDebug("");
writeLogDebug(msg);
writeLogDebug("------ Grace location status ------");
try {
......
......@@ -181,5 +181,41 @@ namespace AutoTx.XmlWrapper
c.ValidationWarnings += " - <DestinationDirectory> is not a UNC path!\n";
}
public string Summary() {
var msg =
"HostAlias: " + HostAlias + "\n" +
"SourceDrive: " + SourceDrive + "\n" +
"IncomingDirectory: " + IncomingDirectory + "\n" +
"MarkerFile: " + MarkerFile + "\n" +
"ManagedDirectory: " + ManagedDirectory + "\n" +
"GracePeriod: " + GracePeriod + "\n" +
"DestinationDirectory: " + DestinationDirectory + "\n" +
"TmpTransferDir: " + TmpTransferDir + "\n" +
"EnforceInheritedACLs: " + EnforceInheritedACLs + "\n" +
"ServiceTimer: " + ServiceTimer + "\n" +
"InterPacketGap: " + InterPacketGap + "\n" +
"MaxCpuUsage: " + MaxCpuUsage + "\n" +
"MinAvailableMemory: " + MinAvailableMemory + "\n";
foreach (var processName in BlacklistedProcesses) {
msg += "BlacklistedProcess: " + processName + "\n";
}
foreach (var driveToCheck in SpaceMonitoring) {
msg += "Drive to check free space: " + driveToCheck.DriveName +
" (threshold: " + driveToCheck.SpaceThreshold + ")" + "\n";
}
if (string.IsNullOrEmpty(SmtpHost)) {
msg += "SmtpHost: ====== Not configured, disabling email! ======" + "\n";
} else {
msg +=
"SmtpHost: " + SmtpHost + "\n" +
"EmailFrom: " + EmailFrom + "\n" +
"AdminEmailAdress: " + AdminEmailAdress + "\n" +
"AdminDebugEmailAdress: " + AdminDebugEmailAdress + "\n" +
"StorageNotificationDelta: " + StorageNotificationDelta + "\n" +
"AdminNotificationDelta: " + AdminNotificationDelta + "\n";
}
return msg;
}
}
}
\ No newline at end of file
......@@ -197,5 +197,19 @@ namespace AutoTx.XmlWrapper
}
}
public string Summary() {
return
"CurrentTransferSrc: " + CurrentTransferSrc + "\n" +
"CurrentTargetTmp: " + CurrentTargetTmp + "\n" +
"TransferInProgress: " + TransferInProgress + "\n" +
"CurrentTransferSize: " + CurrentTransferSize + "\n" +
"LastStatusUpdate: " +
LastStatusUpdate.ToString("yyyy-MM-dd HH:mm:ss") + "\n" +
"LastStorageNotification: " +
LastStorageNotification.ToString("yyyy-MM-dd HH:mm:ss") + "\n" +
"LastAdminNotification: " +
LastAdminNotification.ToString("yyyy-MM-dd HH:mm:ss") + "\n";
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment