PHP Pinger is a light PHP library to check if an host is up or down.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
LICENSE
README.md
phppinger.class.php

README.md

PHPPinger

PHP Pinger is a light PHP library to check if an host is up or down.

It uses a socket and can check any host on any port, one or multiple port, can send you an e-mail report, and you can customize it to display some results on a web page.

I'm in a hurry!

// load PHP Pinger
require 'phppinger.class.php';

/* callbacks for example */
function callback($is_online, $hostname, $port, $sweety_name) {
    echo '<li>', $hostname, ':', $port, ' is ',
    ($is_online ? 'online' : 'offline'), '</li>';
}
function preRun() { echo '<ul>', PHP_EOL; }
function postRun() { echo '</ul>', PHP_EOL; }

/* instanciate a new Pinger and run it with callbacks and notifications */
$ping = new PHP_Pinger();
$ping->registerCallback('callback')
    ->registerPreRun('preRun')
    ->registerPostRun('postRun')
    ->addHost('nicolabricot.com')
    ->addHost('blog.nicolabricot.com', 80)
    ->addHost('ftp.github.com', 21, 'GitHub FTP')
    ->setNotificationTo(array('email@domain.tld', 'other-dude@domain.tld'))
    ->setNotificationPreffix('Network Monitoring')
    ->setNotificationSignature('--'.PHP_EOL.'By PHP Pinger')
    ->enableNotification(NotificationLevel::REPORT)
    ->run();

Documentation

The documentation is available on nicolabricot.github.io/PHPPinger.

You can find some examples on the examples folder.