A simple, single point, site monitoring tool.
Site Monitor is designed to allow for monitoring of any URL, sending of alerts when the site fails to respond in the allowed amount of time, and emails when the site fails to respond for an extended period of time.
Additionally, there is a simple yet powerful summary reporting component that allows for daily, weekly and monthly summary reports about your URLs availabiltiy.
NOTE: SiteMonitor depends on another project of mine - AlertServer, which can be found at: https://github.com/briantroy/java-AlertServer
The site monitor script check_site_status.php should be run periodically from CRON as follows
*/1 * * * * root /usr/local/SiteMonitor/check_site_status.php cf=/usr/local/SiteMonitor/check_mvx_status_config.php >> /dev/null
The only argument is:
- cf : your configuration file based on check_site_status_config.php
A sample configuration file has been included: check_site_status_config.php
All configuration options are commented:
/* Log file for this monitor... used for daily, weekly and monthly reporting. */
define("LOGFILE", "/usr/local/SiteMonitor/home_status.log");
/* Status file for this monitor... maintains status between runs. */
define("STATUSFILE", "/usr/local/SiteMonitor/home_status_stat");
/* Array of URLs to be monitored */
$aryURL = array(
"https://mymonitoredhost.com" =>
array("displayname" => "Index", // Name for URL to display in reports/alerts.
"maxdelay" => 4, // Maximum delay to load the url. Longer = fail
"alertafter" => 2, // Number of "fail" attempts to alert after
"emailalertmultiple" => 3), // This number is multiplied by the "alertafter" value to determine when to send email alerts. In this case an email alert will be sent every 2*3 sequential failed monitor attempts.
"https://mymonitoredhost.com/api/v1/list/10/13/2011" =>
array("displayname" => "API",
"maxdelay" => 2,
"alertafter" => 2,
"emailalertmultiple" => 3),
);
$aryAlertUsers = array(
"user" => array(
"name" => "Brian Roy", // User Name
"alertmethods" => array(
0 => array("type" => "IM", // IM (XMPP) alerts
"address" => "[email protected]", // XMPP Address
"active" => true), // Active true/false - controls if this type of alerts are sent for the user.
1 => array("type" => "SMS", // SMS based alerts
"address" => "16508675309", // SMS address - phone number.
"active" => true), // Active true/false - controls if this type of alerts are sent for the user.
2 => array("type" => "EMAIL", // EMAIL alerts/reports
"address" => "[email protected]", // Email address
"alert" => true, // Send Email Alerts? true/false
"active" => true, // Active true/false - controls if this type of alerts are sent for the user.
"daily" => true, // Send daily summary report
"weekly" => true, // Send weekly summary report
"monthly" => true), // Send monthly summary report
),
),
);
SiteMonitor can send 3 kinds of alerts
- SMS alerts via Google Voice - REQUIRES AlertServer (see above).
- XMPP alerts via a Jabber Account - REQUIRES AlertServer (see above).
- Email alerts.
It is possible to use SiteMonitor without AlertServer IF you only set email alerts as active. However, you still need to have all the required PHP libraries installed.
Summary reports are generated from each monitor's log file (as defined in check_site_status_config.php). Each report (daily, weekly and monthly) is generated by a specific script run from CRON as follows:
0 4 * * * root /usr/local/SiteMonitor/doDailyReport.php logfile=/usr/local/SiteMonitor/home_status.log cf=/usr/local/SiteMonitor/check_home_status_config.php >> /dev/null
0 5 * * 1 root /usr/local/SiteMonitor/doWeeklyReport.php logfile=/usr/local/SiteMonitor/home_status.log cf=/usr/local/SiteMonitor/check_home_status_config.php >> /dev/null
0 5 1 * * root /usr/local/SiteMonitor/doMonthlyReport.php logfile=/usr/local/SiteMonitor/home_status.log cf=/usr/local/SiteMonitor/check_home_status_config.php >> /dev/null
Every monitor should have a cron entry for each script (doDailyReport.php, doWeeklyReport.php and doMonthlyReport.php). The CRON configurations above will run each report as follows:
- Daily: Every day at 4AM
- Weekly: Every Sunday at 5AM
- Monthly: The first day of every month at 5AM
Each report script takes two arugments:
- logfile : The logfile for the monitor as defined in the monitor's configuration file (e.g., check_site_status_config.php).
- cf : The configuration file for the monitor (e.g., check_site_status_config.php).
Beanstalked is a simple job queue server. SiteMonitor and AlertServer use beanstalked to send alerts. Both AlertServer and SiteMonitor have been tested against beanstalked 1.4.6
http://kr.github.com/beanstalkd/
Pheanstalk is a library to integrate PHP with the Beanstalkd simple job queue server (used by AlertServer to get alerts to send).
Version 1.0 Reccomended.
NOTE: You will need to adjust check_site_status.php to have the correct path to pheanstalk. See line 3 for details.
https://github.com/pda/pheanstalk
Mail Mime is used to send multipart messages in HTML/Text. It is used to send email alerts and summary reports (daily, weekly, and monthly).
http://pear.php.net/package/Mail_Mime/redirected
AlertServer is another project of mine designed to implemenet a central, scalable alert sending mechanism. It is required for sending SMS and XMPP (IM) based alerts.