summaryrefslogtreecommitdiffstats
path: root/health/health_json.c
diff options
context:
space:
mode:
authorEmmanuel Vasilakis <mrzammler@mm.st>2021-05-31 16:29:47 +0300
committerGitHub <noreply@github.com>2021-05-31 16:29:47 +0300
commit9f40c4b12c1047c3489ba07dcf1c1e9b647d1835 (patch)
tree2c9b9aaa1bd19b9a7e5f84e7b4488345039190ab /health/health_json.c
parent5bce2d9a8196a90e9d3972b90934d79bad4bb8e1 (diff)
Provide UTC offset in seconds and edit health config command (#11051)
* add abbreviated timezone, utc offset in seconds, and edit health alarm command rebased * formating * use str2i instead of atoi
Diffstat (limited to 'health/health_json.c')
-rw-r--r--health/health_json.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/health/health_json.c b/health/health_json.c
index 4df44611ca..d3c3073215 100644
--- a/health/health_json.c
+++ b/health/health_json.c
@@ -14,9 +14,13 @@ 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");
+
buffer_sprintf(wb,
"\n\t{\n"
"\t\t\"hostname\": \"%s\",\n"
+ "\t\t\"utc_offset\": %d,\n"
+ "\t\t\"timezone\": \"%s\",\n"
"\t\t\"unique_id\": %u,\n"
"\t\t\"alarm_id\": %u,\n"
"\t\t\"alarm_event_id\": %u,\n"
@@ -34,6 +38,7 @@ void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, RRDHOST *host)
"\t\t\"recipient\": \"%s\",\n"
"\t\t\"exec_code\": %d,\n"
"\t\t\"source\": \"%s\",\n"
+ "\t\t\"command\": \"%s\",\n"
"\t\t\"units\": \"%s\",\n"
"\t\t\"when\": %lu,\n"
"\t\t\"duration\": %lu,\n"
@@ -49,6 +54,8 @@ void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, RRDHOST *host)
"\t\t\"last_repeat\": \"%lu\",\n"
"\t\t\"silenced\": \"%s\",\n"
, host->hostname
+ , host->utc_offset
+ , host->abbrev_timezone
, ae->unique_id
, ae->alarm_id
, ae->alarm_event_id
@@ -66,6 +73,7 @@ void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, RRDHOST *host)
, ae->recipient?ae->recipient:host->health_default_recipient
, ae->exec_code
, ae->source
+ , edit_command
, ae->units?ae->units:""
, (unsigned long)ae->when
, (unsigned long)ae->duration
@@ -114,6 +122,7 @@ void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, RRDHOST *host)
buffer_strcat(wb, "\t}");
freez(replaced_info);
+ freez(edit_command);
}
void health_alarm_log2json(RRDHOST *host, BUFFER *wb, uint32_t after, char *chart) {