comparison mod_http_host_status_check/mod_http_host_status_check.lua @ 2765:85cf9a8b4020

mod_http_host_status_check: Add list of failing hosts to the first line for summary
author Matthew Wild <mwild1@gmail.com>
date Mon, 18 Sep 2017 16:39:02 +0100
parents 2a7e9d9e7339
children
comparison
equal deleted inserted replaced
2764:1872a9129c2f 2765:85cf9a8b4020
33 function status_page() 33 function status_page()
34 local host_statuses = {}; 34 local host_statuses = {};
35 local current_time = time(); 35 local current_time = time();
36 36
37 local all_ok = true; 37 local all_ok = true;
38 local failed_hosts = {};
38 39
39 for host in pairs(hosts) do 40 for host in pairs(hosts) do
40 local last_heartbeat_time = heartbeats[host]; 41 local last_heartbeat_time = heartbeats[host];
41 42
42 local ok, status_text = true; 43 local ok, status_text = true;
79 end 80 end
80 end 81 end
81 82
82 if not ok then 83 if not ok then
83 all_ok = false; 84 all_ok = false;
85 table.insert(failed_hosts, host);
84 end 86 end
85 87
86 if not ok or is_component or last_heartbeat_time then 88 if not ok or is_component or last_heartbeat_time then
87 host_statuses[host] = string_pad(status_text, 20); 89 host_statuses[host] = string_pad(status_text, 20);
88 end 90 end
93 end 95 end
94 host_status_ok[host] = ok; 96 host_status_ok[host] = ok;
95 end 97 end
96 end 98 end
97 local page = template(status_page_template, { 99 local page = template(status_page_template, {
98 status = all_ok and "OK" or "FAIL"; 100 status = all_ok and "OK" or ("FAIL: "..table.concat(failed_hosts, ", "));
99 host_statuses = host_statuses; 101 host_statuses = host_statuses;
100 }); 102 });
101 return page; 103 return page;
102 end 104 end
103 105