jayrod
asked on
retrieving System Up time
My code for some reason isn't working :P
PerformanceCounter pc = new PerformanceCounter();
pc.CategoryName = "System";
pc.CounterName = "System Up Time";
this.Label1.Text = pc.NextValue().ToString();
Object get's created just fine.. but it's saying that it can't find that category name... is there something else special I have to do with the performance counter to get it to work in this instance? also what permissions would I need to do this on a remote machine?
PerformanceCounter pc = new PerformanceCounter();
pc.CategoryName = "System";
pc.CounterName = "System Up Time";
this.Label1.Text = pc.NextValue().ToString();
Object get's created just fine.. but it's saying that it can't find that category name... is there something else special I have to do with the performance counter to get it to work in this instance? also what permissions would I need to do this on a remote machine?
ASKER
Nope still doesn't work...
private void Page_Load(object sender, System.EventArgs e)
{
PerformanceCounter pc = new PerformanceCounter("System ","System Up Time");
this.Label1.Text = pc.NextValue().ToString();
}
private void Page_Load(object sender, System.EventArgs e)
{
PerformanceCounter pc = new PerformanceCounter("System
this.Label1.Text = pc.NextValue().ToString();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
possible difference between using a webpage and using a console app? Actually now that I think about it I guess that might just be the problem as all requests from IIS are routed through the aspnet user.
hmm... wonder what I'd have to do to get this working thorugh a web page.
hmm... wonder what I'd have to do to get this working thorugh a web page.
ASKER
well.. I just did it using a console app... and it appears that I still get this exception
{"Category does not exist." }
When I go to admin tools on this machine and go to performance I can't seem to add any counters there... could I maybe have a different problem?
{"Category does not exist." }
When I go to admin tools on this machine and go to performance I can't seem to add any counters there... could I maybe have a different problem?
what are the specifics of the environment ?
You can write values only to counters that reside on the local computer. However, you can read counter values from any computer in the enterprise for which you have access privileges.
When you set the MachineName property to point to a remote computer, the PerformanceCounter instance attempts to open the counter on that computer. If the counter does not exist, setting this property throws an exception.
I would assume you would need permissions as your account to do it on the local machine which I believe is admin ... the windows guys would prob know more details ...
I beleive the overloaded constructor also defaults the InstanceName to PC.InstanceName="Explorer"