Mercurial > prosody-modules
comparison mod_server_status/mod_server_status.lua @ 546:0afe88f9bdde
mod_server_status: fixed trace case when an user, mistakenly or not, sets a component which doesn't exist into the plugin config. (thanks chris)
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Tue, 10 Jan 2012 20:55:45 +0000 |
parents | f78a95aa23c4 |
children | 0b52d82ea0b3 |
comparison
equal
deleted
inserted
replaced
545:77f350635f4f | 546:0afe88f9bdde |
---|---|
73 -- build components stats if there | 73 -- build components stats if there |
74 if components[1] then | 74 if components[1] then |
75 comps_stats[1] = response_table.comps.elem_header | 75 comps_stats[1] = response_table.comps.elem_header |
76 for _, name in ipairs(components) do | 76 for _, name in ipairs(components) do |
77 comps_stats[#comps_stats+1] = response_table.comps.status:format( | 77 comps_stats[#comps_stats+1] = response_table.comps.status:format( |
78 name, hosts[name].modules.component and hosts[name].modules.component.connected and "online" or | 78 name, hosts[name] and hosts[name].modules.component and hosts[name].modules.component.connected and "online" or |
79 hosts[name] and hosts[name].modules.component == nil and "online" or "offline") | 79 hosts[name] and hosts[name].modules.component == nil and "online" or "offline") |
80 end | 80 end |
81 comps_stats[#comps_stats+1] = response_table.comps.elem_closure | 81 comps_stats[#comps_stats+1] = response_table.comps.elem_closure |
82 end | 82 end |
83 | 83 |
99 for _,n in ipairs(show_hosts) do result.hosts[n] = hosts[n] and "online" or "offline" end | 99 for _,n in ipairs(show_hosts) do result.hosts[n] = hosts[n] and "online" or "offline" end |
100 end | 100 end |
101 if show_comps then | 101 if show_comps then |
102 result.components = {} | 102 result.components = {} |
103 for _,n in ipairs(show_comps) do | 103 for _,n in ipairs(show_comps) do |
104 result.components[n] = hosts[n].modules.component and hosts[n].modules.component.connected and "online" or | 104 result.components[n] = hosts[n] and hosts[n].modules.component and hosts[n].modules.component.connected and "online" or |
105 hosts[n] and hosts[n].modules.component == nil and "online" or "offline" | 105 hosts[n] and hosts[n].modules.component == nil and "online" or "offline" |
106 end | 106 end |
107 end | 107 end |
108 | 108 |
109 return json_encode(result) | 109 return json_encode(result) |