Click here to Skip to main content
13,344,508 members (58,260 online)
Click here to Skip to main content
Add your own
alternative version


116 bookmarked
Posted 28 Aug 2010

SystemWatchdog - An Experimental & Educational Project for System Monitoring

, 28 Aug 2010
Rate this:
Please Sign up or sign in to vote.
This is an experimental & educational project for system monitoring based on "Base Library for Multi-threaded Windows Services" architecture


SystemWatchdog is a simple and flexible system monitoring tool for experimental and educational purpose, based on Base Library for Multi-threaded Windows Services[^] architecture.


Install software with installer, edit configuration file (SystemWatchdog.exe.config), and then, start service.

Configuration File



<watchdog name="MsSqlPortTester" enabled="true" sleepTime="60">
<plugin type="SystemWatchdog.Plugins.PortConnector, SystemWatchdog.Plugins">
<parameter name="Hosts" value=",," />

<watchdog name="HttpTester" enabled="true" sleepTime="60">
<plugin type="SystemWatchdog.Plugins.HttpRequester, SystemWatchdog.Plugins">
<parameter name="Host" value="" />
<parameter name="WaitingResponse" value="" />

<watchdog name="SmtpTester" enabled="true" sleepTime="60">
<plugin type="SystemWatchdog.Plugins.SmtpConnecter, SystemWatchdog.Plugins">
<parameter name="Hosts" value="" />

<watchdog name="Pinger" enabled="true" sleepTime="60">
<plugin type="SystemWatchdog.Plugins.Pinger, SystemWatchdog.Plugins">
<parameter name="Hosts" value="" />


<operator name="Efe Erdogru" email="" />

<smtpClient host="" port="587">
<parameter name="FromName" value="Efe Erdogru" />
<parameter name="FromAddress" value="" />
<parameter name="IsSmtpRequiresAuthentication" value="true" />
<parameter name="SmtpUserName" value="" />
<parameter name="SmtpPassword" value="password" />


Configuration section is made of three parts:

  1. watchdogList: This section contains the watchdog services.
  2. operators: This section contains the operators which will be used when an watchdog gets an error.
  3. smtpClient: This section contains SMTP connection settings.

Every watchdog is a service which does a work managed by a plugin.


Project contains an engine library which manages and configures the watchdogs and a plugin library. Also an executor service which is a Windows service and an installer.

  1. Engine Library
  2. Plugin Library
  3. Executor Service
  4. Installer

Engine Library

  • Interfaces
    • IConfigurable: Defines the interface for the classes which can be configured via XmlNode instance that contains the configuration settings.
    • IRunnable: Defines the interface for all classes that have a determined lifetime for execution.
    • IWatchdog: Defines the interface for the classes which will watch the system.
    • IPlugin: Defines the interface for the classes which is a plugin for a watchdog.
  • Watchdog: Worker service which signals the plugin to execute its own process.
  • WatchdogManager: Manages the starting and stopping of watchdogs configured in the system.
  • PluginSkeleton: Base class for plugin instances.
  • PluginFactory: Creates an object of the specified type using reflection through an argumentless constructor.

Plugin Library

  • HttpRequester: This plugin connects a URL and gets a response. If configured, it checks if the response is matched or not.
  • Pinger: This plugin pings to an address.
  • PortConnector: This plugin connects to an IP on a given port.
  • SmtpConnecter: This plugin is for SMTP servers. It connects, sends EHLO (or HELO) command.

Executor Service

  • WindowsService
  • Installer

Using the Code

For base architecture, see Base Library for Multi-threaded Windows Services[^].


<section name="log4net" 

	type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<section name="systemWatchdog" 

	SystemWatchdog.Engine" />

SystemWatchdogConfigurationSectionHandler implements the IConfigurationSectionHandler interface for configuration settings.

var section = (XmlNode) ConfigurationManager.GetSection("systemWatchdog");

How Plugins are Created?

public static IPlugin GetPlugin(XmlNode configSection)
var type = configSection.Attributes["type"].Value;
return (IPlugin) PluginFactory.Create(type);

Watchdog Structure

When execution time comes, watchdog calls plugin to execute itself. If no error occurred, thread will sleep until next execution time which is configured in configuration file. If an error occurred, plugin signals a "PluginErrorEventHandler" event which is caught by watchdog, and then, an e-mail is sent to the operators with SMTP configuration settings.

var section = configSection.SelectNodes("./plugin")[0];
WatchdogPlugin = Tools.GetPlugin(section);
WatchdogPlugin.Log = Log;

WatchdogPlugin.PluginError += WatchdogPlugin_PluginError;


private void WatchdogPlugin_PluginError(object sender, PluginErrorEventArgs e)
Log.Warn(String.Format("Plugin error received: {0}\r\n{1}", e.Subject, e.Body));

Tools.SendMailToOperators("SystemWatchdog Error - " + e.Subject, e.Body, Log);


This is the first published version.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Efe Erdoğru
Software Developer (Senior)
Turkey Turkey
No Biography provided

You may also be interested in...


Comments and Discussions

PraiseMessage Closed Pin
8-Dec-17 2:46
memberbright2128-Dec-17 2:46 
Questioncan't stop and restart Pin
Ernest Bariq5-Sep-14 10:13
memberErnest Bariq5-Sep-14 10:13 
AnswerRe: can't stop and restart Pin
Efe Erdogru5-Sep-14 10:39
memberEfe Erdogru5-Sep-14 10:39 
GeneralRe: can't stop and restart Pin
Ernest Bariq5-Sep-14 11:07
memberErnest Bariq5-Sep-14 11:07 
GeneralRe: can't stop and restart Pin
Efe Erdogru5-Sep-14 11:32
memberEfe Erdogru5-Sep-14 11:32 
GeneralRe: can't stop and restart Pin
Ernest Bariq5-Sep-14 11:42
memberErnest Bariq5-Sep-14 11:42 
GeneralMy vote of 5 Pin
crab6506-Nov-13 22:39
membercrab6506-Nov-13 22:39 
GeneralMy vote of 5 Pin
zhaojs25-Dec-11 22:21
memberzhaojs25-Dec-11 22:21 
GeneralMy vote of 5 Pin
Kanasz Robert1-Dec-11 3:45
memberKanasz Robert1-Dec-11 3:45 
GeneralMy vote of 5 Pin
waqas31620-May-11 20:44
memberwaqas31620-May-11 20:44 
GeneralPing does not work Pin
__Untitled24-Feb-11 21:14
member__Untitled24-Feb-11 21:14 
GeneralNice! Pin
Member 45586629-Aug-10 3:49
memberMember 45586629-Aug-10 3:49 

GeneralMy vote of 5 Pin
Member 45586629-Aug-10 3:49
memberMember 45586629-Aug-10 3:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 28 Aug 2010
Article Copyright 2010 by Efe Erdoğru
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid