Beispiel #1
0
        public Dictionary <string, string> GetSystemInformation()
        {
            using var sshClient = SshManager.CreateSshClient(System);
            using var dbContext = DbContextFactory.CreateDbContext();
            var hasNotFinishedScheduledActions = dbContext.ScheduledActions.SystemHasNotFinishedUpdate(System);

            var packagesActions = ActionsProvider.GetPackagesActions(sshClient, hasNotFinishedScheduledActions).ToList();

            var vulnerablePackages = Audit.GetVulnerablePackages(sshClient);
            var systemUpdateInfo   = SystemUpdate.GetUpdateInfo(sshClient);

            System.PackageActions           = packagesActions.Count;
            System.HasSystemUpdateAvailable = systemUpdateInfo.HasUpdate;
            System.UpdatesFetchedAt         = DateTime.Now;

            if (!string.IsNullOrEmpty(vulnerablePackages?.Trim()))
            {
                System.AddProblem("Found vulnerable packages!!!");
            }

            var result = new Dictionary <string, string>
            {
                { "Hostname", new Hostname().GetHostname(sshClient) },
                { "Logged users", Uptime.CurrentLoggedUsers(sshClient) },
                {
                    "Kernel\nUserland\nRunning",
                    $"{SystemVersion.GetKernel(sshClient)}{SystemVersion.GetUserland(sshClient)}{SystemVersion.GetRunning(sshClient)}"
                },
                { "Vulnerable packages", vulnerablePackages },
                { $"Packages actions ({System.PackageActions})", string.Join("\n", packagesActions) },
            };

            if (System.HasSystemUpdateAvailable)
            {
                result.Add("Has system update", System.HasSystemUpdateAvailable.ToString());
            }

            return(result);
        }