- def action(self, filter='all'):
- session.bind = metadata.bind
- filtercount = {'active' : 0, 'acknowledged': 0, 'all' : 0}
- # With Acknowledgement
- sql_ack = 'SELECT DISTINCT h.host,t.description,t.priority,t.lastchange,a.message,e.eventid '+ \
- ' FROM triggers t,hosts h,items i,functions f, hosts_groups hg,escalations e,acknowledges a ' + \
- ' WHERE f.itemid=i.itemid ' + \
- ' AND h.hostid=i.hostid ' + \
- ' AND hg.hostid=h.hostid ' + \
- ' AND t.triggerid=f.triggerid ' + \
- ' AND t.triggerid=e.triggerid ' + \
- ' AND a.eventid=e.eventid ' + \
- ' AND t.status=' + str(defines.TRIGGER_STATUS_ENABLED) + \
- ' AND i.status=' + str(defines.ITEM_STATUS_ACTIVE) + \
- ' AND h.status=' + str(defines.HOST_STATUS_MONITORED) + \
- ' AND t.value=' + str(defines.TRIGGER_VALUE_TRUE) + \
- ' ORDER BY t.lastchange DESC';
-
- # WithOUT Acknowledgement
- sql_noack = 'SELECT DISTINCT h.host,t.description,t.priority,t.lastchange,e.eventid ' + \
- ' FROM triggers t,hosts h,items i,functions f, hosts_groups hg,escalations e,acknowledges a ' + \
- ' WHERE f.itemid=i.itemid ' + \
- ' AND h.hostid=i.hostid ' + \
- ' AND hg.hostid=h.hostid ' + \
- ' AND t.triggerid=f.triggerid ' + \
- ' AND t.triggerid=e.triggerid ' + \
- ' AND e.eventid not in (select eventid from acknowledges) ' + \
- ' AND t.status=' + str(defines.TRIGGER_STATUS_ENABLED) + \
- ' AND i.status=' + str(defines.ITEM_STATUS_ACTIVE) + \
- ' AND h.status=' + str(defines.HOST_STATUS_MONITORED) + \
- ' AND t.value=' + str(defines.TRIGGER_VALUE_TRUE) + \
- ' ORDER BY t.lastchange DESC';
- # for i in session.execute(sql): print i