Commit 2402c1a9 authored by dmorley's avatar dmorley

move to v2 api for uptimerobot

parent a5d68080
......@@ -10,27 +10,28 @@ $result = pg_query_params($dbh, $sql, array($domain));
if (!$result) {die("Error in SQL query: " . pg_last_error());}
$apikey = pg_fetch_all($result);
$upti = curl_init();
$curlurl = "https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&responseTimes=1&responseTimesAverage=86400&apiKey=".$apikey[0]['pingdomurl'];
curl_setopt($upti, CURLOPT_URL, $curlurl);
$key = $apikey[0]["pingdomurl"];
$data = array('all_time_uptime_ratio' => 1, 'format' => 'json', 'custom_uptime_ratios' => '7-30-60-90', 'response_times' => 1, 'response_times_average' => 86400, 'api_key' => $key, 'callback' => 'jsonpUptimeRobot');
curl_setopt($upti, CURLOPT_URL, "https://api.uptimerobot.com/v2/getMonitors");
curl_setopt($upti, CURLOPT_HEADER, 0);
curl_setopt($upti, CURLOPT_POST, 1);
curl_setopt($upti, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($upti, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($upti, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($upti, CURLOPT_FOLLOWLOCATION, true);
$uptimerobot = curl_exec($upti); curl_close($upti);
$json_encap = "jsonUptimeRobotApi()"; $up2 = substr ($uptimerobot, strlen($json_encap) - 1, strlen ($uptimerobot) - strlen($json_encap)); $uptr = json_decode($up2);
$json_encap = "jsonpUptimeRobot()"; $up2 = substr ($uptimerobot, strlen($json_encap) - 1, strlen ($uptimerobot) - strlen($json_encap)); $uptr = json_decode($up2);
echo "<b>UptimeRobot Json displayed in Human</b><br><br>";
echo "Name: ".$uptr->monitors->monitor{'0'}->friendlyname."<br>";
echo "Url: ".$uptr->monitors->monitor{'0'}->url."<br>";
echo "Interval: ".$uptr->monitors->monitor{'0'}->interval."ms<br>";
echo "Uptime: ".$uptr->monitors->monitor{'0'}->alltimeuptimeratio."%<br>";
echo "Response Time: ".$uptr->monitors->monitor{'0'}->responsetime{'0'}->value."ms<br>";
if ($uptr->monitors->monitor{'0'}->status == 2) {$live = "Up";}
if ($uptr->monitors->monitor{'0'}->status == 0) {$live = "Paused";}
if ($uptr->monitors->monitor{'0'}->status == 1) {$live = "Not Checked Yet";}
if ($uptr->monitors->monitor{'0'}->status == 8) {$live = "Seems Down";}
if ($uptr->monitors->monitor{'0'}->status == 9) {$live = "Down";}
echo "Name: ".$uptr->monitors[0]->friendly_name."<br>";
echo "Url: ".$uptr->monitors[0]->url."<br>";
echo "Interval: ".$uptr->monitors[0]->interval."ms<br>";
echo "Uptime: ".$uptr->monitors[0]->all_time_uptime_ratio."%<br>";
echo "Response Time: ".round($uptr->monitors[0]->average_response_time)."ms<br>";
if ($uptr->monitors[0]->status == 2) {$live = "Up";}
if ($uptr->monitors[0]->status == 0) {$live = "Paused";}
if ($uptr->monitors[0]->status == 1) {$live = "Not Checked Yet";}
if ($uptr->monitors[0]->status == 8) {$live = "Seems Down";}
if ($uptr->monitors[0]->status == 9) {$live = "Down";}
echo "Status: ".$live;
pg_free_result($result);
pg_close($dbh);
?>
Show as: <a href="?mapview=true">Map</a> <a href="/">Simple Table</a> <a href="?advancedview=true">Advanced Table</a>
<?php
//focus map to the users side of the globe
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
$csv = array_map('str_getcsv', file('db/country_latlon.csv'));
foreach ($csv as $cords) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment