Commit 2402c1a9 authored by dmorley's avatar dmorley
Browse files

move to v2 api for uptimerobot

parent a5d68080
...@@ -10,27 +10,28 @@ $result = pg_query_params($dbh, $sql, array($domain)); ...@@ -10,27 +10,28 @@ $result = pg_query_params($dbh, $sql, array($domain));
if (!$result) {die("Error in SQL query: " . pg_last_error());} if (!$result) {die("Error in SQL query: " . pg_last_error());}
$apikey = pg_fetch_all($result); $apikey = pg_fetch_all($result);
$upti = curl_init(); $upti = curl_init();
$curlurl = "https://api.uptimerobot.com/getMonitors?format=json&customUptimeRatio=7-30-60-90&responseTimes=1&responseTimesAverage=86400&apiKey=".$apikey[0]['pingdomurl']; $key = $apikey[0]["pingdomurl"];
curl_setopt($upti, CURLOPT_URL, $curlurl); $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_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_RETURNTRANSFER, 1);
curl_setopt($upti, CURLOPT_CONNECTTIMEOUT, 8); curl_setopt($upti, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($upti, CURLOPT_FOLLOWLOCATION, true);
$uptimerobot = curl_exec($upti); curl_close($upti); $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 "<b>UptimeRobot Json displayed in Human</b><br><br>";
echo "Name: ".$uptr->monitors->monitor{'0'}->friendlyname."<br>"; echo "Name: ".$uptr->monitors[0]->friendly_name."<br>";
echo "Url: ".$uptr->monitors->monitor{'0'}->url."<br>"; echo "Url: ".$uptr->monitors[0]->url."<br>";
echo "Interval: ".$uptr->monitors->monitor{'0'}->interval."ms<br>"; echo "Interval: ".$uptr->monitors[0]->interval."ms<br>";
echo "Uptime: ".$uptr->monitors->monitor{'0'}->alltimeuptimeratio."%<br>"; echo "Uptime: ".$uptr->monitors[0]->all_time_uptime_ratio."%<br>";
echo "Response Time: ".$uptr->monitors->monitor{'0'}->responsetime{'0'}->value."ms<br>"; echo "Response Time: ".round($uptr->monitors[0]->average_response_time)."ms<br>";
if ($uptr->monitors->monitor{'0'}->status == 2) {$live = "Up";} if ($uptr->monitors[0]->status == 2) {$live = "Up";}
if ($uptr->monitors->monitor{'0'}->status == 0) {$live = "Paused";} if ($uptr->monitors[0]->status == 0) {$live = "Paused";}
if ($uptr->monitors->monitor{'0'}->status == 1) {$live = "Not Checked Yet";} if ($uptr->monitors[0]->status == 1) {$live = "Not Checked Yet";}
if ($uptr->monitors->monitor{'0'}->status == 8) {$live = "Seems Down";} if ($uptr->monitors[0]->status == 8) {$live = "Seems Down";}
if ($uptr->monitors->monitor{'0'}->status == 9) {$live = "Down";} if ($uptr->monitors[0]->status == 9) {$live = "Down";}
echo "Status: ".$live; echo "Status: ".$live;
pg_free_result($result); pg_free_result($result);
pg_close($dbh); pg_close($dbh);
?> ?>
Show as: <a href="?mapview=true">Map</a> <a href="/">Simple Table</a> <a href="?advancedview=true">Advanced Table</a> Show as: <a href="?mapview=true">Map</a> <a href="/">Simple Table</a> <a href="?advancedview=true">Advanced Table</a>
<?php <?php
//focus map to the users side of the globe
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; $country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
$csv = array_map('str_getcsv', file('db/country_latlon.csv')); $csv = array_map('str_getcsv', file('db/country_latlon.csv'));
foreach ($csv as $cords) { 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