forked from outlyerapp/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyarn.resourcemgr.py
More file actions
executable file
·60 lines (50 loc) · 1.6 KB
/
yarn.resourcemgr.py
File metadata and controls
executable file
·60 lines (50 loc) · 1.6 KB
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
57
58
59
#!/usr/bin/env python
import sys
import requests
import json
import socket
names = ['*']
excludes = ['modelertype',
'tag.context',
'tag.port',
'tag.processname',
'tag.sessionid',
'name',
'tag.hostname',
'livenodemanagers',
'tag.clustermetrics',
'nodehttpaddress',
'lasthealthupdate',
'hostname',
'healthreport',
'state',
'healthstatus',
'rack',
'nodeid']
metrics = {}
node_data = {}
for n in names:
URL = 'http://%s:8088/jmx?qry=Hadoop:service=ResourceManager,name=%s' % (socket.getfqdn(), n)
try:
resp = requests.get(URL, timeout=60).json()['beans']
for i in range(len(resp)):
for k, v in resp[i].iteritems():
if k.lower() not in excludes:
metrics[k] = v
# Parse info about node managers
for i in json.loads(resp[0]['LiveNodeManagers']):
for k, v in i.iteritems():
node_name = i.values()[0].split('.')[0]
if k.lower() == 'slots':
for a,b in v.iteritems():
node_data[node_name + '.' + a] = b
elif k.lower() not in excludes:
node_data[node_name + '.' + k] = v
metrics.update(node_data)
except:
print "Plugin Failed!"
sys.exit(2)
output = "OK | "
for k, v in metrics.iteritems():
output += str(k).lower() + '=' + str(v).lower() + ';;;; '
print output