Purpose: Company Server IIS has more than 10 application address pools, always inadvertently stopped a, stop line system log will have a lot of warning log, and then stopped, analyzed several times, online some people say that is a certain site should check the site, but the site has so many addresses, Who knows from which request to start the application of the address pool to get hung up ah, the day is okay at any time someone looked at the server in the evening stopped on the trouble, all have the demand, automatic monitoring application address pool. In fact, the method is very simple, is timed to the application of the address pool traversal, check whether there is an open application address pool, and then execute the start command.
Copy Code code as follows:
<summary>
IIS application address Pool monitoring method
</summary>
private void Iisapppools ()
{
Try
{
String Entpath = "Iis://localhost/w3svc/apppools";
while (true)
{
DirectoryEntry rootentry = new DirectoryEntry (Entpath);
foreach (DirectoryEntry AppPool in Rootentry.children)
{
if (apppool.properties["AppPoolState"]. Value.tostring ()!= "2")
{
Loghelper.wirte ("Monitor to" + Apppool.name + "Apply address pool stop.");
Apppool.invoke ("Start", null);
Apppool.commitchanges ();
Loghelper.wirte (Apppool.name + "Apply address pool started successfully.");
}
Apppool.close ();
}
Thread.Sleep (600000);
}
}
catch (Exception ex)
{
Loghelper.wirte (ex. ToString ());
}
}
This one method is done, 10 minutes monitoring, no system resources.
But how do we get it? The collection of address pools in IIS is actually a special address, and any configuration in IIS is available
Recommend a visualization tool, IIS resource management tools, we can Baidu.