Sha256: b476c4022a0122437f59907f6ea08d9fef1cbaa7475f88b08986cfd0cce64948
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
#!/usr/bin/env ruby require "time" SERVICE_NAME="GlowwormServerStatus" HOST="127.0.0.1" PORT=4999 URI="/healthz" URL="http://#{HOST}:#{PORT}#{URI}" OUTPUT=`curl -I #{URL} 2> /dev/null` if OUTPUT.empty? puts "2 #{SERVICE_NAME} - Glowworm Nginx Server Down" exit end MOD_TIME=Time.parse `echo "#{OUTPUT}" |grep Last-Modified |sed -e 's/^Last-Modified: //'` HTTP_STATUS=OUTPUT.split[1].to_i # TODO(jbhat): We need to check that output's time, which looks like: Thu, 18 Oct 2012 05:56:57 GMT, # is within 10 minutes of now. If we get a 404, we should return that the glowworm server is down. # If we get a 500, we should report that there is an error (shouldn't happen). # If we get a 200, but the file is more than 10 minutes ago, we should return an error of stale data. # If we get a 200 with fresh file, but the contents are not OOYALA GLOWWORM OK, we should error its contents. # Finally, we can return ok if the file has last been modified within 10 minutes, and contains the string. STATUS, OUTPUT_TEXT = case HTTP_STATUS when 200 AGE=Time.now - MOD_TIME if(AGE > 600) [2, "Data Stale, healthz has not been updated in #{AGE} seconds."] else HEALTHZ_CONTENTS=`curl #{URL} 2> /dev/null`.chomp if HEALTHZ_CONTENTS =~ /OOYALA GLOWWORM OK/ [0, HEALTHZ_CONTENTS] else [2, HEALTHZ_CONTENTS] end end when 404 [2, "404 Glowworm Service Down"] else [2, "#{STATUS} Error Retrieving Healthz"] end puts "#{STATUS} #{SERVICE_NAME} - #{OUTPUT_TEXT}"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
glowworm-0.3.0 | server/check_mk_checks/check_glowworm_server |