subscribe to up/down only
diff --git a/examples/lua/test_mailers.lua b/examples/lua/test_mailers.lua
index 5d398e4..4cd8d27 100644
--- a/examples/lua/test_mailers.lua
+++ b/examples/lua/test_mailers.lua
@@ -189,17 +189,18 @@
c:add(string.format("%d active and %d backup servers left.",
srv:get_proxy():get_srv_act(),
srv:get_proxy():get_srv_bck()))
- c:add(" ")
- c:add(string.format("%d sessions active, %d requeued, %d remaining in queue",
+ if requeued ~= nil then
+ c:add(" ")
+ c:add(string.format("%d sessions active, %d requeued, %d remaining in queue",
srv:get_cur_sess(),
requeued,
srv:get_pend_conn()))
+ end
return c:dump()
end
local function srv_state_handler(event, data, when)
local server = data.reference
- local state = data.state
local c = core.concat()
local log_level = SYSLOG_LEVEL["ALERT"]
local message
@@ -209,22 +210,11 @@
return
end
- if state.admin then
- -- don't report if is related to an administrative change and not
- -- directly due to an operational change
- return
- end
-
- -- we don't send an alert if the server was previously stopping
- if state.old_state == "STOPPING" or server:is_draining() then
- log_level = SYSLOG_LEVEL["NOTICE"]
- end
-
-- prepare the message
c:add(string.format("Server %s/%s is %s",
server:get_proxy():get_name(),
server:get_name(),
- state.new_state == "STARTING" and "UP" or "DOWN"))
+ event == "SERVER_UP" and "UP" or "DOWN"))
if server:tracking()
then
@@ -235,15 +225,8 @@
server:tracking():get_name()))
end
- if state.check ~= nil
- then
- c:add(srv_get_check_details(state.check))
- else
- c:add(state.cause)
- end
-
c:add(". ")
- c:add(srv_get_status_details(server, state.requeued))
+ c:add(srv_get_status_details(server, nil))
send_email_alert(server, log_level, c:dump(), when)
end
@@ -330,7 +313,7 @@
-- single function for multiple event types since all events come
-- from the same subscription to reduce memory footprint
local function srv_event_dispatch(event, data, mgmt, when)
- if event == "SERVER_STATE" then srv_state_handler(event, data, when) end
+ if event == "SERVER_UP" or event == "SERVER_DOWN" then srv_state_handler(event, data, when) end
if event == "SERVER_ADMIN" then srv_admin_handler(event, data, when) end
if event == "SERVER_CHECK" then srv_check_handler(event, data, when) end
end
@@ -344,7 +327,7 @@
end
-- email alerts are enabled, track server state and admin changes
- local subscriptions = {"SERVER_STATE", "SERVER_ADMIN"}
+ local subscriptions = {"SERVER_UP", "SERVER_DOWN", "SERVER_ADMIN"}
if mailer_conf.track_server_health
then