PHP Classes

PHP PingDom: Check site status sending HTTP and ping requests

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 261 This week: 1All time: 7,794 This week: 560Up
Version License PHP version Categories
pingdom 0.01GNU General Publi...4.3Networking, HTTP, PHP 5
Description 

Author

This class can check status of a site sending HTTP and ping requests.

It can send HTTP requests to Web site servers and check the responses to see if the site is responding correctly.

The class can check the response by determining if they contain a certain text or not.

It can also send UDP ping protocol request to the server address and waits for its response until a given timeout period to verify if the server is responding.

Innovation Award
PHP Programming Innovation award nominee
August 2014
Number 4
Montoring a site is an useful process that can help detecting problems with site servers, so those problems can be fixed as soon as possible.

This class provides a solution to monitor a site based either in HTTP requests and ping protocol requests.

Manuel Lemos
Picture of Pejman Ghasemi
Name: Pejman Ghasemi <contact>
Classes: 1 package by
Country: United Kingdom
Age: ???
All time rank: 3940171 in United Kingdom
Week rank: 411 Up12 in United Kingdom Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
//include class
include('ping.class.php');
//Instantiation of Class
$pingdom = new PingDom;

/*function ping
parameters: it's an array or string that included host address, port and etc.
mode: it's mode of checking your destination host. included ('ping','status_check','equal','not_equal')
timeout: it's number of timeout and integer. Default: 1 , For Example: 3

$paramaters = array('host'=>'http://www.google.com','value'=>'site is alive');
$pingdom->ping($parameters,'equal',3);
*/



/*Array For Paramteres to check status of website
host: IP or Host address of destination.
port: Port of destination server. (optional)
*/
$paramaters_check_status1 = array('host'=>'http://www.google.com','port'=>'80');
if(
$pingdom->ping($paramaters_check_status1,'status_check')){
    echo
'alive';
}else{
    echo
'dead';
}

echo
'<br />------------------<br />';

$paramaters_check_status2 = array('host'=>'http://www.google.com:80');
if(
$pingdom->ping($paramaters_check_status2,'status_check')){
    echo
'alive';
}else{
    echo
'dead';
}

echo
'<br />------------------<br />';
/*Array For Parameters to search for value in website
host: IP or Host address of destination. for example : http://www.google.com , http://192.168.1.1 , http://www.google.com:80
value: exact value should search for in website. For example: "site is alive"
port: Port of destination server. (optional) for example: 80, 8080
*/
$paramaters_search_for_included = array('host'=>'http://www.google.com','value'=>'site is alive');
if(
$pingdom->ping($paramaters_search_for_included,'equal')){
    echo
'alive';
}else{
    echo
'dead';
}

echo
'<br />------------------<br />';



/*Array For Parameters to search for value that is not included in website
host: IP or Host address of destination. for example : http://www.google.com , http://192.168.1.1 , http://www.google.com:80
value: exact value should search for in website. For example: "site is dead"
port: Port of destination server. (optional) for example: 80, 8080
*/
$paramaters_search_for_not_included = array('host'=>'http://www.google.com','value'=>'site is dead');
if(
$pingdom->ping($paramaters_search_for_not_included,'not_equal')){
    echo
'alive';
}else{
    echo
'dead';
}

echo
'<br />------------------<br />';



// ****Direct use specific of class*****

$host = 'http://www.google.com';
$value = 'search';
if(
$pingdom->equal_check($host,$value,$timeout=1,$port=80)){
    echo
'alive';
}else{
    echo
'dead';
}
echo
'<br />------------------<br />';


$host = 'http://www.google.com';
$value = 'Database connection error';
if(
$pingdom->not_equal_check($host,$value,$timeout=1,$port=80)){
    echo
'alive';
}else{
    echo
'dead';
}

echo
'<br />------------------<br />';
$host = '192.168.1.101';
$value = 'Database connection error';
if(
$pingdom->check_ping($host,$timeout=1)){
    echo
'alive';
}else{
    echo
'dead';
}

?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example this is a test file included example of using pingdom class
Plain text file ping.class.php Class Pingdom Claas

 Version Control Unique User Downloads Download Rankings  
 0%
Total:261
This week:1
All time:7,794
This week:560Up