-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvManageAlarms.py
26 lines (24 loc) · 1 KB
/
vManageAlarms.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
import vManage_auth
from pprint import pprint
def get_data():
result = []
query = {"query":{
"field": "active",
"type": "boolean",
"value": ["true"],
"operator": "equal"
}}
data = vManage_auth.get_data("/dataservice/alarms",query2=query)["data"]
for item in data:
if(item["acknowledged"]==False and item["active"]==True):
item["severity"] = item["severity"].lower()
if('host-name' not in item['values'][0].keys()):
item['values'][0]['host-name'] = "NA"
if(item["severity"]=="medium"):
item["severity"] = "moderate"
if(item["severity"]=="minor"):
item["severity"] = "warning"
result.append({"summary": item["eventname"], "name": item['values'][0]['host-name'], "severity": item["severity"] , "url" : "https://"+vManage_auth.vmanage_ip + "/#/app/monitor/alarms/details/" + str(item["uuid"])})
return result
if __name__ == "__main__":
pprint(get_data())