Exemple #1
0
def get_server_cache(request):
    """Cache statistic widget.

    A list of memcached statistic if available to the application.
    """
    cache_stats = get_cache_stats()
    uptime = {}

    for hosts, stats in cache_stats:
        if stats['uptime'] > 86400:
            uptime['value'] = stats['uptime'] / 60 / 60 / 24
            uptime['unit'] = _("days")
        elif stats['uptime'] > 3600:
            uptime['value'] = stats['uptime'] / 60 / 60
            uptime['unit'] = _("hours")
        else:
            uptime['value'] = stats['uptime'] / 60
            uptime['unit'] =  _("minutes")

    cache_data = {
        "cache_stats": cache_stats,
        "uptime": uptime
    }

    return {
        'size': 'widget-small',
        'template': 'admin/widgets/w-server-cache.html',
        'actions': '',
        'data': cache_data
    }
Exemple #2
0
def cache_stats(request, template_name="admin/cache_stats.html"):
    """
    Displays statistics on the cache. This includes such pieces of
    information as memory used, cache misses, and uptime.
    """
    cache_stats = get_cache_stats()

    return render_to_response(template_name, RequestContext(request, {
        'cache_hosts': cache_stats,
        'cache_backend': settings.CACHES['default']['BACKEND'],
        'title': _("Server Cache"),
        'root_path': settings.SITE_ROOT + "admin/db/"
    }))
Exemple #3
0
def cache_stats(request, template_name="admin/cache_stats.html"):
    """
    Displays statistics on the cache. This includes such pieces of
    information as memory used, cache misses, and uptime.
    """
    cache_stats = get_cache_stats()

    return render_to_response(template_name, RequestContext(request, {
        'cache_hosts': cache_stats,
        'cache_backend': settings.CACHES['default']['BACKEND'],
        'title': _("Server Cache"),
        'root_path': settings.SITE_ROOT + "admin/db/"
    }))
Exemple #4
0
    def generate_data(self, request):
        uptime = {}
        cache_stats = get_cache_stats()

        if cache_stats:
            for hosts, stats in cache_stats:
                if stats['uptime'] > 86400:
                    uptime['value'] = stats['uptime'] / 60 / 60 / 24
                    uptime['unit'] = _("days")
                elif stats['uptime'] > 3600:
                    uptime['value'] = stats['uptime'] / 60 / 60
                    uptime['unit'] = _("hours")
                else:
                    uptime['value'] = stats['uptime'] / 60
                    uptime['unit'] = _("minutes")

        return {'cache_stats': cache_stats, 'uptime': uptime}
Exemple #5
0
def cache_stats(request, template_name="admin/cache_stats.html"):
    """Display statistics on the cache.

    This includes such pieces of information as memory used, cache misses, and
    uptime.
    """
    cache_stats = get_cache_stats()
    cache_info = settings.CACHES[DEFAULT_FORWARD_CACHE_ALIAS]

    return render(request=request,
                  template_name=template_name,
                  context={
                      'cache_hosts': cache_stats,
                      'cache_backend': cache_info['BACKEND'],
                      'title': _('Server Cache'),
                      'root_path': reverse('admin:index'),
                  })
def cache_stats(request, template_name="admin/cache_stats.html"):
    """
    Displays statistics on the cache. This includes such pieces of
    information as memory used, cache misses, and uptime.
    """
    cache_stats = get_cache_stats()

    return render_to_response(
        template_name,
        RequestContext(
            request,
            {
                "cache_hosts": cache_stats,
                "cache_backend": cache.__module__,
                "title": _("Server Cache"),
                "root_path": settings.SITE_ROOT + "admin/db/",
            },
        ),
    )
Exemple #7
0
    def generate_data(self, request):
        uptime = {}
        cache_stats = get_cache_stats()

        if cache_stats:
            for hosts, stats in cache_stats:
                if stats['uptime'] > 86400:
                    uptime['value'] = stats['uptime'] / 60 / 60 / 24
                    uptime['unit'] = _("days")
                elif stats['uptime'] > 3600:
                    uptime['value'] = stats['uptime'] / 60 / 60
                    uptime['unit'] = _("hours")
                else:
                    uptime['value'] = stats['uptime'] / 60
                    uptime['unit'] =  _("minutes")

        return {
            'cache_stats': cache_stats,
            'uptime': uptime
        }
Exemple #8
0
    def generate_data(self, request):
        """Generate data for the widget."""
        uptime = {}
        cache_stats = get_cache_stats()

        if cache_stats:
            for hosts, stats in cache_stats:
                uptime_secs = stats['uptime']

                if uptime_secs > 86400:
                    uptime['value'] = uptime_secs / 60 / 60 / 24
                    uptime['unit'] = _('days')
                elif uptime_secs > 3600:
                    uptime['value'] = uptime_secs / 60 / 60
                    uptime['unit'] = _('hours')
                else:
                    uptime['value'] = uptime_secs / 60
                    uptime['unit'] = _('minutes')

        return {'cache_stats': cache_stats, 'uptime': uptime}