Previous Next

Thread: monitoring state of application pools

Last post 06-23-2008 5:23 PM by bduffin. 5 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (6 items)

Sort Posts:

  • 06-10-2008, 12:09 PM

    • bduffin
    • Top 200 Contributor
    • Joined on 06-05-2008, 5:20 PM
    • Posts 15
    • bduffin

    monitoring state of application pools

    We have an ASPX page which runs periodically to check the state of the IIS 6.0 application pool in which it is running.  I need to find a way, through the ASPX page, to get the state of the other application pools on the same machine.  I cannot access the code for this page at the moment, but I will later.  It appears there is a property called AppPoolState, but there is very little in the way of usable examples of it... System.Management is quite different from anything I have used before.  Everything I can find relates to JScript, which I will not be using (C# is preferable).  Does anyone have any ideas or examples?

  • 06-10-2008, 12:19 PM In reply to

    • bduffin
    • Top 200 Contributor
    • Joined on 06-05-2008, 5:20 PM
    • Posts 15
    • bduffin

    Re: monitoring state of application pools

    By the way, the server simply calls the existing ASPX page to see that the application pool is running... if it doesn't respond or gives an error, then we know something is wrong.  Rather than do this with every application pool, we want the original ASPX (and its associated C#) to use IIS features to check the other pools.  Just thought I'd clarify that... 

  • 06-11-2008, 10:56 AM In reply to

    • bduffin
    • Top 200 Contributor
    • Joined on 06-05-2008, 5:20 PM
    • Posts 15
    • bduffin

    Re: monitoring state of application pools

     To be even more specific, here's the code I've tried so far (based on code for a similar question on the forums):

                ConnectionOptions co = new ConnectionOptions();

                co.Impersonation = ImpersonationLevel.Impersonate;

                co.Authentication = AuthenticationLevel.PacketPrivacy;

                string objPath = "IISApplicationPool.Name='W3SVC/AppPools/" + "TestPool" + "'";

                ManagementScope scope = new ManagementScope(@"\\" + "localhost" + @"\root\MicrosoftIISV2", co);
                using (ManagementObject mo = new ManagementObject(objPath))
                {
                    mo.Scope = scope;
                    object poolState = mo.GetPropertyValue("AppPoolState");
                }

     

    This gives an error, saying "Invalid Namespace"... this error does not appear if I delete the 2 lines inside of "using".  There must be some flaws there, but none of the other attempts I've made have come this close.

  • 06-16-2008, 7:06 AM In reply to

    Re: monitoring state of application pools

    Hi,

    The error indicates the namespace is wrong or not available on the testing maching.

    You can follow this article to see if you can navigate to the namespace.

    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • 06-23-2008, 5:13 PM In reply to

    • bduffin
    • Top 200 Contributor
    • Joined on 06-05-2008, 5:20 PM
    • Posts 15
    • bduffin

    Re: monitoring state of application pools

    It turns out that I didn't have the proper permissions to access the application pool root (although I had the permissions to access the pools themselves).  Once I got those permissions, the errors went away.

  • 06-23-2008, 5:23 PM In reply to

    • bduffin
    • Top 200 Contributor
    • Joined on 06-05-2008, 5:20 PM
    • Posts 15
    • bduffin

    Re: monitoring state of application pools

    Note:  I made several other changes to the above code, which may have prevented other errors, beyond the namespace errors.  The above code may still be faulty even with full permissions.  If found it much easier to use DirectoryServices objects to get the states, rather than ManagementObject objects, so my current code has little to do with the code above.  However, the namespace errors didn't go away until I got full the required permissions.

Page 1 of 1 (6 items)
Page view counter