django-restit 4.2.107__py3-none-any.whl → 4.2.110__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.
- {django_restit-4.2.107.dist-info → django_restit-4.2.110.dist-info}/METADATA +1 -1
- {django_restit-4.2.107.dist-info → django_restit-4.2.110.dist-info}/RECORD +9 -9
- metrics/providers/aws.py +2 -2
- metrics/rpc.py +15 -16
- rest/__init__.py +1 -1
- rest/extra/hostinfo.py +36 -2
- rest/rpc.py +10 -0
- {django_restit-4.2.107.dist-info → django_restit-4.2.110.dist-info}/LICENSE.md +0 -0
- {django_restit-4.2.107.dist-info → django_restit-4.2.110.dist-info}/WHEEL +0 -0
@@ -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=
|
358
|
-
metrics/rpc.py,sha256=
|
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
|
@@ -374,7 +374,7 @@ pushit/utils.py,sha256=IeTCGa-164nmB1jIsK1lu1O1QzUhS3BKfuXHGjCW-ck,2121
|
|
374
374
|
rest/.gitignore,sha256=TbEvWRMnAiajCTOdhiNrd9eeCAaIjRp9PRjE_VkMM5g,118
|
375
375
|
rest/README.md,sha256=V3ETc-cJu8PZIbKr9xSe_pA4JEUpC8Dhw4bQeVCDJPw,5460
|
376
376
|
rest/RemoteEvents.py,sha256=nL46U7AuxIrlw2JunphR1tsXyqi-ep_gD9CYGpYbNgE,72
|
377
|
-
rest/__init__.py,sha256=
|
377
|
+
rest/__init__.py,sha256=tkKkxuntg_NNk2IluEC5jeaier2km2CgtVoFK5ThB-c,122
|
378
378
|
rest/arc4.py,sha256=y644IbF1ec--e4cUJ3KEYsewTCITK0gmlwa5mJruFC0,1967
|
379
379
|
rest/cache.py,sha256=1Qg0rkaCJCaVP0-l5hZg2CIblTdeBSlj_0fP6vlKUpU,83
|
380
380
|
rest/crypto/__init__.py,sha256=Tl0U11rgj1eBYqd6OXJ2_XSdNLumW_JkBZnaJqI6Ldw,72
|
@@ -386,7 +386,7 @@ rest/decorators.py,sha256=ig0LATc3-2mhEJPAWHRbIRM-ZOFyjm6e_F9RhpRWidE,15082
|
|
386
386
|
rest/encryption.py,sha256=x6Kiez0tVqfxK26MSsRL3k8OS05ni1gEX2aj3I0S9V0,788
|
387
387
|
rest/errors.py,sha256=uKwG9OkLme36etabqK54DMjMQc1fgEoUIAUxXa7WFQw,612
|
388
388
|
rest/extra/__init__.py,sha256=YzmNsch5H5FFLkUK9mIAKyoRK_rJCA9HGb0kubp4h30,54
|
389
|
-
rest/extra/hostinfo.py,sha256=
|
389
|
+
rest/extra/hostinfo.py,sha256=LFigr90B-NU6MkaYDNj7fwfqJVuu9UP1InZMky4kH58,4041
|
390
390
|
rest/extra/json_metadata.py,sha256=p_ffzmANmOFix_oC3voR6_NNTjcn7-T7aXcH-I4_Npg,1078
|
391
391
|
rest/fields.py,sha256=_v1TJVc6vyWlqmwFRJ6mtuR5Fo-lS0KcUhPWIrzKZUo,9719
|
392
392
|
rest/forms.py,sha256=66Wm5cdy8tKib_mGicjq_yd-gNVMFWRECnrDksnNnwU,6316
|
@@ -413,7 +413,7 @@ rest/models/metadata.py,sha256=1nQ7CYo9bJHoaXE_hVNaj1-Y7yqhHlf2ZlaD1IfTzic,12904
|
|
413
413
|
rest/net.py,sha256=LcB2QV6VNRtsSdmiQvYZgwQUDwOPMn_VBdRiZ6OpI-I,2974
|
414
414
|
rest/regexes.yaml,sha256=VoGb4E-P_K9f82Yzcpltgzekpt9usRtwu9PYlo46nUw,149463
|
415
415
|
rest/requestex.py,sha256=N56056vV3zWkAP-QrYsCu7SdpPzE5kLuPoxGIuZAKt0,16127
|
416
|
-
rest/rpc.py,sha256=
|
416
|
+
rest/rpc.py,sha256=wCR22Ds4CgZ9q-ptWuIpc15J01tTRPpAYWEkAA9LDHM,2205
|
417
417
|
rest/search.py,sha256=QVjk2b5tZLgf1zM2MHvJTyRjwUbY5ZD7HXSTmSPXtvU,8362
|
418
418
|
rest/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
419
419
|
rest/serializers/collection.py,sha256=V9O4qxw26VX9dSYdbsN0-RNnXEi347Ln8eFLZ003LhA,4646
|
@@ -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.
|
513
|
-
django_restit-4.2.
|
514
|
-
django_restit-4.2.
|
515
|
-
django_restit-4.2.
|
512
|
+
django_restit-4.2.110.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
|
513
|
+
django_restit-4.2.110.dist-info/METADATA,sha256=TNwT_yHAFrvDOePQCeCcz0eNaUjVtnf9OMFSHv5CLKM,7663
|
514
|
+
django_restit-4.2.110.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
515
|
+
django_restit-4.2.110.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
|
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
|
-
|
391
|
-
period=
|
392
|
-
duration_seconds=
|
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
|
|
rest/__init__.py
CHANGED
rest/extra/hostinfo.py
CHANGED
@@ -25,13 +25,47 @@ def getTcpEstablishedCount():
|
|
25
25
|
return len(getTcpEstablished())
|
26
26
|
|
27
27
|
|
28
|
-
def getTcpEstablished():
|
28
|
+
def getTcpEstablished(filter=None):
|
29
29
|
cons = psutil.net_connections(kind="tcp")
|
30
30
|
established = []
|
31
31
|
for c in cons:
|
32
32
|
if c.status == "ESTABLISHED":
|
33
33
|
established.append(c)
|
34
|
-
return established
|
34
|
+
return filterConnections(established, filter)
|
35
|
+
|
36
|
+
|
37
|
+
def filterConnections(cons, filter):
|
38
|
+
if filter == "https":
|
39
|
+
return [c for c in cons if cons.laddr.port == 443]
|
40
|
+
elif filter == "redis":
|
41
|
+
return [c for c in cons if cons.raddr.port == 6379]
|
42
|
+
elif filter == "postgres":
|
43
|
+
return [c for c in cons if cons.raddr.port == 5432]
|
44
|
+
elif filter == "unknown":
|
45
|
+
return [c for c in cons if cons.raddr.port not in [5432, 6379] and cons.laddr.port != 443]
|
46
|
+
return cons
|
47
|
+
|
48
|
+
|
49
|
+
def consToDict(cons):
|
50
|
+
out = []
|
51
|
+
cid = 0
|
52
|
+
for c in cons:
|
53
|
+
cid += 1
|
54
|
+
out.append({
|
55
|
+
"id": cid,
|
56
|
+
"type": c.type.name,
|
57
|
+
"status": c.status,
|
58
|
+
"family": c.family.name,
|
59
|
+
"raddr": {
|
60
|
+
"port": c.raddr.port,
|
61
|
+
"ip": c.raddr.ip
|
62
|
+
},
|
63
|
+
"laddr": {
|
64
|
+
"port": c.laddr.port,
|
65
|
+
"ip": c.laddr.ip
|
66
|
+
}
|
67
|
+
})
|
68
|
+
return out
|
35
69
|
|
36
70
|
|
37
71
|
def getVersions(out=None):
|
rest/rpc.py
CHANGED
@@ -60,3 +60,13 @@ def on_get_system_info(request):
|
|
60
60
|
include_blocked=request.DATA.get("blocked"))
|
61
61
|
return views.restGet(request, out)
|
62
62
|
|
63
|
+
|
64
|
+
@url('system/cons')
|
65
|
+
def on_get_system_cons(request):
|
66
|
+
key = request.DATA.get("key")
|
67
|
+
if SYS_INFO_KEY is None or key != SYS_INFO_KEY:
|
68
|
+
if not ALLOW_PUBLIC_SYS_INFO and not request.user.is_authenticated:
|
69
|
+
return views.restPermissionDenied(request, "system info is not public", 565)
|
70
|
+
cons = hostinfo.getTcpEstablished(filter=request.DATA.get("filter"))
|
71
|
+
return views.restList(request, hostinfo.consToDict(cons))
|
72
|
+
|
File without changes
|
File without changes
|