]> arthur.barton.de Git - netdata.git/commitdiff
dashboard does not show past CLEAR notifications; fixes #1035
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Wed, 28 Sep 2016 21:40:30 +0000 (00:40 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Wed, 28 Sep 2016 21:40:30 +0000 (00:40 +0300)
src/appconfig.c
src/health.c
src/health.h
web/dashboard.js

index dd51258cc038baff6f4e0a10ff478f113e17ef05..947407484135d7ce56a6d2a132af2c9869ec834d 100644 (file)
@@ -467,6 +467,7 @@ void generate_config(BUFFER *wb, int only_changed)
                     "# netdata configuration\n"
                     "#\n"
                     "# You can download the latest version of this file, using:\n"
+                    "#\n"
                     "#  wget -O /etc/netdata/netdata.conf http://localhost:19999/netdata.conf\n"
                     "# or\n"
                     "#  curl -o /etc/netdata/netdata.conf http://localhost:19999/netdata.conf\n"
index 227f30492ed9e791f484139e21ede0d5d74fe032..596b143a49d3b7d55fa82e90d0f2a1117a2869f6 100644 (file)
@@ -152,9 +152,10 @@ static inline void health_alarm_log(RRDHOST *host,
     ALARM_ENTRY *t;
     for(t = host->health_log.alarms ; t ; t = t->next) {
         if(t != ae && t->alarm_id == ae->alarm_id) {
-            if(!(t->notifications & HEALTH_ENTRY_NOTIFICATIONS_UPDATED) && !t->updated_by) {
+            if(!(t->notifications & HEALTH_ENTRY_NOTIFICATIONS_UPDATED) && !t->updated_by_id) {
                 t->notifications |= HEALTH_ENTRY_NOTIFICATIONS_UPDATED;
-                t->updated_by = ae;
+                t->updated_by_id = ae->unique_id;
+                ae->updates_id = t->unique_id;
 
                 if((t->new_status == RRDCALC_STATUS_WARNING || t->new_status == RRDCALC_STATUS_CRITICAL) &&
                    (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
                            "\t\t\"status\": \"%s\",\n"
                            "\t\t\"old_status\": \"%s\",\n"
                            "\t\t\"delay\": %d,\n"
-                           "\t\t\"delay_up_to_timestamp\": %lu,\n",
+                           "\t\t\"delay_up_to_timestamp\": %lu,\n"
+                           "\t\t\"updated_by_id\": %u,\n"
+                           "\t\t\"updates_id\": %u,\n",
                    host->hostname,
                    ae->unique_id,
                    ae->alarm_id,
@@ -1878,7 +1881,9 @@ static inline void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, R
                    rrdcalc_status2string(ae->new_status),
                    rrdcalc_status2string(ae->old_status),
                    ae->delay,
-                   (unsigned long)ae->delay_up_to_timestamp
+                   (unsigned long)ae->delay_up_to_timestamp,
+                   ae->updated_by_id,
+                   ae->updates_id
     );
 
     buffer_strcat(wb, "\t\t\"value\":");
index 17a0f75c4c8fb5dcca4a3c7e1200d1d536abd9eb..9d5834fcafefb8f69c178415e52651d7b79664ce 100644 (file)
@@ -305,7 +305,9 @@ typedef struct alarm_entry {
     int delay;
     time_t delay_up_to_timestamp;
 
-    struct alarm_entry *updated_by;
+    uint32_t updated_by_id;
+    uint32_t updates_id;
+    
     struct alarm_entry *next;
 } ALARM_ENTRY;
 
index f54c38727c92e699b15121f4819739eb72982110..a4cdc31207aecb4da61da070b777c3e88238033c 100644 (file)
 
         notifications: false,           // when true, the browser supports notifications (may not be granted though)
         last_notification_id: 0,        // the id of the last alarm_log we have raised an alarm for
+        first_notification_id: 0,       // the id of the first alarm_log we have seen in this session
         // notifications_shown: new Array(),
 
         server: null,                   // the server to connect to for fetching alarms
                     return;
 
                 case 'CLEAR':
-                    if(NETDATA.alarms.last_notification_id === 0) {
+                    if(typeof entry.updates_id === 'number' && entry.updates_id < NETDATA.alarms.first_notification_id) {
                         // console.log('alarm ' + entry.unique_id + ' is not current');
                         return;
                     }
             NETDATA.alarms.server = host;
 
             NETDATA.alarms.last_notification_id = NETDATA.localStorageGet('last_notification_id', NETDATA.alarms.last_notification_id, null);
+            NETDATA.alarms.first_notification_id = NETDATA.alarms.last_notification_id;
 
             if(NETDATA.alarms.onclick === null)
                 NETDATA.alarms.onclick = NETDATA.alarms.scrollToAlarm;