django-restit 4.2.107__py3-none-any.whl → 4.2.108__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-restit
3
- Version: 4.2.107
3
+ Version: 4.2.108
4
4
  Summary: A Rest Framework for DJANGO
5
5
  License: MIT
6
6
  Author: Ian Starnes
@@ -354,8 +354,8 @@ metrics/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
354
354
  metrics/models.py,sha256=lD9nVzfwdav70ENulqJ8rE8Ui8EWlzdVp05rg8bAlMA,13444
355
355
  metrics/periodic.py,sha256=VmL0YG05D6k5fcNsF4QqPEU-BBPbZXjbOrp3b8EHZ-U,651
356
356
  metrics/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
357
- metrics/providers/aws.py,sha256=vhz0w6xE_V_V050g3V2uKEUPRIaI_o48MFkfsHjLzQU,8307
358
- metrics/rpc.py,sha256=yIv1ZVnlY_RYI693pX5iptH3gnVAC1DQ2nJQ5vLZQyw,21657
357
+ metrics/providers/aws.py,sha256=dIBGFE1Fvszy6rmVrn_Fm1zUDv345q4dBsg9Iit-XCc,8358
358
+ metrics/rpc.py,sha256=LXZcYBtssSFmcaoIjaJ32S6Nv_mswDALtmUYm5ByDMQ,21667
359
359
  metrics/settings.py,sha256=wwHA9Z7BAHNeu3tFVn8Fh5j46KR-eGx0E8r5dzCFlAU,132
360
360
  metrics/tq.py,sha256=WHBRYSinmTuxF9l-_-lx0yfzEYkb0ffVMt_uvCj9bYo,825
361
361
  metrics/utils.py,sha256=PSydxeI983udULUTcbeWG-_ulPSOac6Q_t_8k_Vjn1I,12606
@@ -509,7 +509,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
509
509
  ws4redis/settings.py,sha256=K0yBiLUuY81iDM4Yr-k8hbvjn5VVHu5zQhmMK8Dtz0s,1536
510
510
  ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
511
511
  ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
512
- django_restit-4.2.107.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
513
- django_restit-4.2.107.dist-info/METADATA,sha256=lqLjoZ72QKedFUqZbUcmLjrh8GM7Ja1AkBdJy5VSa8Y,7663
514
- django_restit-4.2.107.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
515
- django_restit-4.2.107.dist-info/RECORD,,
512
+ django_restit-4.2.108.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
513
+ django_restit-4.2.108.dist-info/METADATA,sha256=xjyg7k6U0iPx-OAcb3QmgJzKIMK_cRecySSJJvmlH8w,7663
514
+ django_restit-4.2.108.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
515
+ django_restit-4.2.108.dist-info/RECORD,,
metrics/providers/aws.py CHANGED
@@ -87,7 +87,7 @@ def pushMetric(name, value, unit="Count", instance=None):
87
87
 
88
88
  def buildQuery(id, instance, period=300, metric="cpu", namespace="rds", stat="max"):
89
89
  dname = "DBInstanceIdentifier"
90
- if namespace == "ec2":
90
+ if namespace in ["ec2", "CustomMetrics"]:
91
91
  dname = "InstanceId"
92
92
  elif namespace == "redis":
93
93
  dname = "CacheClusterId"
@@ -120,7 +120,7 @@ def getMetrics(instances, period=300, duration_seconds=900, metric="cpu", namesp
120
120
 
121
121
  def getMetricsList(instance, namespace="rds"):
122
122
  dname = "DBInstanceIdentifier"
123
- if namespace == "ec2":
123
+ if namespace == "ec2" or namespace == "CustomMetrics":
124
124
  dname = "InstanceId"
125
125
  cloudwatch = getClient(service="cloudwatch")
126
126
  response = cloudwatch.list_metrics(
metrics/rpc.py CHANGED
@@ -366,19 +366,6 @@ def rest_on_ec2_metrics_cpu(request):
366
366
  if i.id in data:
367
367
  output[i.name] = data[i.id]
368
368
  output[i.name].reverse()
369
- # if get_rds:
370
- # ids = aws.getAllRDS(True)
371
- # rds_cpu = (aws.getMetrics(
372
- # ids,
373
- # period=period,
374
- # duration_seconds=duration,
375
- # metric="cpu",
376
- # namespace="rds",
377
- # stat="max"))
378
- # for k, v in rds_cpu.items():
379
- # v.reverse()
380
- # output.update(rds_cpu)
381
-
382
369
  data = dict(data=output, periods=getPeriods(period, duration))
383
370
  return rv.restReturn(request, dict(data=data))
384
371
 
@@ -386,13 +373,25 @@ def rest_on_ec2_metrics_cpu(request):
386
373
  @rd.urlGET('aws/ec2/network/established')
387
374
  @rd.requires_params(["ids"])
388
375
  def rest_on_ec2_metrics_net_established(request):
376
+ ids = request.DATA.getlist("ids")
377
+ period = request.DATA.get("period", 300, field_type=int)
378
+ duration = request.DATA.get("duration", period*8, field_type=int)
379
+ instances = aws.getAllEC2()
380
+ if "all" in ids:
381
+ ids = [inst.id for inst in instances]
389
382
  data = aws.getMetrics(
390
- request.DATA.getlist("ids"),
391
- period=request.DATA.get("period", 300, field_type=int),
392
- duration_seconds=request.DATA.get("duration", 900, field_type=int),
383
+ ids,
384
+ period=period,
385
+ duration_seconds=duration,
393
386
  metric="EstablishedConnections",
394
387
  namespace="CustomMetrics",
395
388
  stat="max")
389
+ output = dict()
390
+ for i in instances:
391
+ if i.id in data:
392
+ output[i.name] = data[i.id]
393
+ output[i.name].reverse()
394
+ data = dict(data=output, periods=getPeriods(period, duration))
396
395
  return rv.restReturn(request, dict(data=data))
397
396
 
398
397