The WatchTower Project

User Manual

Table of Contents

  1. Introduction
  2. Requirements
  3. WatchTower Project Files
    1. watchtower.conf
    2. watchtower.status
    3. watchtower.pl
  4. Getting it up and running
  5. Bugs / Todo
  6. Contact Me
Top

Introduction

The WatchTower Project was designed primarily to assist System Administrators in the active monitoring of servers and the services they provide. It consists of a few simple files which monitor specified servers and ports on which services run, and to alert administrators on different levels when the status of one or more of these services change. These levels are currently SMS messages, E-Mail notification and Log Entry.

The WatchTower Project is designed primarily to be run as a cron job, such that it is scheduled to run every so often (eg 10 minutes) and monitor the services specified in the configuration file. It then records its current state and compares it to the last recorded state. If a service has changed state, the action specified in the configuration file is undertaken.

This document will briefly go through all the configuration options and requirements for running the WatchTower Project, as well as how to get it up and running. It does not, however detail how to set up programs such as Gnokii; this documentation assumes programs like gnokii,nmap and the nmap Perl module are installed and functioning correctly.

Top

Requirements

Currently, The WatchTower Project requires the following programs to be installed and present in the path to be run at a bare minimal: For all features (including SMS and Mail Alerts) the following programs are required to be installed and present in the path: Earlier versions of these programs may work, but have not been tested.
Top

WatchTower Project Files

There are three key WatchTower Project files: The following sections will describe the format of these files and how to use them correctly.



watchtower.conf

Purpose: Configuration File
Recommended placement: /etc/watchtower.conf
Notes: To be edited by the end user.

This file is the first thing watchtower.pl looks for. Currently this file must belong in the /etc directory under the name of watchtower.conf. The format of the configuration file is similar to many other configuration files.

The file consists of one or more sections, which are indicated by placing square brackets ([ and ]) around an alphanumeric string (i.e. [my_rule_1]). the underscore, Alphabetic and numeric characters are all that is allowed within these section headers. These headers define what the WatchTower Project refers to as a Rule.

There is a special header that is reserved for the configuration of the WatchTower Project itself, and that is the [CONFIGURATION] header. this header is given special treatment and expects diffferent values, explained later.

All other rules will accept two types of values - scan and alert. more than one scan or alert value may be specified.

The [CONFIGURATION] section accepts 6 different values: That Said, here is a very basic sample configuration:

[CONFIGURATION]
sms_numbers= 0441555555
email_addresses=admins@domain.com; me@domain.com
log_file=/var/log/watchtower.log
log_all=yes

[file_server]
scan=fileserv.domain.com:139 FIN
scan=fileserv.domain.com:21 FIN
alert=sms

[windows_logon]
scan=logon.domain.com:139
alert=sms
alert=email

[external_www]
scan=www.anotherdomain.com STAT
scan=www2.anotherdomain.com STAT
alert=email

The sms_all and email_all values are omitted from the [CONFIGURATION] section, but can be added as sms_all=no and email_all=no if it makes you feel better.

All alerts which are destined to be SMS'd will be sent to the hypotheteical phone number 0441555555, likewise for all e-mail alerts which will be sent to admins@domain.com and me@domain.com. The log file exists in /var/log as watchtower.log. All alerts will be logged to this file.

There are 3 rules defined. The first rule, named file_server, scans a machine named fileserv.domain.com twice- once on port 139 (netbios) and once on port 21 (FTP). Any alerts for this rule will be sent to the log file (because of the log_all option) and also to the SMS number specified.

The second rule is named windows_logon and scans just one machine (logon.domain.com) on port 139. However, syn scanning is used because it is a windows machine. All alerts will be sent to email and sms as well as the logs.

The third rule named external_www scans two machines by a status scan (by specifying STAT). we're assuming we're behind a firewall that won't let us scan outside our network, so we're using STAT scans to check the status of the two web servers. All alerts will be e-mailed as well as logged.



watchtower.status

Purpose: Keep record of rule status
Recommended placement: /var/log/watchtower/watchtower.status
Notes: Not to be edited by end user. File completely rewritten after each scan.

The watchtower.status file is a simple file which records the status for each rule after the WatchTower Project run so it can be checked on subsequent scans for state changes. Each line has the syntax:


<rule-name>:<0|1>
where 0 represents a rule failure and 1 represents a rule pass. This file is used internally by the WatchTower Project to determine whether or not to send alerts when a rule fails, and to determine when a rule is restored.



watchtower.pl

Purpose: Main executable
Recommended placement: /usr/local/bin
Notes: Not to be edited by end user. Perl Script.

This is the main WatchTower Project executable. It is written in perl. Hence, there may be an adjustment that needs to be made to the first line of the script: #!/usr/bin/perl may have to be changed to reflect the path to your perl installation. For example, if perl is found in /usr/local/bin, you'll have to change this to #!/usr/local/bin/perl. This is the only change you will need to make to this file.

It is called simply by typing ./watchtower.pl from its installed directory. If everything is working correctly, it will open the config file, and display the rules it is scanning.

Top

Getting it up and running

Firstly, ensure that the prerequisite components mentioned earlier are installed and working. Secondly, you will need to edit your own /etc/watchtower.conf file. You should define rules as you see fit, and use IP addresses instead of DNS names if you do not have DNS servers. Also, if you plan on using a log file, ensure that the directory for the log file exists.

Once the configuration file is edited appropriately, you may run it by simply typing ./watchtower.pl from its installed directory. If all works well, you should see something similar to the following:

Using rules from file /etc/watchtower.conf...
Running at time: Fri Aug 22 10:03:50 2003
The WATCHTOWER Project.


RULE NAME           RESULT
--------------------------
int_mail:           passed
unix_ssh:           passed
unix_mail:          passed
winsrv_smb:         failed
unix_dns:           passed
external_mail:      passed

This indicates that the WatchTower project is installed and configured correctly. You will have to wait until the end of the scanning and for a rule to fail before you can test gnokii is working in conjunction with the script. Once the WatchTower project is confirmed to work, you may want to configure it as a cron job to run every so often to scan your network for all its available services. editing the cron jobs is done usually by typing crontab -e.A typical cron entry may be as follows:


# MB Run our watchtower project script every 10 minutes
0-59/10 * * * * /usr/local/etc/watchtower.pl > /var/log/watchtower/watchtower.lastrun
This particular configuration will run the watchtower project script every 10 minutes, and redirect the output to /var/log/watchtower/watchtower.lastrun. To view this, you can simply type cat /var/log/watchtower/watchtower.lastrun. If output is not directed, the result of the scan will most likely be e-mailed to the root user of the system you have installed it on. This is all that is involved in running the WatchTower Project.
Top

Bugs/Todo

Bugs Todo
Top

Contact Me

You can reach me via e-mail at: watchtower@mattbradford.com. Happy to receive proposed features and comments.



Top
Document created by Matt Bradford 20030822
Modified 20040608
Document Version 1.2