@cryptotaxi247 / netdata-1 / commits / 899a78b16

Pass the child machine's guid to the goto_url link (#12609)

* pass child machine guid * pass parameter

Emmanuel Vasilakis committed May 27, 2022 at 13:54 UTC 899a78b162a45fcdc7da08912c94ee9d2a027ae2
2 files changed +9 -3
health/health.c
+3 -2
@@ -354,7 +354,7 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
354
355 char *edit_command = ae->source ? health_edit_command_from_source(ae->source) : strdupz("UNKNOWN=0=UNKNOWN");
356
357 - snprintfz(command_to_run, ALARM_EXEC_COMMAND_LENGTH, "exec %s '%s' '%s' '%u' '%u' '%u' '%lu' '%s' '%s' '%s' '%s' '%s' '" CALCULATED_NUMBER_FORMAT_ZERO "' '" CALCULATED_NUMBER_FORMAT_ZERO "' '%s' '%u' '%u' '%s' '%s' '%s' '%s' '%s' '%s' '%d' '%d' '%s' '%s' '%s' '%s'",
357 + snprintfz(command_to_run, ALARM_EXEC_COMMAND_LENGTH, "exec %s '%s' '%s' '%u' '%u' '%u' '%lu' '%s' '%s' '%s' '%s' '%s' '" CALCULATED_NUMBER_FORMAT_ZERO "' '" CALCULATED_NUMBER_FORMAT_ZERO "' '%s' '%u' '%u' '%s' '%s' '%s' '%s' '%s' '%s' '%d' '%d' '%s' '%s' '%s' '%s' '%s'",
358 exec,
359 recipient,
360 host->registry_hostname,
@@ -383,7 +383,8 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
383 buffer_tostring(warn_alarms),
384 buffer_tostring(crit_alarms),
385 ae->classification?ae->classification:"Unknown",
386 - edit_command
386 + edit_command,
387 + host != localhost ? host->machine_guid:""
388 );
389
390 ae->flags |= HEALTH_ENTRY_FLAG_EXEC_RUN;
health/notifications/alarm-notify.sh.in
+6 -1
@@ -244,6 +244,7 @@ else
244 total_crit_alarms="${26}" # List of alarms in critical state
245 classification="${27}" # The class field from .conf files
246 edit_command_line="${28}" # The command to edit the alarm, with the line number
247 + child_machine_guid="${29}" # If populated, the notification is sent for a child
248 fi
249
250 # -----------------------------------------------------------------------------
@@ -2361,7 +2362,11 @@ if [ ${GOTOCLOUD} -eq 0 ]; then
2362 else
2363 # Temporarily disable alarm redirection, as the cloud endpoint no longer exists. This functionality will be restored after discussion on #9487. For now, just lead to netdata.cloud
2364 # Re-allow alarm redirection, for alarms 2.0, new template
2364 - goto_url="${NETDATA_REGISTRY_CLOUD_BASE_URL}/alarms/redirect?agentId=${NETDATA_REGISTRY_UNIQUE_ID}&${redirect_params}"
2365 + if [ -z "${child_machine_guid}" ]; then
2366 + goto_url="${NETDATA_REGISTRY_CLOUD_BASE_URL}/alarms/redirect?agentId=${NETDATA_REGISTRY_UNIQUE_ID}&${redirect_params}"
2367 + else
2368 + goto_url="${NETDATA_REGISTRY_CLOUD_BASE_URL}/alarms/redirect?agentId=${NETDATA_REGISTRY_UNIQUE_ID}&childId=${child_machine_guid}&${redirect_params}"
2369 + fi
2370 fi
2371
2372 # the severity of the alarm