Reduce frequency of failure messages in sendTCPData

This commit is contained in:
Alfredo Cardigliano 2023-05-22 10:47:48 +02:00
parent ab73418e29
commit b7b2810e61
2 changed files with 22 additions and 5 deletions

View file

@ -85,6 +85,7 @@ end
-- ##############################################
function syslog.sendMessage(settings, notif, severity)
local do_debug = false
local syslog_severity = alert_consts.alertLevelToSyslogLevel(severity)
local syslog_format = settings.syslog_alert_format
local msg
@ -152,11 +153,18 @@ function syslog.sendMessage(settings, notif, severity)
msg = "<"..prio..">"..log_time.." "..host.." "..tag.."["..pid.."]: "..msg
end
local success = true
if settings.protocol == 'tcp' then
ntop.send_tcp_data(settings.host, settings.port, msg.."\n", 1 --[[ timeout (msec) --]] )
success = ntop.send_tcp_data(settings.host, settings.port, msg.."\n", 1 --[[ timeout (msec) --]] )
else
ntop.send_udp_data(settings.host, settings.port, msg)
end
if not success then
if do_debug then
tprint("[syslog] Failure delivering message")
end
end
end
return true