Revision 3a32bf0a
Modification de la requête afin d'inclure les évènements corrélés causés par des incidents sur des hôtes
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@1706 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/controllers/vigiboardrequest.py | ||
---|---|---|
5 | 5 |
from vigiboard.model import Event, CorrEvent, EventHistory, \ |
6 | 6 |
Host, HostGroup, ServiceLowLevel, ServiceGroup, \ |
7 | 7 |
StateName |
8 |
from vigilo.models import SupItem |
|
8 | 9 |
from vigilo.models.secondary_tables import HOST_GROUP_TABLE, \ |
9 | 10 |
SERVICE_GROUP_TABLE |
10 | 11 |
from tg import url, config, tmpl_context |
... | ... | |
52 | 53 |
self.user_groups = user.groups |
53 | 54 |
self.lang = lang |
54 | 55 |
self.generaterq = False |
56 |
|
|
57 |
associated_host = aliased(Host) |
|
58 |
lls_query = DBSession.query(ServiceLowLevel.idservice.label("idsupitem"), |
|
59 |
ServiceLowLevel.servicename, |
|
60 |
associated_host.name.label("hostname") |
|
61 |
).join((associated_host, |
|
62 |
associated_host.idhost == ServiceLowLevel.idhost), |
|
63 |
) |
|
64 |
|
|
65 |
host_query = DBSession.query(Host.idhost.label("idsupitem"), |
|
66 |
"NULL", |
|
67 |
Host.name.label("hostname")) |
|
68 |
|
|
69 |
items = lls_query.union(host_query).subquery() |
|
55 | 70 |
|
56 | 71 |
self.table = [ |
57 | 72 |
CorrEvent, |
58 | 73 |
sql.func.count(CorrEvent.idcorrevent), |
74 |
items.hostname, |
|
75 |
items.servicename, |
|
59 | 76 |
] |
60 | 77 |
|
78 |
# self.join = [ |
|
79 |
# (Event, CorrEvent.idcause == Event.idevent), |
|
80 |
# (ServiceLowLevel, Event.idsupitem == ServiceLowLevel.idservice), |
|
81 |
# (Host, Host.idhost == ServiceLowLevel.idhost), |
|
82 |
# (StateName, StateName.idstatename == Event.current_state), |
|
83 |
# ] |
|
84 |
# |
|
85 |
# self.outerjoin = [ |
|
86 |
# (HOST_GROUP_TABLE, HOST_GROUP_TABLE.c.idhost == Host.idhost), |
|
87 |
# (SERVICE_GROUP_TABLE, SERVICE_GROUP_TABLE.c.idservice == \ |
|
88 |
# ServiceLowLevel.idservice), |
|
89 |
# ] |
|
90 |
|
|
61 | 91 |
self.join = [ |
62 | 92 |
(Event, CorrEvent.idcause == Event.idevent), |
63 |
(ServiceLowLevel, Event.idsupitem == ServiceLowLevel.idservice), |
|
64 |
(Host, Host.idhost == ServiceLowLevel.idhost), |
|
93 |
(items, Event.idsupitem == items.c.idsupitem), |
|
65 | 94 |
(StateName, StateName.idstatename == Event.current_state), |
66 | 95 |
] |
67 | 96 |
|
68 | 97 |
self.outerjoin = [ |
69 |
(HOST_GROUP_TABLE, HOST_GROUP_TABLE.c.idhost == Host.idhost),
|
|
98 |
(HOST_GROUP_TABLE, HOST_GROUP_TABLE.c.idhost == items.c.idsupitem),
|
|
70 | 99 |
(SERVICE_GROUP_TABLE, SERVICE_GROUP_TABLE.c.idservice == \ |
71 |
ServiceLowLevel.idservice),
|
|
100 |
items.c.idsupitem),
|
|
72 | 101 |
] |
73 | 102 |
|
74 | 103 |
self.filter = [ |
... | ... | |
97 | 126 |
priority_order, # Priorité ITIL (entier). |
98 | 127 |
desc(StateName.order), # Etat courant (entier). |
99 | 128 |
desc(Event.timestamp), |
100 |
asc(Host.name),
|
|
129 |
asc(items.c.hostname),
|
|
101 | 130 |
] |
102 | 131 |
|
103 | 132 |
self.groupby = [ |
104 | 133 |
CorrEvent.idcorrevent, |
105 | 134 |
CorrEvent, |
106 |
Host.name,
|
|
135 |
items.c.hostname,
|
|
107 | 136 |
StateName.order, |
108 | 137 |
Event.timestamp, |
109 | 138 |
] |
Also available in: Unified diff