-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadpPointTest.py
57 lines (40 loc) · 11.3 KB
/
adpPointTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from dmonpoint import *
import datetime
# testWatcher = AdpPoint('85.120.206.27')
#
#
# print testWatcher.watcherInfo()
test = {'free_slave1': {1477561840000: 292937728.0, 1477561880000: 285921280.0, 1477561930000: 270848000.0, 1477562050000: 261517312.0, 1477562000000: 274919424.0, 1477561950000: 270499840.0, 1477561860000: 287571968.0, 1477561990000: 277430272.0, 1477561970000: 268066816.0, 1477562060000: 261300224.0, 1477561870000: 287920128.0, 1477562010000: 270602240.0, 1477561960000: 268353536.0, 1477561910000: 259362816.0, 1477561800000: 295542784.0, 1477561940000: 270782464.0, 1477562070000: 261234688.0, 1477561810000: 293310464.0, 1477562020000: 270422016.0, 1477561890000: 285839360.0, 1477561920000: 272781312.0, 1477562080000: 261185536.0, 1477561900000: 277942272.0, 1477561850000: 291295232.0, 1477562030000: 268972032.0, 1477561980000: 277131264.0, 1477561820000: 292610048.0, 1477561830000: 291241984.0, 1477562090000: 260681728.0, 1477562040000: 262090752.0}, 'shortterm_master': {1477561840000: 0.01, 1477561880000: 0.0, 1477561930000: 0.040000000000000001, 1477562050000: 0.01, 1477562000000: 0.01, 1477561950000: 0.029999999999999999, 1477561860000: 0.0, 1477561990000: 0.02, 1477561970000: 0.02, 1477562060000: 0.0, 1477561870000: 0.0, 1477562010000: 0.01, 1477561960000: 0.029999999999999999, 1477561910000: 0.059999999999999998, 1477561800000: 0.01, 1477561940000: 0.040000000000000001, 1477562070000: 0.0, 1477561810000: 0.01, 1477562020000: 0.01, 1477561890000: 0.080000000000000002, 1477561920000: 0.050000000000000003, 1477562080000: 0.0, 1477561900000: 0.070000000000000007, 1477561850000: 0.0, 1477562030000: 0.01, 1477561980000: 0.02, 1477561820000: 0.01, 1477561830000: 0.01, 1477562090000: 0.0, 1477562040000: 0.01}, 'free_slave3': {1477561840000: 2775625728.0, 1477561880000: 2788417536.0, 1477561930000: 2786336768.0, 1477562050000: 2776641536.0, 1477562000000: 2779774976.0, 1477561950000: 2784944128.0, 1477561860000: 2775887872.0, 1477561990000: 2777755648.0, 1477561970000: 2780868608.0, 1477562060000: 2776449024.0, 1477561870000: 2775953408.0, 1477562010000: 2779881472.0, 1477561960000: 2782715904.0, 1477561910000: 2788425728.0, 1477561800000: 2794987520.0, 1477561940000: 2785345536.0, 1477562070000: 3296321536.0, 1477561810000: 2792759296.0, 1477562020000: 2779656192.0, 1477561890000: 2788331520.0, 1477561920000: 2786435072.0, 1477562080000: 2953306112.0, 1477561900000: 2788438016.0, 1477561850000: 2776104960.0, 1477562030000: 2778222592.0, 1477561980000: 2779754496.0, 1477561820000: 2792468480.0, 1477561830000: 2775904256.0, 1477562090000: 2933829632.0, 1477562040000: 2778767360.0}, 'free_slave2': {1477561840000: 4367798272.0, 1477561880000: 4324278272.0, 1477561930000: 4326248448.0, 1477562050000: 4311019520.0, 1477562000000: 4315004928.0, 1477561950000: 4321456128.0, 1477561860000: 4344754176.0, 1477561990000: 4317200384.0, 1477561970000: 4319621120.0, 1477562060000: 4309491712.0, 1477561870000: 4343193600.0, 1477562010000: 4315000832.0, 1477561960000: 4321263616.0, 1477561910000: 4325994496.0, 1477561800000: 4412100608.0, 1477561940000: 4323360768.0, 1477562070000: 4313718784.0, 1477561810000: 4409942016.0, 1477562020000: 4312748032.0, 1477561890000: 4328116224.0, 1477561920000: 4325928960.0, 1477562080000: 4311556096.0, 1477561900000: 4325998592.0, 1477561850000: 4367757312.0, 1477562030000: 4313444352.0, 1477561980000: 4317331456.0, 1477561820000: 4370337792.0, 1477561830000: 4370509824.0, 1477562090000: 4311781376.0, 1477562040000: 4311597056.0}, 'midterm_slave2': {1477561840000: 1.98, 1477561880000: 1.99, 1477561930000: 1.99, 1477562050000: 1.99, 1477562000000: 2.0, 1477561950000: 2.0, 1477561860000: 1.98, 1477561990000: 2.0, 1477561970000: 2.0, 1477562060000: 1.99, 1477561870000: 1.99, 1477562010000: 2.0, 1477561960000: 2.0, 1477561910000: 1.99, 1477561800000: 1.98, 1477561940000: 2.0, 1477562070000: 1.99, 1477561810000: 1.98, 1477562020000: 1.99, 1477561890000: 1.99, 1477561920000: 1.99, 1477562080000: 1.99, 1477561900000: 1.99, 1477561850000: 1.98, 1477562030000: 1.99, 1477561980000: 2.0, 1477561820000: 1.98, 1477561830000: 1.98, 1477562090000: 2.0, 1477562040000: 1.99}, 'free_slave4': {1477561840000: 3246813184.0, 1477561880000: 3244154880.0, 1477561930000: 3218280448.0, 1477562050000: 3206406144.0, 1477562000000: 3212689408.0, 1477561950000: 3214737408.0, 1477561860000: 3244240896.0, 1477561990000: 3212181504.0, 1477561970000: 3211563008.0, 1477562060000: 3202109440.0, 1477561870000: 3244240896.0, 1477562010000: 3211440128.0, 1477561960000: 3213754368.0, 1477561910000: 3228971008.0, 1477561800000: 3248189440.0, 1477561940000: 3218604032.0, 1477562070000: 3193905152.0, 1477561810000: 3247140864.0, 1477562020000: 3209576448.0, 1477561890000: 3238490112.0, 1477561920000: 3219488768.0, 1477562080000: 3185516544.0, 1477561900000: 3238723584.0, 1477561850000: 3246465024.0, 1477562030000: 3207520256.0, 1477561980000: 3212148736.0, 1477561820000: 3247345664.0, 1477561830000: 3247083520.0, 1477562090000: 3170959360.0, 1477562040000: 3208790016.0}, 'midterm_slave1': {1477561840000: 2.0899999999999999, 1477561880000: 2.0800000000000001, 1477561930000: 2.0800000000000001, 1477562050000: 2.23, 1477562000000: 2.1499999999999999, 1477561950000: 2.1099999999999999, 1477561860000: 2.0899999999999999, 1477561990000: 2.1600000000000001, 1477561970000: 2.1299999999999999, 1477562060000: 2.2200000000000002, 1477561870000: 2.0899999999999999, 1477562010000: 2.2599999999999998, 1477561960000: 2.1400000000000001, 1477561910000: 2.0899999999999999, 1477561800000: 2.1099999999999999, 1477561940000: 2.1099999999999999, 1477562070000: 2.2200000000000002, 1477561810000: 2.1000000000000001, 1477562020000: 2.25, 1477561890000: 2.0800000000000001, 1477561920000: 2.0899999999999999, 1477562080000: 2.21, 1477561900000: 2.0899999999999999, 1477561850000: 2.0899999999999999, 1477562030000: 2.25, 1477561980000: 2.1299999999999999, 1477561820000: 2.1000000000000001, 1477561830000: 2.1000000000000001, 1477562090000: 2.2000000000000002, 1477562040000: 2.2400000000000002}, 'cached_master': {1477561840000: 1512923136.0, 1477561880000: 1512972288.0, 1477561930000: 1513029632.0, 1477562050000: 1513189376.0, 1477562000000: 1513119744.0, 1477561950000: 1513062400.0, 1477561860000: 1512947712.0, 1477561990000: 1513111552.0, 1477561970000: 1513086976.0, 1477562060000: 1513193472.0, 1477561870000: 1512960000.0, 1477562010000: 1513132032.0, 1477561960000: 1513070592.0, 1477561910000: 1513005056.0, 1477561800000: 1512878080.0, 1477561940000: 1513046016.0, 1477562070000: 1513205760.0, 1477561810000: 1512886272.0, 1477562020000: 1513140224.0, 1477561890000: 1512984576.0, 1477561920000: 1513021440.0, 1477562080000: 1513291776.0, 1477561900000: 1512992768.0, 1477561850000: 1512935424.0, 1477562030000: 1513156608.0, 1477561980000: 1513095168.0, 1477561820000: 1512898560.0, 1477561830000: 1512910848.0, 1477562090000: 1513320448.0, 1477562040000: 1513172992.0}, 'used_slave2': {1477561840000: 3034705920.0, 1477561880000: 3078176768.0, 1477561930000: 3076153344.0, 1477562050000: 3091247104.0, 1477562000000: 3087319040.0, 1477561950000: 3080925184.0, 1477561860000: 3057725440.0, 1477561990000: 3085139968.0, 1477561970000: 3082735616.0, 1477562060000: 3092762624.0, 1477561870000: 3059269632.0, 1477562010000: 3087314944.0, 1477561960000: 3081101312.0, 1477561910000: 3076423680.0, 1477561800000: 2990448640.0, 1477561940000: 3079024640.0, 1477562070000: 3088519168.0, 1477561810000: 2992594944.0, 1477562020000: 3089555456.0, 1477561890000: 3074326528.0, 1477561920000: 3076481024.0, 1477562080000: 3090673664.0, 1477561900000: 3076435968.0, 1477561850000: 3034734592.0, 1477562030000: 3088834560.0, 1477561980000: 3085012992.0, 1477561820000: 3032190976.0, 1477561830000: 3032002560.0, 1477562090000: 3090427904.0, 1477562040000: 3090677760.0}, 'used_slave3': {1477561840000: 3682643968.0, 1477561880000: 3669774336.0, 1477561930000: 3671699456.0, 1477562050000: 3680440320.0, 1477562000000: 3677798400.0, 1477561950000: 3672723456.0, 1477561860000: 3682340864.0, 1477561990000: 3679830016.0, 1477561970000: 3676749824.0, 1477562060000: 3680153600.0, 1477561870000: 3682254848.0, 1477562010000: 3677667328.0, 1477561960000: 3674931200.0, 1477561910000: 3669712896.0, 1477561800000: 3663491072.0, 1477561940000: 3672334336.0, 1477562070000: 3160342528.0, 1477561810000: 3665698816.0, 1477562020000: 3677872128.0, 1477561890000: 3669839872.0, 1477561920000: 3671613440.0, 1477562080000: 3503218688.0, 1477561900000: 3669716992.0, 1477561850000: 3682144256.0, 1477562030000: 3679293440.0, 1477561980000: 3677851648.0, 1477561820000: 3665842176.0, 1477561830000: 3682377728.0, 1477562090000: 3522662400.0, 1477562040000: 3678724096.0}, 'used_slave1': {1477561840000: 3964420096.0, 1477561880000: 3969478656.0, 1477561930000: 3985526784.0, 1477562050000: 3993726976.0, 1477562000000: 3982487552.0, 1477561950000: 3985784832.0, 1477561860000: 3968053248.0, 1477561990000: 3980054528.0, 1477561970000: 3988185088.0, 1477562060000: 3993870336.0, 1477561870000: 3967500288.0, 1477562010000: 3986415616.0, 1477561960000: 3987922944.0, 1477561910000: 3996000256.0, 1477561800000: 3961925632.0, 1477561940000: 3985514496.0, 1477562070000: 3993911296.0, 1477561810000: 3964149760.0, 1477562020000: 3986690048.0, 1477561890000: 3969556480.0, 1477561920000: 3983740928.0, 1477562080000: 3993952256.0, 1477561900000: 3977437184.0, 1477561850000: 3966050304.0, 1477562030000: 3988127744.0, 1477561980000: 3980369920.0, 1477561820000: 3964768256.0, 1477561830000: 3966128128.0, 1477562090000: 3994443776.0, 1477562040000: 3993161728.0}, 'shortterm_slave1': {1477561840000: 2.0299999999999998, 1477561880000: 2.02, 1477561930000: 2.0499999999999998, 1477562050000: 2.3900000000000001, 1477562000000: 2.27, 1477561950000: 2.1600000000000001, 1477561860000: 2.02, 1477561990000: 2.3199999999999998, 1477561970000: 2.2400000000000002, 1477562060000: 2.3300000000000001, 1477561870000: 2.02, 1477562010000: 2.75, 1477561960000: 2.2799999999999998, 1477561910000: 2.0699999999999998, 1477561800000: 2.0699999999999998, 1477561940000: 2.1899
def pacheck(data, type, threashold, lt):
anomalies = []
for k, v in data.iteritems():
if type in k:
for t, vl in v.iteritems():
time = datetime.datetime.fromtimestamp(t / 1000).strftime('%Y-%m-%d %H:%M:%S')
if lt:
if vl > threashold:
print "Found anomaly for %s at %s with value %f" % (k, time, vl)
anomalies.append({"type": "point", "metric": k, "time": time, "value": vl, "threashold": threashold, "threashold_type": "upper"})
else:
if vl < threashold:
print "Found anomaly for %s at %s with value %f" % (k, t, vl)
anomalies.append(
{"type": "point", "metric": k, "time": time, "value": vl, "threashold": threashold,
"threashold_type": "lower"})
return anomalies
print datetime.datetime.fromtimestamp(
int("1477561960")
).strftime('%Y-%m-%d %H:%M:%S')
t = pacheck(test, 'shortterm', 2.0, True)
t1 = pacheck(test, 'midterm', 2.0, True)
t2 = pacheck(test, 'longterm', 2.0, True)
t3 = pacheck(test, 'tx', 568300, True)
t4 = pacheck(test, 'rx', 568300, True)
t5 = pacheck(test, 'cached', 1512935424, True)
t6 = pacheck(test, 'buffered', 1512935424, True)
t7 = pacheck(test, 'used', 1512935424, True)
t8 = pacheck(test, 'free', 1512935424, True)
print len(t)
for p in t:
print p
print len(t8)