dashboard does not show past CLEAR notifications; fixes #1035
Costa Tsaousis (ktsaou) committed
Sep 29, 2016 at 00:40 UTC
34d42c00b57d924cf804b0c83923ae5bc27852e2
4 files changed
+16
-6
src/appconfig.c
+1
@@ -467,6 +467,7 @@ void generate_config(BUFFER *wb, int only_changed)
467
"# netdata configuration\n"
468
"#\n"
469
"# You can download the latest version of this file, using:\n"
470
+ "#\n"
471
"# wget -O /etc/netdata/netdata.conf http://localhost:19999/netdata.conf\n"
472
"# or\n"
473
"# curl -o /etc/netdata/netdata.conf http://localhost:19999/netdata.conf\n"
src/health.c
+9
-4
@@ -152,9 +152,10 @@ static inline void health_alarm_log(RRDHOST *host,
152
ALARM_ENTRY *t;
153
for(t = host->health_log.alarms ; t ; t = t->next) {
154
if(t != ae && t->alarm_id == ae->alarm_id) {
155
- if(!(t->notifications & HEALTH_ENTRY_NOTIFICATIONS_UPDATED) && !t->updated_by) {
155
+ if(!(t->notifications & HEALTH_ENTRY_NOTIFICATIONS_UPDATED) && !t->updated_by_id) {
156
t->notifications |= HEALTH_ENTRY_NOTIFICATIONS_UPDATED;
157
- t->updated_by = ae;
157
+ t->updated_by_id = ae->unique_id;
158
+ ae->updates_id = t->unique_id;
159
160
if((t->new_status == RRDCALC_STATUS_WARNING || t->new_status == RRDCALC_STATUS_CRITICAL) &&
161
(t->old_status == RRDCALC_STATUS_WARNING || t->old_status == RRDCALC_STATUS_CRITICAL))
@@ -1854,7 +1855,9 @@ static inline void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, R
1855
"\t\t\"status\": \"%s\",\n"
1856
"\t\t\"old_status\": \"%s\",\n"
1857
"\t\t\"delay\": %d,\n"
1857
- "\t\t\"delay_up_to_timestamp\": %lu,\n",
1858
+ "\t\t\"delay_up_to_timestamp\": %lu,\n"
1859
+ "\t\t\"updated_by_id\": %u,\n"
1860
+ "\t\t\"updates_id\": %u,\n",
1861
host->hostname,
1862
ae->unique_id,
1863
ae->alarm_id,
@@ -1878,7 +1881,9 @@ static inline void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, R
1881
rrdcalc_status2string(ae->new_status),
1882
rrdcalc_status2string(ae->old_status),
1883
ae->delay,
1881
- (unsigned long)ae->delay_up_to_timestamp
1884
+ (unsigned long)ae->delay_up_to_timestamp,
1885
+ ae->updated_by_id,
1886
+ ae->updates_id
1887
);
1888
1889
buffer_strcat(wb, "\t\t\"value\":");
src/health.h
+3
-1
@@ -305,7 +305,9 @@ typedef struct alarm_entry {
305
int delay;
306
time_t delay_up_to_timestamp;
307
308
- struct alarm_entry *updated_by;
308
+ uint32_t updated_by_id;
309
+ uint32_t updates_id;
310
+
311
struct alarm_entry *next;
312
} ALARM_ENTRY;
313
web/dashboard.js
+3
-1
@@ -5621,6 +5621,7 @@
5621
5622
notifications: false, // when true, the browser supports notifications (may not be granted though)
5623
last_notification_id: 0, // the id of the last alarm_log we have raised an alarm for
5624
+ first_notification_id: 0, // the id of the first alarm_log we have seen in this session
5625
// notifications_shown: new Array(),
5626
5627
server: null, // the server to connect to for fetching alarms
@@ -5665,7 +5666,7 @@
5666
return;
5667
5668
case 'CLEAR':
5668
- if(NETDATA.alarms.last_notification_id === 0) {
5669
+ if(typeof entry.updates_id === 'number' && entry.updates_id < NETDATA.alarms.first_notification_id) {
5670
// console.log('alarm ' + entry.unique_id + ' is not current');
5671
return;
5672
}
@@ -5901,6 +5902,7 @@
5902
NETDATA.alarms.server = host;
5903
5904
NETDATA.alarms.last_notification_id = NETDATA.localStorageGet('last_notification_id', NETDATA.alarms.last_notification_id, null);
5905
+ NETDATA.alarms.first_notification_id = NETDATA.alarms.last_notification_id;
5906
5907
if(NETDATA.alarms.onclick === null)
5908
NETDATA.alarms.onclick = NETDATA.alarms.scrollToAlarm;