« Back
in #servicewatch #networkservices #csharp read.

Windows Service Control App with Performance Indicator.

After writing so many Windows services, I needed a way to keep track of the services' status in case something mission critical went down or it just simply needed to be turned off and on again.

Often, they would be scattered over a few machines on the intranet and I did not want to remote into each machine to check their status -- or issue a lengthy command in the console to do what I needed. I wanted to look at one location to get that overview and perform some quick actions.

Service Status and Control

Thus ServiceWatch was born. It's a very simple and sleek SPA using AngularJs and John Papa's hot towel nuget package for a quick start. Here is a quick screenshot of just some services on my local machine which happens to be named AUNBDEV01

Windows service controls

Of course it's not limited to one machine but to any machine on the network that you have access to. The application web.config contains the credentials used for impersonation.

You can click on the controls in the last column to issue the appropriate command.

Quick Performance Indicators

I added a quick overview of the CPU usage on machines of interest and the remaining RAM and page file usage on the app Dashboard. Pushing the Start Polling button will update the statistics at an interval.

Here's what it would look like on a smaller device like a mobile phone:
Responsive mobile view of computer performance

Here's what it looks like on a Desktop:
Desktop view of computer performance

Putting In Your Services

        function getNetworkMachines() {
            var networkedMachines = [
                { MachineName: "AUNBDEV01" },
                { MachineName: "AUNBDEV01" },
                { MachineName: "AUNBDEV01" },
                { MachineName: "AUNBDEV01" },
                { MachineName: "AUNBDEV01" }
            ];

            return $q.when(networkedMachines);
        }

        function getServices() {
            var services = [
                { ServiceName: encodeURIComponent("COM+ Event System"), MachineName: "AUNBDEV01" },
                { ServiceName: encodeURIComponent("Credential Manager"), MachineName: "AUNBDEV01" },
                { ServiceName: encodeURIComponent("SQL Server (SQLEXPRESS)"), MachineName: "AUNBDEV01" }
            ];

            return $q.when(services);
        }

I decided to put the machine names and service names into the app\services\datacontext.js file. So if this app was already deployed, I can edit the js file without re-deploying the whole thing. The service names match those found in Computer Management -> Services

Get ServiceWatch

ServiceWatch is open source and you can download it here: https://bitbucket.org/serinth/servicewatch

Future Improvements

There is definite room for improvement and add-ons such as pretty visualizations and statistics. Or even better error handling. I've put in some logging using Nlog which will output to the application directory/logs.

For now, this suits my needs and I hope it helps some others out there. In the future though, I plan to add support for multiple credentials and authentication if I want to expose this outside the intranet.

comments powered by Disqus