- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEventStatus.sql
More file actions
Latest commit
executable file
·20 lines (19 loc) · 2.44 KB
/
Copy pathEventStatus.sql
File metadata and controls
executable file
·20 lines (19 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
SET @NumDays :=3;
select'<tr><td>', event_schema,
'</td><td>', event_name,
'</td><td>', CASE status WHEN 'ENABLED' THEN '<div class="Healthy">Yes</div>' WHEN 'SLAVESIDE_DISABLED' THEN '<div class="Healthy">No</div>' ELSE '<div class="Warning">No</div>' END,
'</td><td>', CASE (selectcount(*) frommaster.event_historywhere db =ev.EVENT_SCHEMAand name =ev.EVENT_NAMEand errno is nulland start >= subdate(now(), @NumDays)) WHEN 0 THEN CONCAT('<div class="Warning">', (selectcount(*) frommaster.event_historywhere db =ev.EVENT_SCHEMAand name =ev.EVENT_NAMEand errno is nulland start >= subdate(now(), @NumDays)), '</div>') ELSE (selectcount(*) frommaster.event_historywhere db =ev.EVENT_SCHEMAand name =ev.EVENT_NAMEand errno is nulland start >= subdate(now(), @NumDays)) END,
'</td><td>', CASE (selectcount(*) frommaster.event_historywhere db =ev.EVENT_SCHEMAand name =ev.EVENT_NAMEand errno is not nulland start >= subdate(now(), @NumDays)) WHEN 0 THEN '<div class="Healthy">0</div>' ELSE CONCAT('<div class="Critical">', (selectcount(*) frommaster.event_historywhere db =ev.EVENT_SCHEMAand name =ev.EVENT_NAMEand errno is not nulland start >= subdate(now(), @NumDays)),'</div>') END,
'</td><td>', last_executed,
'</td><td>', case interval_field
when "YEAR" then date_add(last_executed, interval interval_value YEAR)
when "QUARTER" then date_add(last_executed, interval interval_value QUARTER)
when "MONTH" then date_add(last_executed, interval interval_value MONTH)
when "DAY" then date_add(last_executed, interval interval_value DAY)
when "HOUR" then date_add(last_executed, interval interval_value HOUR)
when "MINUTE" then date_add(last_executed, interval interval_value MINUTE)
when "WEEK" then date_add(last_executed, interval interval_value WEEK)
when "SECOND" then date_add(last_executed, interval interval_value SECOND)
end,
'</td><td>', (select CASE WHEN errno is null THEN CONCAT('<span class="Healthy">', message_text, '</span>') ELSE CONCAT('<span class="Critical">', message_text, '</span>') END frommaster.event_historywhere db =ev.EVENT_SCHEMAand name =ev.EVENT_NAMEorder by start limit1), '</td></tr>'
frominformation_schema.EVENTS ev;