New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Anyone using UptimeRobot's API?
I was wondering if anyone's using UptimeRobot's API?
I found this piece of php code which displays all your monitored services in a nice table, but it shows the all time uptime, so not per month:
http://forum.youhosting.com/post8969.html#p8969
I tried changing the 'alltimeuptimeratio' to ''customUptimeRatio=30' as per UptimeRobot's API, but then it doesn't show any uptime stats anymore
Thanked by 1djvdorp
Comments
Try this
Instead of
if ($monitor['alltimeuptimeratio'] > 95) { echo "<b style=\"color:green;\">" . $monitor['alltimeuptimeratio'] . "%</b></td></tr>"; } else { echo "<b style=\"color:red;\">" . $monitor['alltimeuptimeratio'] . "%</b></td></tr>"; }
and
$url = "http://api.uptimerobot.com/getMonitors?apiKey=" . $apiKey . "&format=xml";
use
if ($monitor['customuptimeratio'] > 95) { echo "<b style=\"color:green;\">" . $monitor['customuptimeratio'] . "%</b></td></tr>"; } else { echo "<b style=\"color:red;\">" . $monitor['customuptimeratio'] . "%</b></td></tr>"; }
and
$url = "http://api.uptimerobot.com/getMonitors?apiKey=" . $apiKey . "&customUptimeRatio=30&format=xml";
echo "" . $monitor['customuptimeratio'] . "%";
}
else {
echo "" . $monitor['customuptimeratio'] . "%";
}
}
Why on Earth are you using an if/else statement to echo a single variable?
I was wondering the same thing.
If it's over 95, echo it, if not echo it.
Edit : yeah, makes sense now.
I've updated the sample from the first post but it looks that HTML tags were removed
Updated my previous comment with this f***ing markdown
@gbshouse Thanks, that indeed did solve the problem
I also added the type of check without problems. However, I do have problems adding the log 'datetime' and log 'type'. It doesn't display anything in the last two columns (Last Error says 'Not available', At is empty), but the xml file does contain these values..
Here's the code I have now: http://pastebin.com/dYtjCJBn
UptimeRobot's API can be found here: http://uptimerobot.com/api.asp
@Freek - as far as I can see from API doc "datetime" and "type" are the attributes of "log" not "monitor" so you should add something like
foreach($xml->monitor as $monitor) {
foreach($monitor->log as $log) {
echo $log['datetime'];
echo $log['type'];
}
}
Try to read documentation once again including samples
Note - I'm writing straight from my head using my phone and I'm not PHP expert
What's so difficult with Markdown? It's what we've been using since Usenet all day long.
Nothing - just used to use HTML to format posts on dev forums
@gbshouse Hmm, looks to me datetime and type are attributes of log.. xml says this:
http://pastebin.com/MyM0aXTT
@gbshouse use < pre >
< / pre >
@gbshouse @Freek Or just put four spaces at the beginning of each line.
@Freek - yes, those props. belongs to log not to monitor but your code uses them in context of monitor not log. Try to use my snippet from one of the previous entries. Beside that yor are using log variable but never assigning the value to it for ex. like the first log entry from monitor object.
I know this is a little offtopic, but does anyone know if they offer plans above 50 servers?
Contact them
Thanks for this share. UptimeRobot has been extremely accurate for me. In a year of using it I've not had one false report.
@jarland - I agree, UptimeRobot is better than monitor.us and site24x7 (which I used previously)
@gbshouse Thanks, I managed to got it to work!
Now I need to skin it a little bit, because now it looks like this:
It does the job, but we all love a little eye candy, don't we
Here's the source. Note that's not fully ready yet. I need to add some more status codes etc. Will post the final source when I'm ready.
@Freek why is that epic if/else statement still there?
if a
then b
else
then b
makes no sense
@djvdorp Because I just wanted to see the 'log' part working first :P I will remove it in the 'final' version
^.^ I don't get that... It sort of defeats all purpose.
Oh, look, if this matches, output a var, if it doesnt, output it anyway. -sighface.
Might start using this, just to keep an eye on certain things I own ;']!