Commits

Martin Mahner  committed 95f741f

Initial data commit.

  • Participants
  • Parent commits a210db5

Comments (0)

Files changed (6)

 ======================
 django-memcache-status
-======================
+======================
+
+This app displays the current load and some statistics for your memcached_
+instances. At this time it's only tested with *Django 1.1* (django-trunk).
+
+Installation
+============
+
+Put ``memcache_status`` in your ``INSTALLED_APPS``. That's all.
+
+Screenshots
+===========
+
+.. image:: http://cloud.github.com/downloads/bartTC/django-memcache-status/memcache_status_1.png
+
+Overview
+
+.. image:: http://cloud.github.com/downloads/bartTC/django-memcache-status/memcache_status_2.png
+
+Details if you click on a instance
+
+
+.. _memcached: http://www.danga.com/memcached/

File memcache_status/__init__.py

Empty file added.

File memcache_status/admin.py

+from django.contrib import admin
+
+admin.site.index_template = 'memcache_status/index.html'

File memcache_status/templates/memcache_status/index.html

+{% extends "admin/index.html" %}
+
+{% load memcache_status_tags %}
+
+{% block extrahead %}
+<style type="text/css">
+div.cache_stats{
+    margin: 1em 0 2em 0;
+}
+
+div.cache_stats table{
+    width: 100%
+}
+
+div.cache_stats table tbody th,
+div.cache_stats table tbody td{
+    width: 50% !important;
+}
+
+div.cache_stats table tbody th{
+    text-align: right;
+}
+
+div.cache_stats tbody{
+    display: none;
+}
+
+div.cache_graph{
+    height: 1em;
+    width: 100%;
+    background-color: #BEEE37;
+    -webkit-box-shadow: 0.1em 0.1em 0.2em #aaa;
+    -moz-box-shadow: 0.1em 0.1em 0.2em #aaa;
+}
+
+div.cache_graph_value{
+    height: 1em;
+    background-color: #E84A2F;
+}
+
+</style>
+{% endblock %}
+
+{% block content %}
+    {% if request.user.is_superuser %}
+    <div class="cache_stats">
+    {% get_cache_stats %}
+    {% for server in cache_stats %}
+    <div class="module">
+        <table>
+        <caption>
+            <a href="#" class="section" onclick="
+                var elem = document.getElementById('cache{{ forloop.counter }}');
+                if(elem.style.display == 'none'){
+                    elem.style.display = 'table-row-group';
+                }else{
+                    elem.style.display = 'none';
+                }
+                return false;
+            ">memcached: {{ server.0 }} - {% widthratio server.1.bytes server.1.limit_maxbytes 100 %}% load</a>
+        </caption>
+        <thead>
+        <tr><td colspan="2">
+            <div class="cache_graph">
+            <div class="cache_graph_value" style="width: {% widthratio server.1.bytes server.1.limit_maxbytes 100 %}%"></div>
+            </div>
+        </td></tr>
+        </thead>
+        <tbody id="cache{{ forloop.counter }}">
+        {% for k,v in server.1.items %}
+        <tr><th>{{ k }}</th><td>{{ v }}</td></tr>
+        {% endfor %}
+        </tbody>
+        </table>
+    </div>
+    {% endfor %}
+    </div>
+    {% endif %}
+
+    {{ block.super }}
+{% endblock %}

File memcache_status/templatetags/__init__.py

Empty file added.

File memcache_status/templatetags/memcache_status_tags.py

+from django import template
+from django.core.cache import cache
+
+register = template.Library()
+
+class CacheStats(template.Node):
+    def render(self, context):
+        context['cache_stats'] = sorted(cache._cache.get_stats())
+        return ''
+
+@register.tag
+def get_cache_stats(parser, token):
+    return CacheStats()