Beispiel #1
0
        /// <summary>
        /// Write a summary of loaded config + status to the log.
        /// </summary>
        private void StartupSummary()
        {
            var msg = "Startup Summary:\n\n";

            var thisAssembly    = Assembly.GetExecutingAssembly();
            var thisVersionInfo = FileVersionInfo.GetVersionInfo(thisAssembly.Location);

            msg += "------ Assembly Information ------\n" +
                   $" > version: {thisAssembly.GetName().Version}\n" +
                   $" > file version: {thisVersionInfo.FileVersion}\n" +
                   $" > description: {thisVersionInfo.Comments}\n" +
                   $" > version information: {thisVersionInfo.ProductVersion}\n";

            var roboAssembly    = Assembly.GetAssembly(typeof(RoboCommand));
            var roboVersionInfo = FileVersionInfo.GetVersionInfo(roboAssembly.Location);

            msg += "\n------ RoboSharp ------\n" +
                   $" > location: [{roboAssembly.Location}]\n" +
                   $" > version: {roboAssembly.GetName().Version}\n" +
                   $" > file version: {roboVersionInfo.FileVersion}\n" +
                   $" > description: {roboVersionInfo.Comments}\n" +
                   $" > version information: {roboVersionInfo.ProductVersion}\n";

            _versionSummary = $"AutoTx {Properties.Resources.BuildCommit.Trim()} " +
                              $"{Properties.Resources.BuildDate.Trim()} | " +
                              $"RoboSharp {roboAssembly.GetName().Version} " +
                              $"{roboVersionInfo.ProductVersion}";


            msg += "\n------ Loaded status flags ------\n" + _status.Summary() +
                   "\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";
            }


            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);
            }

            Log.Debug(msg);

            // finally check if the validation gave warnings and send them to the admin:
            var warnings = ServiceConfig.ValidatorWarnings;

            if (string.IsNullOrWhiteSpace(warnings))
            {
                return;
            }
            SendAdminEmail(warnings);
        }
Beispiel #2
0
        /// <summary>
        /// Generate a human-readable sumary of the current configuration.
        /// </summary>
        /// <returns>A string with details on the configuration.</returns>
        public string Summary()
        {
            var msg =
                "############### REQUIRED PARAMETERS ###############\n" +
                $"HostAlias: {HostAlias}\n" +
                $"SourceDrive: {SourceDrive}\n" +
                $"IncomingDirectory: {IncomingDirectory}\n" +
                $"ManagedDirectory: {ManagedDirectory}\n" +
                $"DestinationAlias: {DestinationAlias}\n" +
                $"DestinationDirectory: {DestinationDirectory}\n" +
                $"TmpTransferDir: {TmpTransferDir}\n" +
                $"MaxCpuUsage: {MaxCpuUsage}%\n" +
                $"MaxDiskQueue: {MaxDiskQueue} / 1000 (effectively {MaxDiskQueue/1000})\n" +
                $"MinAvailableMemory: {MinAvailableMemory} MB\n" +
                "\n" +
                "############### OPTIONAL PARAMETERS ###############\n" +
                $"LogLevel: {LogLevel}\n" +
                $"LogLevelMonitoring: {LogLevelMonitoring}\n" +
                $"ServiceTimer: {ServiceTimer} ms\n" +
                $"MarkerFile: {MarkerFile}\n" +
                $"GracePeriod: {GracePeriod} days (" +
                TimeUtils.DaysToHuman(GracePeriod, false) + ")\n" +
                $"EnforceInheritedACLs: {EnforceInheritedACLs}\n" +
                $"InterPacketGap: {InterPacketGap}\n" +
                "";

            var blacklist = "";

            foreach (var processName in BlacklistedProcesses)
            {
                blacklist += $"    ProcessName: {processName}\n";
            }
            if (!string.IsNullOrWhiteSpace(blacklist))
            {
                msg += $"BlacklistedProcesses:\n{blacklist}";
            }


            var space = "";

            foreach (var drive in SpaceMonitoring)
            {
                space += $"    DriveName: {drive.DriveName} " +
                         $"(threshold: {Conv.GigabytesToString(drive.SpaceThreshold)})\n";
            }
            if (!string.IsNullOrWhiteSpace(space))
            {
                msg += $"SpaceMonitoring:\n{space}";
            }

            if (string.IsNullOrWhiteSpace(SmtpHost))
            {
                msg += "SmtpHost: ====== Not configured, disabling email! ======" + "\n";
            }
            else
            {
                msg +=
                    $"SmtpHost: {SmtpHost}\n" +
                    $"SmtpPort: {SmtpPort}\n" +
                    $"SmtpUserCredential: {SmtpUserCredential}\n" +
                    $"SmtpPasswortCredential: --- not showing ---\n" +
                    $"EmailFrom: {EmailFrom}\n" +
                    $"EmailPrefix: {EmailPrefix}\n" +
                    $"AdminEmailAdress: {AdminEmailAdress}\n" +
                    $"AdminDebugEmailAdress: {AdminDebugEmailAdress}\n" +
                    $"SendTransferNotification: {SendTransferNotification}\n" +
                    $"SendAdminNotification: {SendAdminNotification}\n" +
                    $"AdminNotificationDelta: {AdminNotificationDelta} min (" +
                    TimeUtils.MinutesToHuman(AdminNotificationDelta, false) + ")\n" +
                    $"GraceNotificationDelta: {GraceNotificationDelta} min (" +
                    TimeUtils.MinutesToHuman(GraceNotificationDelta, false) + ")\n" +
                    $"StorageNotificationDelta: {StorageNotificationDelta} min (" +
                    TimeUtils.MinutesToHuman(StorageNotificationDelta, false) + ")\n" +
                    "";
            }
            return(msg);
        }