Skip to content

Instantly share code, notes, and snippets.

@dennisfaust
Created April 14, 2011 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dennisfaust/920509 to your computer and use it in GitHub Desktop.
Save dennisfaust/920509 to your computer and use it in GitHub Desktop.
Pingdom supports http custom checks via XML. This is a ruby code snippet which checks a file's timestamp and returns OK if it's recent enough. http://royal.pingdom.com/2008/07/14/new-pingdom-feature-custom-monitoring-type/
#!/usr/bin/ruby
# Pingdom_http_custom_check
# DFF - 2011
# put this in {Apache Files}/cgi-bin/
# make sure to chmod +x the file
# Your ruby interpreter might not be where mine is. Check the above.
#
require 'cgi'
too_old=360
FILE_TO_TIMESTAMP='/mnt/titan_data/pantheon/PANTHEON_FILE_TIMESTAMP'
#Get modification time:
age_in_seconds = (Time.now - File.mtime(FILE_TO_TIMESTAMP)).to_i
cgi = CGI.new('html3')
cgi.out do
cgi.out { "<pingdom_http_custom_check>\n\t<status>#{ age_in_seconds < too_old ? 'OK' : 'ERROR' }</status>\n\t<response_time>#{age_in_seconds.to_s }</response_time>\n</pingdom_http_custo
m_check>" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment