IIS经常出现假死的情况,具体什么时候会出现假死,我就不说了,今天我要写的是如何监控IIS的状态。
程序的功能是:如果IIS是为运行的状态,就重启IIS,如果IIS的连接数达到了设置的连接数,也重启IIS。我写了一个window服务,时刻监控着IIS的运行状态。
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Management;
using System.Diagnostics;
using System.ServiceProcess;
using System.Configuration;
namespace IISWatcher
{
public partial class IISWatcher : ServiceBase
{
public IISWatcher()
{
InitializeComponent();
}
System.Timers.Timer tmr;
protected override void OnStart(string[] args)
{
tmr = new System.Timers.Timer();
tmr.Interval = 6000;
tmr.Elapsed += new System.Timers.ElapsedEventHandler(tmr_Elapsed);