Examples - By Language
Simple Checkin
Check in if a script runs succesfully (perfect for cron tasks)
$ /path/to/very_important_script.sh && curl https://api.IsItWorking.info/c/CHECKIN_IDENTIFIER &> /dev/null
The && means that the curl is only called if very_important_script.sh returns an exit code of zero
Checkin with status and message
$ /path/to/script_that_might_fail.sh; curl -d "s=$?" https://api.IsItWorking.info/c/CHECKIN_IDENTIFIER
Curl will be called whatever the exit code for script_that_might_fail returns
The status is sent to IsItWorking, and if it is non-zero, an alert will be sent to you
Timing a script
#!/bin/sh start=`date +%s` /Users/rob/Documents/Development/Rails/IsItWorking/test/scripts/slow_script.sh end=`date +%s` runtime=$((end-start)) curl -d "t=$runtime" https://api.IsItWorking.info/c/CHECKIN_IDENTIFIER echo $runtime
Note - this only measures elapsed seconds
Setting a boundary and a message:
#!/bin/sh start=`date +%s` /Users/rob/Documents/Development/Rails/IsItWorking/test/scripts/slow_script.sh end=`date +%s` runtime=$((end-start)) curl -d "t=$runtime&b=5&m=Possibly Slow Script" https://api.IsItWorking.info/c/CHECKIN_IDENTIFIER echo $runtime
If the time is larger than the boundary value (5 seconds here), then an alert is triggered
IsItWorkingInfo Gem
We have a gem which provides a super way to do checkins in Ruby
Simple Checkin
require 'net/http' uri = URI('https://api.IsItWorking.info/c/CHECKIN_IDENTIFIER') result = Net::HTTP.get(uri)
Checkin with status and message
require 'net/http' uri = URI('https://api.IsItWorking.info/c/CHECKIN_IDENTIFIER') params = { m: "Important Message", s: 1 } res = Net::HTTP.post_form(uri,params)
The status is sent to IsItWorking, and if it is non-zero, an alert will be sent to you
Timing a script
require 'net/http' time = Benchmark.realtime do #do important things here end milliseconds = time * 1000 uri = URI('https://api.IsItWorking.info/c/CHECKIN_IDENTIFIER') params = { t: milliseconds } res = Net::HTTP.post_form(uri,params)
Setting a boundary and a message:
require 'net/http' time = Benchmark.realtime do #do important things here end milliseconds = time * 1000 uri = URI('https://api.IsItWorking.info/c/CHECKIN_IDENTIFIER') params = { m: "Is my script slow?", t: milliseconds, b: 5000 } res = Net::HTTP.post_form(uri,params)
If the time is larger than the boundary value (5,000 milliseconds here), then an alert is triggered
You can check in with any language that allows you to make an http call.
Please see the API document for more details.
If you'd like to contribute examples in a another language, then please get in touch