Link to home
Start Free TrialLog in
Avatar of CJCraft
CJCraft

asked on

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

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>
Avatar of Michel Sakr
Michel Sakr
Flag of Canada image

you'll need to assign a doman admin for that
or assign a user with same credentials as a local admin on the remote machine
ASKER CERTIFIED SOLUTION
Avatar of ASPGuru
ASPGuru

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CJCraft
CJCraft

ASKER

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
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