Created
April 14, 2011 20:53
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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