function executePing() { // Run a first instance $app = new PHP_Pinger(); // set e-mail destinators with an array $app->setNotificationTo(array('*****@*****.**', '*****@*****.**')); // you can change the subjects preffix $app->setNotificationPreffix('Network Monitoring'); // you can add a signature at the end of the sent e-mail $app->setNotificationSignature('--' . PHP_EOL . 'The Status CRON Notifier'); // now enable notification (available types are: NONE, PROBLEMS, REPORT) $app->enableNotification(NotificationLevel::REPORT); // add hosts to be checked $app->addHost('nicolabricot.com')->addHost('github.com', 443, 'GitHub ‹3')->addHost('help.github.com', 443, 'Help over HTTPS')->addHost('ftp.github.com', 21); // let's go! $app->run(); // An other instance to check some hosts $cat = new PHP_Pinger(); $cat->enableNotification(NotificationLevel::PROBLEMS)->setNotificationTo(array('*****@*****.**'))->addHost('google.fr', 80, 'Google FR')->addHost('www.google.com', 443, 'Google SSL')->addHost('404.google.com')->addHost('example.com', 8080, 'Bad example')->addHost('example.com', 80, 'Good example')->run(); // Callback functions can be also used }
<link rel="shortcut icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAABFElEQVRIib3WURGDMBBF0UhAQiW8uTFQCZUQCZWAAyQgBQlIqAQktD9hhqbJEmjazOxfyCG7C4lzzjlgAJYYg/vFAAbv/XMbJUyS4vwpeWYGBkkXC1oy0JIAl8zi2QD6UxAQcnN2YpbUVacOuB8E3rBsndJmAMIXiJ3GbU1OpCsbew0ytkCsDnaSulZIsVYRujaGnn9JXRFai9cSK+2mB8aGmF2jVlhV17XAJKnYDN77uRE2FZEITcn2T2HmbtIdncWAYCLWQrXYOi87JHU1b7uHAXcLUS5d63cQa2Y2CDCaf+p4D8geCWkK4pF+A/p1UUnXj9O0UJPSuWO35tFRuDM8qt7yIBQSZNnt/2+wzZ0h/MJ4Aa9TefuF5N03AAAAAElFTkSuQmCC" /> </head> <body> <h1><a href="https://nicolabricot.github.io/PHPPinger">PHP Pinger</a> <br />Example HTML</h1> <p>You can browse the <a href="https://nicolabricot.github.io/PHPPinger/documentation.html">documentation</a> or see the source of these page.</p> <h2>First example</h2> <p>Following enumeration is defined with callback functions (callback, preRun and postRun).</p> <!-- run result --> <?php // launch $app ping tests $app->run(); ?> <!-- /run result --> <h2>Second example</h2> <p>Only the main callback function is defined which format each line of the table.</p> <table> <tr><th>Label</th><th>host:port</th><th>Result</th></tr> <!-- run result --> <?php // launch the other example $other_example->run(); ?> <!-- /run result --> </table> </body> </html>