Overview

While working and using QuickMon (one of my other projects on CodePlex) I realized that I'm starting to 'spam' myself with alert messages. Ignoring the alerts is not a good idea but having to search through dozens of alert messages (all valid) to read other non related mail messages became a bit of a pain.
So the idea was born to rather send alerts in batches or time-slots using some form of aggregation by 'to' address and optionally the subject as well.

I did consider building some new functionality into QuickMon itself since it only does on-the-fly alerts (i.e. immediately sending an alert the moment it is generated). However, I decided to create something a bit more generic that can even be used completely stand-alone without QuickMon. The result is something that can even be used to keep you up to date with debugging log files.

Usage scenario

The first two examples are simply to use it in conjunction with QuickMon alerts.
  • QuickMon log files: configure QuickMon to output alerts to a log file and then use the Text file aggregator to simply read the same file. You can either have the file deleted or renamed/appended. Technically there is always a chance that one of the processes can cause a lock-out problem for the other but the chance is slim (hopefully)
  • QuickMon sql table: use the sql notifier to log to a database. Using the provided example script you can add a 'marked' bit/boolean field added to the table. The example includes scripts for the stored procs as well.
  • Additionally any log file can be processed. The text file aggregator will read all contents and create a new mail message from it, then either delete or rename and append the log file for backup. This way only 'new' entries are mailed to you/whoever needs it.

Architecture

The architecture is fairly simple. There is a Windows service that calls aggregator assemblies which is based on a shared assembly that contains a standard .Net interface. This way it would be easy to add any new aggregator types in the future.
Email messages are send using SMTP mail.

Aggregators

At the moment there are only two types of aggregators:
  • Text file - plain text files containing the messages. The text files can optionally contain the 'to' or 'subject' fields specified in a predefined format. Alternatively, the default values for 'to' and 'subject' can be specified in the config of the aggregator.
  • Sql - a SQL server table that contains the messages. Any existing table that contains messages can be used - by simply adding a bit/boolean field to indicate the message has already been sent. Also, you need to create 2 stored procs: 1. select messages (must return some specified fields, 2. a mark message stored proc that takes @Id (int) as parameter. A plain tsql query can be used but is a hassle to maintain.

Service

The main 'module' is a simple 'Windows Service'. It simply takes a list of 'config' strings and create aggregator a host for each - each serviced by the type of aggregator as specified in the config.

Last edited Mar 1, 2012 at 6:34 AM by RudolfHenning, version 7