コード例 #1
0
        /// <summary>
        /// Ottiene un Master valorizzato coi valori ottenuti direttamente dal sistema operativo
        /// Potrebbe non corrispondere al Master salvato
        /// Viene utilizzato per ottenere le differenze tra i parametri salvati e quelli effettivamente applicati
        /// </summary>
        /// <returns></returns>
        public static MachineStatus GetRunning()
        {
            //var STOPWATCH = new System.Diagnostics.Stopwatch();
            //STOPWATCH.Start();
            var master = new MachineStatus();

            master.Info.Uptime    = Uptime.Get();
            master.Info.CpuInfo   = CpuInfo.Get();
            master.Info.MemInfo   = MemInfo.Get();
            master.Info.Free      = Free.Get();
            master.Info.Losetup   = Losetup.Get();
            master.Info.DiskUsage = DiskUsage.Get();
            master.Info.Versions  = Versioning.Get();

            master.Host     = Hostnamectl.Get();
            master.TimeDate = new TimeDate()
            {
                Timezone = Timedatectl.Get().Timezone
            };
            master.Boot = new Boot();
            var modules     = Mod.Get();
            var bootModules = new SystemModule[modules.Length];

            for (var i = 0; i < modules.Length; i++)
            {
                bootModules[i] = new SystemModule()
                {
                    Module = modules[i].Module, Active = true
                };
            }
            master.Boot.Modules           = bootModules;
            master.Boot.Services          = cmds.Systemctl.GetAll();
            master.Boot.Parameters        = Sysctl.Get();
            master.Users.SystemUsers      = Passwd.Get();
            master.Users.ApplicativeUsers = new ApplicativeUser[] { new ApplicativeUser()
                                                                    {
                                                                        Active = true, Type = AuthenticationType.simple, Id = "master", Claims = new[] { SHA.Generate("master") }
                                                                    } };

            master.Network.KnownDns          = Dns.GetResolv();
            master.Network.KnownHosts        = Dns.GetHosts();
            master.Network.KnownNetworks     = Dns.GetNetworks();
            master.Network.Bridges           = Brctl.Get();
            master.Network.Bonds             = Bond.Get();
            master.Network.NetworkInterfaces = cmds.Network.Get();
            master.Network.RoutingTables     = Route.GetRoutingTable();
            master.Network.Routing           = Route.Get();

            master.NsSwitch = NS.Switch.Get();

            master.Storage.Mounts       = Mount.Get();
            master.Storage.Zpools       = Zpool.GetPools();
            master.Storage.ZfsDatasets  = Zfs.GetDatasets();
            master.Storage.ZfsSnapshots = Zfs.GetSnapshots();

            master.Services.Ssh.PublicKey     = Ssh.GetRootPublicKey();
            master.Services.Ssh.PrivateKey    = Ssh.GetRootPrivateKey();
            master.Services.Ssh.AuthorizedKey = Ssh.GetAuthorizedKey();

            master.Services.Virsh.Domains = Virsh.GetDomains();

            //ConsoleLogger.Log($"[conf] loaded running conf ({STOPWATCH.ElapsedMilliseconds})");
            return(master);
        }