Skip to content
Browse files

add /?format=csv for easy monitoring

  • Loading branch information...
1 parent b097757 commit 1df408cd31f307d55369f8b8f66301d8d74d3b44 @posativ committed Nov 10, 2012
Showing with 9 additions and 3 deletions.
  1. +1 −1 regenwolken/templates/index.html
  2. +8 −2 regenwolken/views.py
View
2 regenwolken/templates/index.html
@@ -11,7 +11,7 @@
<ul style="list-style-type: none;">
<li>Users: {{ users }}</li>
<li>Files: {{ files }}</li>
- <li>Size : {{ size }}</li>
+ <li>Size : {{ size | filesizeformat }}</li>
<li>Hits : {{ hits }}</li>
</ul>
<p>– <a href="https://github.com/posativ/regenwolken#readme">See
View
10 regenwolken/views.py
@@ -14,7 +14,7 @@
from pymongo import DESCENDING
from flask import request, abort, jsonify, json, current_app, render_template, redirect
-from regenwolken.utils import login, private, A1, slug, thumbnail, clear, urlscheme, ppsize
+from regenwolken.utils import login, private, A1, slug, thumbnail, clear, urlscheme
from regenwolken.specs import Item, Account, Drop
@@ -50,10 +50,16 @@ def index():
else:
return jsonify(Item(obj, config, urlscheme(request)))
else:
+
users = db.accounts.find().count()
files = fs.gfs._GridFS__files.count()
- size = ppsize(sum([f['length'] for f in fs.gfs._GridFS__files.find()]))
+ size = sum([f['length'] for f in fs.gfs._GridFS__files.find()])
hits = sum([f['view_counter'] for f in fs.mdb.find()])
+
+ if request.args.get('format') == 'csv':
+ fields = [('users', users), ('files', files), ('size', size), ('hits', hits)]
+ return Response('\n'.join('%s,%s' % field for field in fields), 200)
+
return Response(render_template("index.html", **locals()), 200, content_type="text/html")

0 comments on commit 1df408c

Please sign in to comment.
Something went wrong with that request. Please try again.