SerMon
  Download SerMon v0.1
Static HTML Demo
Download Add-On
SerMon


SERverMONitor is an Open Source PHP Server Monitor

SerMon uses plugins to check your server and to notify you a problem.

News
2009-11-20 :: Released Alert-Plugin: Twitter
The Twitter Alert Plugin sends messages to your Twitter Account when an error is caught.
Download - Installation and Configuration: twitter_readme.txt
2009-11-18 :: Released SerMon
Go to SourceForge Project Page: SerMon

Usage
SerMon is a server-side PHP script that needs an external scheduler to be executed.

Cron under Debian/Ubuntu:
  1. Download and Extract SerMon
  2. Configure SerMon (change settings in the file: configure.php)
  3. Disable unwanted plugins by moving them in the "disabled" folder
  4. As root go in the folder: /etc/cron.hourly/ (# cd /etc/cron.hourly/)
  5. Create a bash script with vim (# vim sermon)
  6. # chmod +x sermon



SerMon and Plugins
SerMon uses Plugins to perform every operation: to check your server and to send notifications. So we have 2 types of plugin in 2 different folders ("alerts/" and "plugin/").
When SerMon starts it checks all available plugins and sequentially executes them. If something goes wrong it calls (sequentially) (all available) "alert" plugins to send notifications (to send emails, to write an error log, to post something to your twitter account , ...)


Default Plugins
mysql.php
This plugin checks that the MySQL Server is UP and responsive. It tries to connect to a MySQL Server and to execute a customizable query.

Variables (in configure.php):
  • MYSQL001_SERVER (Leave this field empty to disable this test)
  • MYSQL001_USERNAME
  • MYSQL001_PASSWORD
  • MYSQL001_DATABASE
  • MYSQL001_TEST_QUERY (Customizable SQL Query)
  • MYSQL001_MAX_TIME (in seconds)
If MySQL Server is down or if it executes your custom query in more than MYSQL001_MAX_TIME: SerMon will call (all available) alert-plugin.


speed.php
This is a simple Speed Test plugin for your server. It downloads a file and calculates the speed of your server.

Variables (in configure.php):
  • SB001_URL2DOWNLOAD (Leave this field empty to disable this test)
  • SB001_MIN_BANDWIDTH (In Kb/s)
Alert plugins are called if your server download SB001_URL2DOWNLOAD too much slowly.


md5_check.php
Checks files (or URLs) against MD5 Hashes. This is useful to check that your homepage or important files aren't modified.

Variables (in configure.php):
  • MD5001_URL (Leave this field empty to disable this test)
  • MD5001_MD5
You can list as many URLs (and MD5s) you want by separating them with commas. Examples:
Alert plugins are called when one or more file don't match their MD5


webserver.php
Tries to open an URL on your webserver (Example: http://yourdomain/)

Variables (in configure.php):
  • WS001_URL2DOWNLOAD (Leave this field empty to disable this test)
Alert plugins are called if your server cant't open WS001_URL2DOWNLOAD


How to develop a Plugin
skeleton.php (plugin/skeleton.php.txt)

Note:
  • SERMON will use (execute) all the files ending with ".php" in the "plugin" folder
    (Please move un-wanted plugins in the "disabled" folder)
  • Use the constant BASE_DIR to get the root folder of SERMON
  • Set the variable "$alert" to true if you want to report a problem.
  • Use the variable "$alert_msg" to return an error message.

Example (plugin/webserver.php)



Alert Plugins
Alert Plugins are the way SerMon sends notifications (E-Mail, Log Files, SMS, ...)

Default Alert Plugins
send_mail.php
This alert-plugin sends emails when something goes wrong.

Variables (in configure.php):
  • SENDEMAIL001_TO (Leave this field empty to disable this notification)
  • SENDEMAIL001_SUBJECT


file_log.php
This alert-plugin logs all problems to a custom file.

Variables (in configure.php):
  • FILELOG001_FULL_PATH (Leave this field empty to disable this notification)


How to develop an Alert-Plugin
skeleton.php (alerts/skeleton.php.txt)

Note:
  • SERMON will use (execute) all the files ending with ".php" in the "alerts" folder
    (Please move un-wanted alert-plugins in the "disabled" folder)
  • You can't declare functions() in your custom alert!
    Alerts (PHP files in the "alerts" folder) are included many times by the main script and declaring a function in an alert will result in a PHP error
  • Use the constant BASE_DIR to get the root folder of SERMON
  • Use the variable "$source_alert" to get the name of the plugin that generated an error.
  • Use the variable "$alert_msg" to get the error message from the plugin that generated an error.
  • Use the variable "$alert_out" to print something.

Example (plugin/file_log.php)



Screenshots
Static HTML Demo SerMon User Interface with many simulated server problems.


Requirements
Apache and PHP correctly installed.




lab.openwebspider.org     |     Powered by OpenWebSpider