зеркало из https://github.com/mozilla/MozDef.git
try/except around the ES node stats
In case the stat is missing, or a node doesn't have a stat (like a non data node).
This commit is contained in:
Родитель
0b3b9a841c
Коммит
204e194bb8
|
@ -79,14 +79,18 @@ def getEsNodesStats():
|
|||
jsonobj = r.json()
|
||||
results = []
|
||||
for nodeid in jsonobj['nodes']:
|
||||
results.append({
|
||||
'hostname': jsonobj['nodes'][nodeid]['host'],
|
||||
'disk_free': jsonobj['nodes'][nodeid]['fs']['total']['free_in_bytes'] / (1024 * 1024 * 1024),
|
||||
'disk_total': jsonobj['nodes'][nodeid]['fs']['total']['total_in_bytes'] / (1024 * 1024 * 1024),
|
||||
'mem_heap_per': jsonobj['nodes'][nodeid]['jvm']['mem']['heap_used_percent'],
|
||||
'cpu_usage': jsonobj['nodes'][nodeid]['os']['cpu_percent'],
|
||||
'load': jsonobj['nodes'][nodeid]['os']['load_average']
|
||||
})
|
||||
try:
|
||||
results.append({
|
||||
'hostname': jsonobj['nodes'][nodeid]['host'],
|
||||
'disk_free': jsonobj['nodes'][nodeid]['fs']['total']['free_in_bytes'] / (1024 * 1024 * 1024),
|
||||
'disk_total': jsonobj['nodes'][nodeid]['fs']['total']['total_in_bytes'] / (1024 * 1024 * 1024),
|
||||
'mem_heap_per': jsonobj['nodes'][nodeid]['jvm']['mem']['heap_used_percent'],
|
||||
'cpu_usage': jsonobj['nodes'][nodeid]['os']['cpu_percent'],
|
||||
'load': jsonobj['nodes'][nodeid]['os']['load_average']
|
||||
})
|
||||
except Exception as e:
|
||||
#logger.error("exception %r appending ES node stats" %e)
|
||||
continue
|
||||
return results
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче