Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

nicolabricot/PHPPinger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Languages