@cryptotaxi247 / netdata-1 / commits / 0a9f0c2c5

friendly values for external notifications

Costa Tsaousis (ktsaou) committed Jan 26, 2017 at 13:34 UTC 0a9f0c2c50ed0b0ac2a150771b81cc37de4f7398
2 files changed +12 -8
plugins.d/alarm-notify.sh
+6 -4
@@ -46,7 +46,7 @@ then
46 echo >&2
47 echo >&2 "# SENDING TEST ${x} ALARM TO ROLE: ${recipient}"
48
49 - "${0}" "${recipient}" "$(hostname)" 1 1 "${id}" "$(date +%s)" "test_alarm" "test.chart" "test.family" "${x}" "${last}" 100 90 "${0}" 1 $((0 + id)) "units" "this is a test alarm to verify notifications work"
49 + "${0}" "${recipient}" "$(hostname)" 1 1 "${id}" "$(date +%s)" "test_alarm" "test.chart" "test.family" "${x}" "${last}" 100 90 "${0}" 1 $((0 + id)) "units" "this is a test alarm to verify notifications work" "new value" "old value"
50 if [ $? -ne 0 ]
51 then
52 echo >&2 "# FAILED"
@@ -138,6 +138,8 @@ duration="${15}" # the duration in seconds of the previous alarm state
138 non_clear_duration="${16}" # the total duration in seconds this is/was non-clear
139 units="${17}" # the units of the value
140 info="${18}" # a short description of the alarm
141 +value_string="${19}" # friendly value (with units)
142 +old_value_string="${20}" # friendly old value (with units)
143
144 # -----------------------------------------------------------------------------
145 # screen statuses we don't need to send a notification
@@ -747,13 +749,13 @@ send_pd() {
749 then
750 for PD_SERVICE_KEY in ${recipients}
751 do
750 - d="${status} ${name}=${value} ${units} - ${host}, ${family}"
752 + d="${status} ${name} = ${value_string} - ${host}, ${family}"
753 ${pd_send} -k ${PD_SERVICE_KEY} \
754 -t ${t} \
755 -d "${d}" \
756 -i ${alarm_id} \
757 -f 'info'="${info}" \
756 - -f 'value_w_units'="${value} ${units}" \
758 + -f 'value_w_units'="${value_string}" \
759 -f 'when'="${when}" \
760 -f 'duration'="${duration}" \
761 -f 'roles'="${roles}" \
@@ -1034,7 +1036,7 @@ status_message="status unknown"
1036 color="grey"
1037
1038 # the alarm value
1037 -alarm="${name//_/ } = ${value} ${units}"
1039 +alarm="${name//_/ } = ${value_string}"
1040
1041 # the image of the alarm
1042 image="${images_base_url}/images/seo-performance-128.png"
src/health.c
+6 -4
@@ -2656,7 +2656,7 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
2656 const char *recipient = ae->recipient;
2657 if(!recipient) recipient = health.health_default_recipient;
2658
2659 - snprintfz(command_to_run, ALARM_EXEC_COMMAND_LENGTH, "exec %s '%s' '%s' '%u' '%u' '%u' '%lu' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%u' '%u' '%s' '%s'",
2659 + snprintfz(command_to_run, ALARM_EXEC_COMMAND_LENGTH, "exec %s '%s' '%s' '%u' '%u' '%u' '%lu' '%s' '%s' '%s' '%s' '%s' '%0.0Lf' '%0.0Lf' '%s' '%u' '%u' '%s' '%s' '%s' '%s'",
2660 exec,
2661 recipient,
2662 host->hostname,
@@ -2669,13 +2669,15 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
2669 ae->family?ae->family:"NOFAMILY",
2670 rrdcalc_status2string(ae->new_status),
2671 rrdcalc_status2string(ae->old_status),
2672 - ae->new_value_string,
2673 - ae->old_value_string,
2672 + ae->new_value,
2673 + ae->old_value,
2674 ae->source?ae->source:"UNKNOWN",
2675 (uint32_t)ae->duration,
2676 (uint32_t)ae->non_clear_duration,
2677 ae->units?ae->units:"",
2678 - ae->info?ae->info:""
2678 + ae->info?ae->info:"",
2679 + ae->new_value_string,
2680 + ae->old_value_string
2681 );
2682
2683 ae->flags |= HEALTH_ENTRY_FLAG_EXEC_RUN;