Fix hostname when syslog is used (#10275)
thiagoftsm committed
Nov 25, 2020 at 16:05 UTC
55c31e58b981c8850d1d775381d3fa5df066ddb9
1 file changed
+11
-11
health/notifications/alarm-notify.sh.in
+11
-11
@@ -1833,7 +1833,7 @@ EOF
1833
1834
send_syslog() {
1835
local facility=${SYSLOG_FACILITY:-"local6"} level='info' targets="${1}"
1836
- local priority='' message='' host='' port='' prefix=''
1836
+ local priority='' message='' server='' port='' prefix=''
1837
local temp1='' temp2=''
1838
1839
[ "${SEND_SYSLOG}" = "YES" ] || return 1
@@ -1847,7 +1847,7 @@ send_syslog() {
1847
for target in ${targets}; do
1848
priority="${facility}.${level}"
1849
message=''
1850
- host=''
1850
+ server=''
1851
port=''
1852
prefix=''
1853
temp1=''
@@ -1859,25 +1859,25 @@ send_syslog() {
1859
if [ ${prefix} != ${temp1} ]; then
1860
if (echo ${temp1} | grep -q '@'); then
1861
temp2=$(echo ${temp1} | cut -d '@' -f 1)
1862
- host=$(echo ${temp1} | cut -d '@' -f 2)
1862
+ server=$(echo ${temp1} | cut -d '@' -f 2)
1863
1864
- if [ ${temp2} != ${host} ]; then
1864
+ if [ ${temp2} != ${server} ]; then
1865
priority=${temp2}
1866
fi
1867
1868
- port=$(echo ${host} | rev | cut -d ':' -f 1 | rev)
1868
+ port=$(echo ${server} | rev | cut -d ':' -f 1 | rev)
1869
1870
- if (echo ${host} | grep -E -q '\[.*\]'); then
1870
+ if (echo ${server} | grep -E -q '\[.*\]'); then
1871
if (echo ${port} | grep -q ']'); then
1872
port=''
1873
else
1874
- host=$(echo ${host} | rev | cut -d ':' -f 2- | rev)
1874
+ server=$(echo ${server} | rev | cut -d ':' -f 2- | rev)
1875
fi
1876
else
1877
- if [ ${port} = ${host} ]; then
1877
+ if [ ${port} = ${server} ]; then
1878
port=''
1879
else
1880
- host=$(echo ${host} | cut -d ':' -f 1)
1880
+ server=$(echo ${server} | cut -d ':' -f 1)
1881
fi
1882
fi
1883
else
@@ -1887,8 +1887,8 @@ send_syslog() {
1887
1888
message="${prefix} ${status} on ${host} at ${date}: ${chart} ${value_string}"
1889
1890
- if [ ${host} ]; then
1891
- logger_options="${logger_options} -n ${host}"
1890
+ if [ ${server} ]; then
1891
+ logger_options="${logger_options} -n ${server}"
1892
if [ ${port} ]; then
1893
logger_options="${logger_options} -P ${port}"
1894
fi