Solved

More problems accessing performance monitor information on remote machine from ASP.NET using C#

Posted on 2002-04-14
5
342 Views
Last Modified: 2007-12-19
Okay well I have gotten the code at the bottom to work but only for the Web server it is installed on, which is also the domain controller. I haven't been able to get it to give any information on any other machine.

When I try I get the following:

Exception Details: System.ComponentModel.Win32Exception: Access is denied

I had to set up permission for the ASPNET user to be able to read the perflib registry key. But it only seems to work for the local machine and not any domain machine.

Can someone please help me solve this issue.

Thanks everyone,
Chris Craft


<!--#include virtual="/library/functionlibrary.aspx"-->
<%@ Import Namespace = System.Diagnostics %>

<script runat="server">

  void Page_Load( Object Src, EventArgs E )
  {
    PerformanceCounter perfFreeMem = new PerformanceCounter( "Memory", "Available MBytes", "", "Arena3" );
    lblFreeMem.Text = perfFreeMem.NextValue().ToString();
  }

</script>

<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            Application Restarts:  
            <asp:Label id="lblAppRestarts" runat="server"></asp:Label>
        </p>
        <p>
            Free Memory (in MB):
            <asp:Label id="lblFreeMem" runat="server"></asp:Label>
        </p>
    </form>
</body>
</html>
0
Comment
Question by:CJCraft
  • 2
  • 2
5 Comments
 
LVL 20

Expert Comment

by:Silvers5
ID: 6940439
you'll need to assign a doman admin for that
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 6940445
or assign a user with same credentials as a local admin on the remote machine
0
 
LVL 11

Accepted Solution

by:
ASPGuru earned 200 total points
ID: 6940534
Have a look at this Classes/enumerations:

System.Diagnostics.PerformanceCounterPermission
System.Diagnostics.PerformanceCounterPermissionAccess
System.Diagnostics.PerformanceCounterPermissionAttribute
System.Diagnostics.PerformanceCounterPermissionEntry
System.Diagnostics.PerformanceCounterPermissionEntryCollection

ASPGuru
0
 
LVL 7

Author Comment

by:CJCraft
ID: 6940907
Isn't there some way I could give my ASPNET domain user access rights to the registry key perflib on the other machines? I think that is what is stopping it.

I got it to work fine on the Web / Domain server itself.

I'll look in to those enumerations too, thanks.

Chris
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 6941158
i don't know if it works by setting rights on registry keys...

try it with the domain administrator account first, maybe that works, then if you know that it works, you can try it with another account or removing rights as long as it still works...

ASPGuru
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question