1
|
|
|
from lib.mmonit import MmonitBaseAction |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
class MmonitListEvents(MmonitBaseAction): |
5
|
|
|
def run(self, active=None, hostid=None, hostgroupid=None, servicenameid=None, |
6
|
|
|
servicegroupid=None, servicetype=None, eventtype=None, state=None, datefrom=None, |
7
|
|
|
results=None, startindex=None, sort_key=None, sort_dir=None, dateto=None): |
8
|
|
|
self.login() |
9
|
|
|
data = {} |
10
|
|
|
|
11
|
|
|
if active is not None: |
12
|
|
|
data['active'] = active |
13
|
|
|
if hostid is not None: |
14
|
|
|
data['description'] = hostid |
15
|
|
|
if hostgroupid is not None: |
16
|
|
|
data['hostgroupid'] = hostgroupid |
17
|
|
|
if servicenameid is not None: |
18
|
|
|
data['servicenameid'] = servicenameid |
19
|
|
|
if servicegroupid is not None: |
20
|
|
|
data['servicegroupid'] = servicegroupid |
21
|
|
|
if servicetype is not None: |
22
|
|
|
data['servicetype'] = servicetype |
23
|
|
|
if eventtype is not None: |
24
|
|
|
data['eventtype'] = eventtype |
25
|
|
|
if state is not None: |
26
|
|
|
data['state'] = state |
27
|
|
|
if datefrom is not None: |
28
|
|
|
data['datefrom'] = datefrom |
29
|
|
|
if results is not None: |
30
|
|
|
data['results'] = results |
31
|
|
|
if startindex is not None: |
32
|
|
|
data['startindex'] = startindex |
33
|
|
|
if sort_key is not None: |
34
|
|
|
data['sort'] = sort_key |
35
|
|
|
if sort_dir is not None: |
36
|
|
|
data['dir'] = sort_dir |
37
|
|
|
if dateto is not None: |
38
|
|
|
data['dateto'] = dateto |
39
|
|
|
|
40
|
|
|
req = self.session.post("{}/reports/events/list".format(self.url), data=data) |
41
|
|
|
|
42
|
|
|
try: |
43
|
|
|
return req.json() |
44
|
|
|
except Exception: |
45
|
|
|
raise |
46
|
|
|
finally: |
47
|
|
|
self.logout() |
48
|
|
|
|