#!/usr/bin/python -u # -*- coding: utf-8 -*- import cgi import cgitb import os import sys import resource import time # HTML Debug of errors cgitb.enable() # Limit maximum CPU time # The Postscript output format can sometimes take hours resource.setrlimit(resource.RLIMIT_CPU,(180,180)) # Limit memory usage # Some odd requests can cause extreme memory usage resource.setrlimit(resource.RLIMIT_AS,(4000000000, 4000000000)) # Routine to output HTTP headers def output_headers(content_type, filename = "", length = 0): print "Cache-Control: no-cache, no-store, must-revalidate')" print "Pragma: no-cache" print "Expires: 0" print "Content-Type: %s" % content_type if filename: print "Content-Disposition: attachment; filename=\"%s\"" % filename if length: print "Content-Length: %d" % length print "" # Routine to report an error def output_error(message): output_headers("text/html") print "" print "" print "Error" print "" print "" print "

Error

" print "

%s

" % message print "" print "" # Make sure we have a user agent if not os.environ.has_key('HTTP_USER_AGENT'): os.environ['HTTP_USER_AGENT'] = 'NONE' # Get the load average loadavg = float(open("/proc/loadavg").readline().split(" ")[0]) output_headers("text/html") print "" print "" print "tile.openstreetmap.org debug" print "" print "" print "

tile.openstreetmap.org debug

" print "

Server Stats

" print "

" print "Render Server: <%= node['fqdn'] %>
" print "Load Average: %s

" % loadavg print "

File Status

" print "

" <% node[:tile][:data].each do |name,data| url = data[:url] file = "/srv/tile.openstreetmap.org/data/#{File.basename(url)}" file_basename = File.basename(url) -%> print "%s last modified: %s
" % ("<%= file_basename %>", time.ctime(os.path.getmtime("<%= file %>"))) <% end -%> print "

" print "

Browser Request Headers

" print "

" for param in os.environ.keys(): print "%20s: %s
" % (param, os.environ[param]) print "

" print "" print ""