2 # vim:fileencoding=utf-8
6 from google
.appengine
.api
import memcache
7 from google
.appengine
.api
import mail
8 from google
.appengine
.ext
import webapp
9 from google
.appengine
.ext
.webapp
.util
import run_wsgi_app
11 class Stat(webapp
.RequestHandler
):
13 time
= datetime
.datetime
.now() - datetime
.timedelta(hours
=1)
14 time
= time
.strftime('%Y-%m-%d_%H')
16 for type in ('message', 'presence'):
17 count
= memcache
.get('%s_%s' % (type, time
))
20 msg
.append('%s: %s' % (type, count
))
22 mail
.send_mail(sender
='"GAE stat" <stat@%s.appspotmail.com>' % config
.appid
,
23 to
="Admin <%s>" % config
.root
,
24 subject
="Stats for %s in %s" % (config
.appid
, time
),
26 self
.response
.out
.write(u
'OK.'.encode('utf-8'))
28 application
= webapp
.WSGIApplication(
30 ('/_admin/stat', Stat
),
35 run_wsgi_app(application
)
37 if __name__
== "__main__":