mirror of
https://github.com/netdata/netdata.git
synced 2025-04-17 11:12:42 +00:00
Add localhost hostname to the edit_command (#11793)
* include localhost hostname in edit_command * since the edit_command now contains the localhost name, dont pass it again to the script
This commit is contained in:
parent
8c201ccadf
commit
3296f78436
5 changed files with 11 additions and 23 deletions
database/sqlite
health
|
@ -209,7 +209,7 @@ void aclk_push_alert_event(struct aclk_database_worker_config *wc, struct aclk_d
|
|||
|
||||
char *edit_command = sqlite3_column_bytes(res, 16) > 0 ?
|
||||
health_edit_command_from_source((char *)sqlite3_column_text(res, 16)) :
|
||||
strdupz("UNKNOWN=0");
|
||||
strdupz("UNKNOWN=0=UNKNOWN");
|
||||
alarm_log.command = strdupz(edit_command);
|
||||
|
||||
alarm_log.duration = (time_t) sqlite3_column_int64(res, 6);
|
||||
|
@ -695,7 +695,7 @@ void aclk_mark_alert_cloud_ack(char *uuid_str, uint64_t alerts_ack_sequence_id)
|
|||
#ifdef ENABLE_NEW_CLOUD_PROTOCOL
|
||||
void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_ENTRY *ae, RRDHOST *host)
|
||||
{
|
||||
char *edit_command = ae->source ? health_edit_command_from_source(ae->source) : strdupz("UNKNOWN=0");
|
||||
char *edit_command = ae->source ? health_edit_command_from_source(ae->source) : strdupz("UNKNOWN=0=UNKNOWN");
|
||||
char config_hash_id[GUID_LEN + 1];
|
||||
uuid_unparse_lower(ae->config_hash_id, config_hash_id);
|
||||
|
||||
|
|
|
@ -350,9 +350,9 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
|
|||
}
|
||||
}
|
||||
|
||||
char *edit_command = ae->source ? health_edit_command_from_source(ae->source) : strdupz("UNKNOWN=0");
|
||||
char *edit_command = ae->source ? health_edit_command_from_source(ae->source) : strdupz("UNKNOWN=0=UNKNOWN");
|
||||
|
||||
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'",
|
||||
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'",
|
||||
exec,
|
||||
recipient,
|
||||
host->registry_hostname,
|
||||
|
@ -381,8 +381,7 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
|
|||
buffer_tostring(warn_alarms),
|
||||
buffer_tostring(crit_alarms),
|
||||
ae->classification?ae->classification:"Unknown",
|
||||
edit_command,
|
||||
localhost->registry_hostname
|
||||
edit_command
|
||||
);
|
||||
|
||||
ae->flags |= HEALTH_ENTRY_FLAG_EXEC_RUN;
|
||||
|
|
|
@ -485,10 +485,11 @@ char *health_edit_command_from_source(const char *source)
|
|||
snprintfz(
|
||||
buffer,
|
||||
FILENAME_MAX,
|
||||
"sudo %s/edit-config health.d/%s=%s",
|
||||
"sudo %s/edit-config health.d/%s=%s=%s",
|
||||
netdata_configured_user_config_dir,
|
||||
file_no_path + 1,
|
||||
temp);
|
||||
temp,
|
||||
localhost->registry_hostname);
|
||||
} else
|
||||
buffer[0] = '\0';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ void health_string2json(BUFFER *wb, const char *prefix, const char *label, const
|
|||
}
|
||||
|
||||
void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, RRDHOST *host) {
|
||||
char *edit_command = ae->source ? health_edit_command_from_source(ae->source) : strdupz("UNKNOWN=0");
|
||||
char *edit_command = ae->source ? health_edit_command_from_source(ae->source) : strdupz("UNKNOWN=0=UNKNOWN");
|
||||
char config_hash_id[GUID_LEN + 1];
|
||||
uuid_unparse_lower(ae->config_hash_id, config_hash_id);
|
||||
|
||||
|
|
|
@ -243,7 +243,6 @@ else
|
|||
total_crit_alarms="${26}" # List of alarms in critical state
|
||||
classification="${27}" # The class field from .conf files
|
||||
edit_command_line="${28}" # The command to edit the alarm, with the line number
|
||||
sender_host="${29}" # The host sending this notification
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
@ -257,17 +256,6 @@ else
|
|||
host="${args_host}"
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Do the same for sender_host (find a suitable hostname to use, if netdata did not supply a hostname)
|
||||
|
||||
if [ -z ${sender_host} ]; then
|
||||
this_host=$(hostname -s 2>/dev/null)
|
||||
s_host="${this_host}"
|
||||
sender_host="${this_host}"
|
||||
else
|
||||
s_host="${sender_host}"
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# screen statuses we don't need to send a notification
|
||||
|
||||
|
@ -2856,7 +2844,7 @@ if [ -n "$total_crit_alarms" ]; then
|
|||
fi
|
||||
|
||||
if [ -n "$edit_command_line" ]; then
|
||||
IFS='=' read -r edit_command line <<<"$edit_command_line"
|
||||
IFS='=' read -r edit_command line s_host <<<"$edit_command_line"
|
||||
fi
|
||||
|
||||
IFS='' read -r -d '' email_html_part <<EOF
|
||||
|
@ -3340,7 +3328,7 @@ Content-Transfer-Encoding: 8bit
|
|||
<tr>
|
||||
<td align="left" style="font-size:0px;padding:10px 25px;padding-top:8px;padding-left:0;word-break:break-word;">
|
||||
<div style="font-family:Open Sans, sans-serif;font-size:12px;line-height:1.3;text-align:left;color:#35414A;">${edit_command} <br>
|
||||
The alarm to edit is at line {${line}}</div>
|
||||
<br>The alarm to edit is at line ${line}</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
Loading…
Add table
Reference in a new issue