Click here to Skip to main content
15,664,619 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am trying to get CPU usage of a remote server in the same network. I don't know what configuration needs. I have used PerformanceCounter. If I check with my pc, its giving CPU usage. But when I check with a remote server, it's saying Access deny.

What I have tried:

private PerformanceCounter cpuCounter = null;
cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total", machineName);
                //ramCounter = new PerformanceCounter("Memory", "Available MBytes", String.Empty, machineName);
                ramCounter = new PerformanceCounter("Memory", "% Committed Bytes In Use", String.Empty, machineName);
                pageCounter = new PerformanceCounter("Paging File", "% Usage", "_Total", machineName);
                // there can be multiple network interfaces
                nicCounters = GetNICCounters();
                // for each nic card, create a corresponding status bar label
                for (int i = 0; i < nicCounters.Length; i++)
                { ssStatusBar.Items.Add(GetNICLabel(nicCounters[i], i)); }
F-ES Sitecore 5-Dec-18 4:46am    
The account your code is running under probably doesn't have the required access. I assume it probably needs admin access on the remote machine. By default your .net code is running under a very restricted account, you'd need to change it to an account with the right access, which would be a massive security risk in itself. An alternative would be to run that code on a different process such as a webservice or similar that is configured to have the right access and your web code then calls that service to get the data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900