Esempio n. 1
0
        public override ResponseBase ExecuteRequest()
        {
            var pf = new PerfmonDataResponse();

            pf.CPUuse  = Int32.Parse(WmiQuery.GetWMIdata("Win32_PerfFormattedData_PerfOS_Processor", "PercentProcessorTime", "Name", "_Total"));
            pf.RAMfree = Int32.Parse(WmiQuery.GetWMIdata("Win32_PerfFormattedData_PerfOS_Memory", "AvailableMBytes"));
            string[] properties = new string[] { "FreeMegabytes", "AvgDiskQueueLength" };
            var      values     = WmiQuery.GetWMIdata("Win32_PerfFormattedData_PerfDisk_LogicalDisk", properties, "Name", "C:");

            pf.DiskFree  = Int32.Parse(values["FreeMegabytes"]);
            pf.DiskQueue = Int32.Parse(values["AvgDiskQueueLength"]);

            #region Workaround for showing the graph in UI
            if (!realDiskFreeValue.HasValue)
            {
                pf.DiskFree      -= 1;
                realDiskFreeValue = pf.DiskFree;
            }
            if (!realDiskQueueValue.HasValue)
            {
                pf.DiskQueue      += 1;
                realDiskQueueValue = pf.DiskQueue;
            }
            #endregion

            return(pf);
        }
        public override ResponseBase ExecuteRequest()
        {
            var id = new IdentificationDataResponse
            {
                DeviceName   = Environment.MachineName,
                SerialNumber = WmiQuery.GetWMIdata("Win32_BaseBoard", "SerialNumber")
            };

            return(id);
        }
Esempio n. 3
0
        public override ResponseBase ExecuteRequest()
        {
            OsInfoResponse os = new OsInfoResponse();

            //retrieve all data in one call because WMI call usually takes some time...
            string[] properties = new string[] { "Caption", "Version", "OSArchitecture", "TotalVisibleMemorySize", "FreePhysicalMemory", "SystemDrive" };
            Dictionary <string, string> values = WmiQuery.GetWMIdata("Win32_OperatingSystem", properties);

            os.OsName    = values["Caption"];
            os.OsVersion = values["Version"];
            if (values.ContainsKey("OSArchitecture"))
            {
                os.OsArchitecture = values["OSArchitecture"];
            }
            else
            {
                os.OsArchitecture = "32 bit";                                                                                                             //old 32-bit systems has no OSArchitecture property
            }
            os.RamSize         = Int32.Parse(values["TotalVisibleMemorySize"]) / 1024;                                                                    //in Mb
            os.SystemDrive     = values["SystemDrive"];
            os.SystemDriveSize = (int)(Double.Parse(WmiQuery.GetWMIdata("Win32_LogicalDisk", "Size", "Caption", os.SystemDrive)) / (1024 * 1024 * 1024)); //Gb

            return(os);
        }