开发者

Monitoring a custom windows service

I've built a windows service application using Visual Studio .NET and C#. This service will be deployed on a few hundred machines and I'm looking for a solid wa开发者_运维技巧y to monitor the application. By monitor, I mean, I just want to check to make sure that it's running, and check the status of a few settings on each client.

Is there a common method of doing this?


The easiest thing to do is have each application "call home". Create a single central application, preferably a web app, and have the remote applications make a small call to the central app on whatever interval you feel is necessary. They can include the extra information you want to monitor.

Keep a list of where the application is deployed and if you don't get a call from any on the list within the expected timeframe, then you know it's offline.

If you can't change the actual application that you're monitoring, then write a small companion application that can run as a scheduled tasks and perform the same local checks and call back to the central application.

We do this with thousands of client machines worldwide and it works well.


You could write a little monitor utility program that checks the service state via the SCM and provides a simple HTTP interface so you can poll the status. This would basically be just a big loop with some reporting if the service state changes.

while (true)
{
    string serviceName = "NameOfYourService";
    ServiceController Svc = new ServiceController(serviceName);
    if (Svc.Status != ServiceControllerStatus.Running)
    {
        //Do reporting/set status here
    }
    Thread.Sleep(5000);
}


You could take advantage of a monitoring tool like Zabbix, for example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜