forked from outlyerapp/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhadoop.datanode.py
More file actions
executable file
·43 lines (36 loc) · 1011 Bytes
/
hadoop.datanode.py
File metadata and controls
executable file
·43 lines (36 loc) · 1011 Bytes
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
#!/usr/bin/env python
import sys
import requests
import json
import socket
names = ['*']
excludes = ['namenodeaddresses',
'volumeinfo',
'httpport',
'name',
'version',
'modelertype',
'storageinfo',
'clusterid',
'rpcport',
'tag.port',
'tag.context',
'tag.hostname',
'tag.sessionid',
'tag.processname']
metrics = {}
for n in names:
URL = 'http://%s:50075/jmx?qry=Hadoop:service=DataNode,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
except:
print "Plugin Failed!"
sys.exit(2)
output = "OK | "
for k, v in metrics.iteritems():
output += str(k).lower() + '=' + str(v).lower() + ';;;; '
print output