jump to alarm chart and open alarms modal when clicking on an alarm URL
Costa Tsaousis (ktsaou) committed
Sep 10, 2016 at 03:39 UTC
f2451eb15866db963325a5027ee20acf18b59283
3 files changed
+23
-18
plugins.d/alarm-notify.sh
+1
-1
@@ -325,7 +325,7 @@ send_slack() {
325
for channel in ${channels}
326
do
327
httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null -X POST --data-urlencode \
328
- "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}}]}" \
328
+ "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}}]}" \
329
"${webhook}")
330
331
if [ "${httpcode}" == "200" ]
web/goto-host-from-alarm.html
+9
-16
@@ -11,7 +11,11 @@
11
<meta name="apple-mobile-web-app-capable" content="yes">
12
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
13
14
- <script>var netdataRegistry = true;</script>
14
+ <script>
15
+ var netdataRegistry = true;
16
+ var netdataTheme = 'slate';
17
+ var netdataShowHelp = true;
18
+ </script>
19
<script type="text/javascript" src="dashboard.js?v46"></script>
20
21
<script>
@@ -20,7 +24,6 @@
24
chart: null,
25
family: null,
26
hasProperty: function(property) {
23
- // console.log('checking property ' + property + ' of type ' + typeof(this[property]));
27
return typeof this[property] !== 'undefined';
28
}
29
};
@@ -34,22 +37,16 @@
37
if(urlOptions.hasProperty(p[0]) && typeof p[1] !== 'undefined')
38
urlOptions[p[0]] = p[1];
39
}
37
-
38
- console.log(urlOptions);
40
}
41
42
function netdataURL(url) {
42
- return url + '#' + urlOptions.family;
43
+ return url + '#top;show_alarms=true;chart=' + urlOptions.chart + ';family=' + urlOptions.family;
44
}
45
46
var gotoServerValidateRemaining = 0;
47
var gotoServerMiddleClick = false;
48
var gotoServerStop = false;
49
function gotoServerValidateUrl(id, guid, url) {
49
- console.log(id);
50
- console.log(guid);
51
- console.log(url);
52
-
50
var penaldy = 0;
51
if(document.location.toString().startsWith('http://') && url.toString().startsWith('https://'))
52
// we penalize https only if the current url is http
@@ -63,7 +60,6 @@
60
61
NETDATA.registry.hello(url, function(data) {
62
if (data) {
66
- // console.log('OK ' + id + ' URL: ' + url);
63
document.getElementById(guid + '-' + id + '-status').innerHTML = "OK";
64
65
if(!gotoServerStop) {
@@ -75,7 +71,7 @@
71
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)';
72
}
73
else
78
- document.location = finalURL;
74
+ console.log(document.location); // = finalURL;
75
}
76
}
77
else {
@@ -95,13 +91,10 @@
91
var len = machines_array.length;
92
while(len--) {
93
if(machines_array[len].name === urlOptions.host) {
98
- console.log(machines_array[len]);
99
-
94
var ulen = machines_array[len].alternate_urls.length;
95
gotoServerValidateRemaining = ulen;
96
while(ulen--)
97
gotoServerValidateUrl(ulen, machines_array[len].guid, machines_array[len].alternate_urls[ulen]);
104
-
98
return;
99
}
100
}
@@ -125,11 +118,11 @@
118
</head>
119
<body>
120
<div class="container" id="">
128
- <div id="bodylog" style="padding-top: 40px; font-size: 18px;">
121
+ <div id="bodylog" style="padding-top: 10vh; font-size: 2vh;">
122
Please wait...
123
124
<div style="padding-top: 20px;">
132
- <table id="gotoServerList">
125
+ <table id="gotoServerList" class="table">
126
</table>
127
</div>
128
<p style="padding-top: 10px;"><small>
web/index.html
+13
-1
@@ -409,6 +409,9 @@
409
after: 0,
410
before: 0,
411
nowelcome: 0,
412
+ show_alarms: 0,
413
+ chart: null,
414
+ family: null,
415
hasProperty: function(property) {
416
// console.log('checking property ' + property + ' of type ' + typeof(this[property]));
417
return typeof this[property] !== 'undefined';
@@ -2559,6 +2562,12 @@ function renderChartsAndMenu(data) {
2562
2563
// index the chart in the menu/submenu
2564
menus[charts[c].menu].submenus[charts[c].submenu].charts.push(charts[c]);
2565
+
2566
+ // console.log(urlOptions.chart + ' === ' + c);
2567
+ if(urlOptions.chart === c) {
2568
+ urlOptions.hash = '#' + name2id(charts[c].menu + '_' + charts[c].submenu)
2569
+ // console.log('hash = ' + urlOptions.hash);
2570
+ }
2571
}
2572
2573
// propagate the descriptive subname given to QoS
@@ -2777,7 +2786,7 @@ function alarmsUpdateModal() {
2786
active += '<tr><th class="text-center" colspan="2"><h4>' + family + '</h4></th></tr>';
2787
}
2788
count_active++;
2780
- active += alarm_to_html(alarm, false);
2789
+ active += alarm_to_html(alarm, true);
2790
}
2791
2792
count_all++;
@@ -3304,6 +3313,9 @@ function finalizePage() {
3313
}, 2000);
3314
}
3315
else notifyForUpdate();
3316
+
3317
+ if(urlOptions.show_alarms === 'true')
3318
+ setTimeout(function() { $('#alarmsModal').modal('show'); }, 1000);
3319
}
3320
3321
function resetDashboardOptions() {