A PHP module to make use of the Pingdom REST API for you to automate your interaction with the Pingdom system.
The best way to install the library is by using Composer. Add the following to composer.json
in the root of your project:
{
"require": {
"sgrodzicki/pingdom": "1.1.*"
}
}
Then, on the command line:
curl -s http://getcomposer.org/installer | php
php composer.phar install
Use the generated vendor/.composer/autoload.php
file to autoload the library classes.
<?php
$username = ''; // Pingdom username
$password = ''; // Pingdom password
$token = ''; // Pingdom application key (32 characters)
$pingdom = new \Pingdom\Client($username, $password, $token);
// List of probe servers
$probes = $pingdom->getProbes();
foreach ($probes as $probe) {
echo $probe->getName() . PHP_EOL;
}
// List of checks
$checks = $pingdom->getChecks();
foreach ($checks as $check) {
$results = $pingdom->getResults($check['id']);
}
The client is tested with phpunit; you can run the tests, from the repository's root, by doing:
phpunit
Some tests require internet connection (to test against a real API response), so they are disabled by default; to run them add a credentials.php
file in the root of your project:
<?php
require_once __DIR__ . '/vendor/autoload.php';
$username = '[your username]';
$password = '[your password]';
$token = '[your token]';
and run the tests, from the repository's root, by doing:
phpunit --bootstrap credentials.php