PHP Classes

File: example1.php

Recommend this page to a friend!
  Classes of Paul Aitken   Server Status   example1.php   Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: A simple example of using ServerStatus
Class: Server Status
Checks a server to verify if services are up.
Author: By
Last change: A complete recode, using the new methods.
Date: 16 years ago
Size: 709 bytes
 

Contents

Class file image Download
<?php
/**
 * Copyright 2007. Paul Aitken <http://justletitflow.com>
 * Licensed under The GNU General Public License (GPL) Version 2 or greater
 * http://www.opensource.org/licenses/gpl-license.html
 */
require_once 'server_status.php';

// Create new instance of the class ServerStatus
$status = new ServerStatus();

// Lets add an example site to check - first parameter must be unique for each service
$status->add('http-example', 'example.com', 80);

// Lets check all the status' of the servers that were added
$status->check();

// Lets check the status of 'http-example' (returns true/false)
echo ($status->status('http-example')) ? 'http-example is up' : 'http-example is down';
?>