Site Monitor Engine
Version: 1.0
Last update: 3 year ago
Platforms: php, SQLite
Example included: yes
Asq a question Purchase
description

Description

  • Check your sites uptime
  • Get notification when your site is not available
  • Get you sites uptime rate
  • Using SQLite database
  • Server notification by sending POST data

installation

Copy monitor.php on your server and include in PHP script when you need it:

require_once('monitor.php');

Then add file with initialization in CRON:

*/5 * * * * php /path_to_initialization_file/init.php

This sets cron with 5 minute interval

initialization

Monitor::init($sites). Static function. Initialize parameters and create or open sqlite base.

$sites - array of sites. Each site is array with parameters:

  • url - url of site to monitor.
  • timeout - maximum server unavailability time, minutes.
  • email - email for notifications
  • curl - array of sites.

Example:

$sites = array(
     array("url"=>"http://shop.tolk.by/", "timeout"=>5, "curl"=>"url_for_curl", "email"=>"tessen@yandex.ru"),
     array("url"=>"http://codecanyon.net/", "timeout"=>5, "email"=>"tessen@yandex.ru")
);
Monitor::init($sites);
monitor

When server downtime reaches up to timeout parameter, engine send notification or curl.
When server restores, engine send restore notification.
Example:

Monitor::init($sites)->monitore();
curl

If you want to log server downtime periods, you can send POST data by CURL to specified address (parameter curl of site).
Post data:

  • site - url of site
  • start - time of start of downtime period in format "Y-m-d H:I:S"
  • final - time of end of downtime period in format "Y-m-d H:I:S"
infobyday

Function returns statistic of the day for site. Parameters:

  • site - Url of site
  • day - parameter day is a string of 12 numbers. Example: 201402050000,
    Where:
    • 2014 - year
    • 02 - month
    • 05 - day
    • 00 - hours
    • 00 - minutes

Example:

$day = date("Ymd")."0000";
$arr = Monitor::getByDay("http://monitore_site.com/", $day);

Function returns array with statistics:

  • $arr["sum"] - summary server downtime for the specified day
  • $arr["percentage"]["off"] - percentage of the server downtime for the specified day
  • $arr["sum"] - percentage of the server uptime for the specified day
infobymonth

Function returns monthly statistic for site. Parameters:

  • site - Url of site
  • month - parameter month is a string of 12 numbers. Example: 201402000000,
    Where:
    • 2014 - year
    • 02 - month
    • 00 - day
    • 00 - hours
    • 00 - minutes

Example:

$day = date("Ym")."000000";
$arr = Monitor::getByDay("http://monitore_site.com/", $month);

Function returns array with statistics:

  • $arr["sum"] - summary monthly server downtime
  • $arr["percentage"]["off"] - percentage of monthly server downtime
  • $arr["sum"] - percentage of monthly server uptime
screenshots
Changelog
Version 1.0
  • Released
0