def ItemListView(request): context = {} context["methods"] = methods context["symbols"] = symbols context["dts"] = ("GAUGE","COUNTER","DERIVE") service_id = request.GET.get("service_id") host_id = request.GET.get("host_id") template_id = request.GET.get("template_id") context["service"] = service.objects.get(pk=int(service_id)) q = request.GET.get("q") page = request.GET.get("page") if not page: page = 1 if host_id: context["host"] = context["service"].host if template_id: context["template"] = context["service"].template context["items"] = context["service"].item_set.all().order_by('key') if q: context["items"] = context["items"].filter( Q(key__contains=q) ) context["items"] = paging(context["items"], page, settings.PAGE_SIZE) return render_to_response( "host/item_list.html", context , context_instance=RequestContext(request) )
def DashBoard(request): context = {} page = request.GET.get("page") q = request.GET.get("q") if not page: page = 1 queryset = graph.objects.filter(user__username__exact=request.user.username) if q: for qs in q.split(" "): queryset = queryset.filter(Q(title__contains=qs)) context["graphs"] = paging(queryset, page, 3) return render_to_response("graph/dashboard.html", context, context_instance=RequestContext(request))
def GraphListView(request): context = {} page = request.GET.get("page") q = request.GET.get("q") if not page: page = 1 if request.user.is_superuser: queryset = graph.objects.all() else: queryset = graph.objects.filter(user__username__exact=request.user.username) if q: queryset = queryset.filter(Q(title__contains=q)) context["graphs"] = paging(queryset, page, 5) return render_to_response("graph/graph_list.html", context, context_instance=RequestContext(request))
def MetricListView(request): context = {} graph_id = request.GET.get("graph_id") context["graph"] = graph.objects.get(pk=int(graph_id)) context["metrics"] = context["graph"].metric_set.all() if not request.user.is_superuser and context["graph"].user != request.user: return HttpResponse("权限拒绝") page = request.GET.get("page") q = request.GET.get("q") if not page: page = 1 if q: context["metrics"] = context["metrics"].filter(Q(metric__contains=q)) context["metrics"] = paging(context["metrics"], page, settings.PAGE_SIZE) return render_to_response("graph/metric_list.html", context, context_instance=RequestContext(request))
def DashBoard(request): context = {} page = request.GET.get("page") q = request.GET.get("q") if not page: page = 1 queryset = graph.objects.filter( user__username__exact=request.user.username) if q: for qs in q.split(" "): queryset = queryset.filter(Q(title__contains=qs)) context["graphs"] = paging(queryset, page, 3) return render_to_response("graph/dashboard.html", context, context_instance=RequestContext(request))
def GraphListView(request): context = {} page = request.GET.get("page") q = request.GET.get("q") if not page: page = 1 if request.user.is_superuser: queryset = graph.objects.all() else: queryset = graph.objects.filter( user__username__exact=request.user.username) if q: queryset = queryset.filter(Q(title__contains=q)) context["graphs"] = paging(queryset, page, 5) return render_to_response("graph/graph_list.html", context, context_instance=RequestContext(request))
def InterfaceListView(request): context = {} device_id = request.GET.get("device_id") q = request.GET.get("q") page = request.GET.get("page") if not page: page = 1 if request.method == "GET": context["device"] = device.objects.get(pk=int(device_id)) context["interfaces"] = context["device"].interface_set.all().order_by("-status", "index") if q: context["interfaces"] = context["interfaces"].filter( Q(name__contains=q) ) context["interfaces"] = paging(context["interfaces"], page, settings.PAGE_SIZE) return render_to_response( "network/interfaces_list.html", context, context_instance = RequestContext(request) )
def HostListView(request): context = {} q = request.GET.get("q") page = request.GET.get("page") if not page: page = 1 queryset=None if q: queryset = host.objects.filter( Q(ip__contains=q)| Q(server__sn__contains=q)| Q(server__cabinet__name__contains=q)| Q(group__name__contains=q) ) else: queryset = host.objects.all().order_by('-status', '-alarm', '-c_time') context["hosts"] = paging(queryset.distinct(), page, settings.PAGE_SIZE) return render_to_response( "host/host_list.html", context , context_instance=RequestContext(request) )
def DeviceListView(request): context = {} context["proxys"] = proxy.objects.all() context["cabinets"] = cabinet.objects.all() context["units"] = [1,2,3,4] context["devices"] = device.objects.all() q =request.GET.get("q") page = request.GET.get("page") if not page: page =1 if q: context["devices"]=context["devices"].filter( Q(ip__contains=q)| Q(sn__contains=q)| Q(cabinet__name__contains=q)| Q(model__contains=q) ) context["devices"] = paging(context["devices"], page, settings.PAGE_SIZE) return render_to_response( "network/device_list.html", context, context_instance = RequestContext(request) )
def ServiceListView(request): context = {} host_id = request.GET.get("host_id") template_id = request.GET.get("template_id") page = request.GET.get("page") q = request.GET.get("q") if not page: page = 1 if host_id: context["host"] = host.objects.get(pk=int(host_id)) queryset = context["host"].service_set.all() else: context["template"] = template.objects.get(pk=int(template_id)) queryset = context["template"].service_set.all() if q: queryset = queryset.filter( Q(name__contains = q.strip()) ) context["services"] = paging(queryset, page, settings.PAGE_SIZE) return render_to_response( "host/service_list.html", context , context_instance=RequestContext(request) )