add host to log messages
Costa Tsaousis (ktsaou) committed
Mar 12, 2017 at 05:40 UTC
30c8f6ac827cdae82136d659b117babd67577b48
1 file changed
+12
-12
plugins.d/alarm-notify.sh
+12
-12
@@ -142,20 +142,27 @@ info="${18}" # a short description of the alarm
142
value_string="${19}" # friendly value (with units)
143
old_value_string="${20}" # friendly old value (with units)
144
145
+# -----------------------------------------------------------------------------
146
+# find a suitable hostname to use, if netdata did not supply a hostname
147
+
148
+[ -z "${host}" ] && host="${NETDATA_HOSTNAME}"
149
+[ -z "${host}" ] && host="${NETDATA_REGISTRY_HOSTNAME}"
150
+[ -z "${host}" ] && host="$(hostname 2>/dev/null)"
151
+
152
# -----------------------------------------------------------------------------
153
# screen statuses we don't need to send a notification
154
155
# don't do anything if this is not WARNING, CRITICAL or CLEAR
156
if [ "${status}" != "WARNING" -a "${status}" != "CRITICAL" -a "${status}" != "CLEAR" ]
157
then
151
- info "not sending notification for ${status} on '${chart}.${name}'"
158
+ info "not sending notification for ${status} of '${host}.${chart}.${name}'"
159
exit 1
160
fi
161
162
# don't do anything if this is CLEAR, but it was not WARNING or CRITICAL
163
if [ "${old_status}" != "WARNING" -a "${old_status}" != "CRITICAL" -a "${status}" = "CLEAR" ]
164
then
158
- info "not sending notification for ${status} on '${chart}.${name}' (last status was ${old_status})"
165
+ info "not sending notification for ${status} of '${host}.${chart}.${name}' (last status was ${old_status})"
166
exit 1
167
fi
168
@@ -532,16 +539,9 @@ if [ "${SEND_EMAIL}" != "YES" \
539
-a "${SEND_PD}" != "YES" \
540
]
541
then
535
- fatal "All notification methods are disabled. Not sending notification to '${roles}' for '${name}' = '${value}' of chart '${chart}' for status '${status}'."
542
+ fatal "All notification methods are disabled. Not sending notification for host '${host}', chart '${chart}' to '${roles}' for '${name}' = '${value}' for status '${status}'."
543
fi
544
538
-# -----------------------------------------------------------------------------
539
-# find a suitable hostname to use, if netdata did not supply a hostname
540
-
541
-[ -z "${host}" ] && host="${NETDATA_HOSTNAME}"
542
-[ -z "${host}" ] && host="${NETDATA_REGISTRY_HOSTNAME}"
543
-[ -z "${host}" ] && host="$(hostname 2>/dev/null)"
544
-
545
# -----------------------------------------------------------------------------
546
# get the date the alarm happened
547
@@ -803,10 +803,10 @@ send_pd() {
803
retval=$?
804
if [ ${retval} -eq 0 ]
805
then
806
- info "sent pagerduty.com notification using service key ${PD_SERVICE_KEY::-26}....: ${d}"
806
+ info "sent pagerduty.com notification for host ${host} ${chart}.${name} using service key ${PD_SERVICE_KEY::-26}....: ${d}"
807
sent=$((sent + 1))
808
else
809
- error "failed to send pagerduty.com notification using service key ${PD_SERVICE_KEY::-26}.... (error code ${retval}): ${d}"
809
+ error "failed to send pagerduty.com notification for ${host} ${chart}.${name} using service key ${PD_SERVICE_KEY::-26}.... (error code ${retval}): ${d}"
810
fi
811
done
812