]> arthur.barton.de Git - netdata.git/commitdiff
jump to alarm chart and open alarms modal when clicking on an alarm URL
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 10 Sep 2016 00:39:24 +0000 (03:39 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 10 Sep 2016 00:39:24 +0000 (03:39 +0300)
plugins.d/alarm-notify.sh
web/goto-host-from-alarm.html
web/index.html

index bd2557c586f483dd8e146f13778a7c58f684f8d8..cdaed226b93eed263ed1dd391b58ad91a45989f8 100755 (executable)
@@ -325,7 +325,7 @@ send_slack() {
         for channel in ${channels}
         do
             httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null -X POST --data-urlencode \
-                "payload={\"channel\": \"#${channel}\", \"username\": \"${username}\", \"text\": \"${hostname} ${status_message} about ${author} ${raised_for} - click <${goto_url}|here> to view the netdata dashboard.\", \"icon_url\": \"${image}\", \"attachments\": [{\"fallback\": \"${alarm} - ${info}\", \"color\": \"${color}\", \"title\": \"${alarm}\", \"title_link\": \"${goto_url}\", \"text\": \"${info}\", \"footer\": \"netdata\", \"footer_icon\": \"${NETDATA_REGISTRY_URL}/images/seo-performance-128.png\", \"ts\": ${when}}]}" \
+                "payload={\"channel\": \"#${channel}\", \"username\": \"${username}\", \"text\": \"${hostname} ${status_message} - ${author} ${raised_for} - click <${goto_url}|here> to view the netdata dashboard.\", \"icon_url\": \"${image}\", \"attachments\": [{\"fallback\": \"${alarm} - ${info}\", \"color\": \"${color}\", \"title\": \"${alarm}\", \"title_link\": \"${goto_url}\", \"text\": \"${info}\", \"footer\": \"netdata\", \"footer_icon\": \"${NETDATA_REGISTRY_URL}/images/seo-performance-128.png\", \"ts\": ${when}}]}" \
                 "${webhook}")
 
             if [ "${httpcode}" == "200" ]
index deab6b8b5d535e64bb000e3a6ef65a9d5be75815..6cbca405933520847f0466442ffb175e06e45995 100755 (executable)
     <meta name="apple-mobile-web-app-capable" content="yes">
     <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
 
-    <script>var netdataRegistry = true;</script>
+    <script>
+        var netdataRegistry = true;
+        var netdataTheme = 'slate';
+        var netdataShowHelp = true;
+    </script>
     <script type="text/javascript" src="dashboard.js?v46"></script>
 
     <script>
@@ -20,7 +24,6 @@
         chart: null,
         family: null,
         hasProperty: function(property) {
-            // console.log('checking property ' + property + ' of type ' + typeof(this[property]));
             return typeof this[property] !== 'undefined';
         }
     };
             if(urlOptions.hasProperty(p[0]) && typeof p[1] !== 'undefined')
                 urlOptions[p[0]] = p[1];
         }
-
-        console.log(urlOptions);
     }
 
     function netdataURL(url) {
-        return url + '#' + urlOptions.family;
+        return url + '#top;show_alarms=true;chart=' + urlOptions.chart + ';family=' + urlOptions.family;
     }
 
     var gotoServerValidateRemaining = 0;
     var gotoServerMiddleClick = false;
     var gotoServerStop = false;
     function gotoServerValidateUrl(id, guid, url) {
-        console.log(id);
-        console.log(guid);
-        console.log(url);
-
         var penaldy = 0;
         if(document.location.toString().startsWith('http://') && url.toString().startsWith('https://'))
                 // we penalize https only if the current url is http
@@ -63,7 +60,6 @@
 
             NETDATA.registry.hello(url, function(data) {
                 if (data) {
-                    // console.log('OK ' + id + ' URL: ' + url);
                     document.getElementById(guid + '-' + id + '-status').innerHTML = "OK";
 
                     if(!gotoServerStop) {
@@ -75,7 +71,7 @@
                             document.getElementById('gotoServerResponse').innerHTML = '<b>Opening new window to ' + NETDATA.registry.machines[guid].name + '<br/><a href="' + finalURL + '">' + url + '</a></b><br/>(check your pop-up blocker if it fails)';
                         }
                         else
-                            document.location = finalURL;
+                            console.log(document.location); // = finalURL;
                     }
                 }
                 else {
             var len = machines_array.length;
             while(len--) {
                 if(machines_array[len].name === urlOptions.host) {
-                    console.log(machines_array[len]);
-
                     var ulen = machines_array[len].alternate_urls.length;
                     gotoServerValidateRemaining = ulen;
                     while(ulen--)
                         gotoServerValidateUrl(ulen, machines_array[len].guid, machines_array[len].alternate_urls[ulen]);
-
                     return;
                 }
             }
 </head>
 <body>
 <div class="container" id="">
-    <div id="bodylog" style="padding-top: 40px; font-size: 18px;">
+    <div id="bodylog" style="padding-top: 10vh; font-size: 2vh;">
         Please wait...
 
         <div style="padding-top: 20px;">
-            <table id="gotoServerList">
+            <table id="gotoServerList" class="table">
             </table>
         </div>
         <p style="padding-top: 10px;"><small>
index 3ea587b52976f0ec3cbd837fe9215ac431d86cb9..214d4b19d1e03843899a73b4c962dcb25533129a 100644 (file)
             after: 0,
             before: 0,
             nowelcome: 0,
+            show_alarms: 0,
+            chart: null,
+            family: null,
             hasProperty: function(property) {
                 // console.log('checking property ' + property + ' of type ' + typeof(this[property]));
                 return typeof this[property] !== 'undefined';
@@ -2559,6 +2562,12 @@ function renderChartsAndMenu(data) {
 
         // index the chart in the menu/submenu
         menus[charts[c].menu].submenus[charts[c].submenu].charts.push(charts[c]);
+
+        // console.log(urlOptions.chart + ' === ' + c);
+        if(urlOptions.chart === c) {
+            urlOptions.hash = '#' + name2id(charts[c].menu + '_' + charts[c].submenu)
+            // console.log('hash = ' + urlOptions.hash);
+        }
     }
 
     // propagate the descriptive subname given to QoS
@@ -2777,7 +2786,7 @@ function alarmsUpdateModal() {
                         active += '<tr><th class="text-center" colspan="2"><h4>' + family + '</h4></th></tr>';
                     }
                     count_active++;
-                    active += alarm_to_html(alarm, false);
+                    active += alarm_to_html(alarm, true);
                 }
 
                 count_all++;
@@ -3304,6 +3313,9 @@ function finalizePage() {
         }, 2000);
     }
     else notifyForUpdate();
+
+    if(urlOptions.show_alarms === 'true')
+        setTimeout(function() { $('#alarmsModal').modal('show'); }, 1000);
 }
 
 function resetDashboardOptions() {