Ejemplo n.º 1
0
 def metrics(self, request):
     # try:
     metric = request.GET.get('metric') or 'cpu_usage'
     period = request.GET.get('period') or '1hour'
     visitor = Visitor()
     pf_cls = PlatformData(metric=metric, timestamp=period, monitor_type='hosts')
     pf_data = visitor.visit(pf_cls)
     # logging.info('metirc:  ' + str(pf_data))
     # logging.info('final data:  ' + str(pf_data))
     return Response(pf_data)
Ejemplo n.º 2
0
 def metrics(self, request, user_id):
     try:
         user = self.queryset.get(user_id=user_id)
         metric = request.GET.get('metric') or 'cpu_usage'
         period = request.GET.get('period') or '1hour'
         visitor = Visitor()
         user_cls = UserData(target=user_id, metric=metric, timestamp=period, monitor_type='user')
         user_data = visitor.visit(user_cls)
         return Response(user_data)
     except models.MisUmuser.DoesNotExist:
         raise Http404
Ejemplo n.º 3
0
 def metrics(self, request, fixed_ip):
     try:
         vm = self.queryset.get(fixed_ip=fixed_ip)
         metric = request.GET.get('metric') or 'cpu_usage'
         period = request.GET.get('period') or '1hour'
         visitor = Visitor()
         vm_cls = VMData(target=fixed_ip, metric=metric, timestamp=period, monitor_type='vm')
         vm_data = visitor.visit(vm_cls)
         return Response(vm_data)
     except:
         raise Http404
Ejemplo n.º 4
0
 def metrics(self, request, org_id):
     try:
         depart = self.queryset.get(org_id=org_id)
         metric = request.GET.get('metric') or 'cpu_usage'
         period = request.GET.get('period') or '1hour'
         visitor = Visitor()
         depart_cls = DepartData(target=org_id, metric=metric, timestamp=period, monitor_type='org')
         depart_data = visitor.visit(depart_cls)
         return Response(depart_data)
     except models.MisUmorg.DoesNotExist:
         raise Http404