Example #1
0
        /// <summary>
        /// The get metrics.
        /// </summary>
        /// <returns>
        /// The get metrics result.
        /// </returns>
        private static MachineInfo GetMetrics()
        {
            MachineInfo info = new MachineInfo();
            info.CpuTime = (double)cpuCounter.NextValue();
            info.MemoryUsage = (ulong)memUsageCounter.NextValue();

            info.FreeDiskSpace = (ulong)freeDiskSpaceCounter.NextValue();
            info.FreeDiskSpacePercentage = (ulong)freespacepercentage.NextValue();

            ulong totalMemory = 0;

            // Get total memory from WMI
            ObjectQuery memQuery = new ObjectQuery("SELECT * FROM CIM_OperatingSystem");

            ManagementObjectSearcher searcher = new ManagementObjectSearcher(memQuery);

            foreach (ManagementObject item in searcher.Get())
            {
                totalMemory = (ulong)item["TotalVisibleMemorySize"];
            }

            info.TotalMemory = totalMemory;
            return info;
        }
Example #2
0
 public void SendCpuInfo(MachineInfo machineInfo)
 {
     //this.Clients.cpuInfoMessage(name, machineName, processor, memUsage, totalMemory);
     this.Clients[machineInfo.MachineName].cpuInfoMessage(machineInfo);
 }
 public void SendCpuReport(MachineInfo machineInfo)
 {
     var context = SignalR.GlobalHost.ConnectionManager.GetHubContext<CpuInfo>();
     context.Clients.cpuInfoMessage(machineInfo);
 }