示例#1
0
def nagios(request):
    if not getattr(settings, 'REDIS_MONITOR_ONLY_TRACK_TOTALS', False):
        return HttpResponse(
            'nagios only available in REDIS_MONITOR_ONLY_TRACK_TOTALS mode')
    requests = get_instance('requests').get_totals()
    sqlops = get_instance('sqlops').get_totals()
    return render(
        'django_redis_monitor/nagios.xml', {
            'db_count': sqlops.get('hits', 0),
            'db_total_ms': int(int(sqlops.get('weight', 0)) / 1000.0),
            'request_count': requests.get('hits', 0),
            'request_total_ms': int(int(requests.get('weight', 0)) / 1000.0),
        })
示例#2
0
def nagios(request):
    if not getattr(settings, 'REDIS_MONITOR_ONLY_TRACK_TOTALS', False):
        return HttpResponse(
            'nagios only available in REDIS_MONITOR_ONLY_TRACK_TOTALS mode'
        )
    requests = get_instance('requests').get_totals()
    sqlops = get_instance('sqlops').get_totals()
    return render('django_redis_monitor/nagios.xml', {
        'db_count': sqlops.get('hits', 0),
        'db_total_ms': int(int(sqlops.get('weight', 0)) / 1000.0),
        'request_count': requests.get('hits', 0),
        'request_total_ms': int(int(requests.get('weight', 0)) / 1000.0),
    })
 def process_request(self, request):
     if self.should_track_request(request):
         self.tracking = True
         self.start_time = time.time()
         self.rm = get_instance('requests')
     else:
         self.tracking = False
示例#4
0
 def process_request(self, request):
     if self.should_track_request(request):
         self.tracking = True
         self.start_time = time.time()
         self.rm = get_instance('requests')
     else:
         self.tracking = False
示例#5
0
def monitor(request):
    requests = get_instance('requests')
    sqlops = get_instance('sqlops')
    if getattr(settings, 'REDIS_MONITOR_ONLY_TRACK_TOTALS', False):
        return render('django_redis_monitor/monitor_totals_only.html', {
            'requests': requests.get_totals(),
            'sqlops': sqlops.get_totals(),
        })
    else:
        return render('django_redis_monitor/monitor.html', {
            'requests': reversed(
                list(requests.get_recent_hits_per_second(minutes = 10))
            ),
            'sqlops': reversed(
                list(sqlops.get_recent_hits_per_second(minutes = 10))
            ),
        })
示例#6
0
def monitor(request):
    requests = get_instance('requests')
    sqlops = get_instance('sqlops')
    if getattr(settings, 'REDIS_MONITOR_ONLY_TRACK_TOTALS', False):
        return render('django_redis_monitor/monitor_totals_only.html', {
            'requests': requests.get_totals(),
            'sqlops': sqlops.get_totals(),
        })
    else:
        return render(
            'django_redis_monitor/monitor.html', {
                'requests':
                reversed(list(
                    requests.get_recent_hits_per_second(minutes=10))),
                'sqlops':
                reversed(list(sqlops.get_recent_hits_per_second(minutes=10))),
            })
 def execute(self, sql, params=()):
     if is_sampling_request():
         start = time.time()
         self.rm = get_instance('sqlops')
         try:
             return self.cursor.execute(sql, params)
         finally:
             stop = time.time()
             duration_in_microseconds = int(1000000 * (stop - start))
             try:
                 self.rm.record_hit_with_weight(duration_in_microseconds)
             except Exception, e:
                 pass #logging.warn('RedisMonitor error: %s' % str(e))
示例#8
0
 def __init__(self, cursor, db):
     self.cursor = cursor
     self.db = db
     self.rm = get_instance('sqlops')
 def __init__(self, cursor, db):
     self.cursor = cursor
     self.db = db
     self.rm = get_instance('sqlops')