]> arthur.barton.de Git - netdata.git/blobdiff - web/index.html
Merge branch 'master' into ab-debian
[netdata.git] / web / index.html
index 7bba3f4d5ef465b5563991ec722d1f73f7d9b18f..3283b16e89cf53e215ca0a6758a30758ff6a783b 100644 (file)
@@ -35,7 +35,7 @@
     <meta property="og:site_name"          content="netdata"/>
     <meta property="og:title"              content="Get control of your Linux Servers. Simple. Effective. Awesome." />
     <meta property="og:description"        content="Unparalleled insights, in real-time, of everything happening on your Linux systems and applications, with stunning, interactive web dashboards and powerful performance and health alarms." />
-    <meta property="og:image"              content="https://cloud.githubusercontent.com/assets/2662304/20910305/65d10354-bb69-11e6-8128-c44b547517b4.png" />
+    <meta property="og:image"              content="https://cloud.githubusercontent.com/assets/2662304/22945737/e98cd0c6-f2fd-11e6-96f1-5501934b0955.png" />
     <meta property="og:image:type"         content="image/png" />
     <meta property="fb:app_id"             content="1200089276712916" />
 
         var netdataRegistryCallback = function(machines_array) {
             var el = '';
             var a1 = '';
-            var found = 0;
+            var found = 0, hosted = 0;
+            var len, i, url, hostname, icon;
+
+            if(options.hosts.length > 1) {
+                // there are mirrored hosts here
+
+                el += '<li><a href="#" onClick="return false;" style="color: #666;" target="_blank">databases available on this host</a></li>';
+                a1 += '<li><a href="#" onClick="return false;"><i class="fa fa-info-circle" aria-hidden="true" style="color: #666;"></i></a></li>';
+
+                var base = document.location.origin.toString() + document.location.pathname.toString();
+                if(base.endsWith("/host/" + options.hostname + "/"))
+                    base = base.substring(0, base.length - ("/host/" + options.hostname + "/").toString().length);
+
+                if(base.endsWith("/"))
+                    base = base.substring(0, base.length - 1);
+
+                var master = options.hosts[0].hostname;
+                var sorted = options.hosts.sort(function(a, b) {
+                    if(a.hostname === master) return -1;
+                    if(a.hostname === b.hostname) return 0;
+                    else if(a.hostname > b.hostname) return 1;
+                    return -1;
+                });
+
+                i = 0;
+                len = sorted.length;
+                while(len--) {
+                    hostname = sorted[i].hostname;
+                    if(hostname == master) {
+                        url = base + "/";
+                        icon = "home";
+                    }
+                    else {
+                        url = base + "/host/" + hostname + "/";
+                        icon = "window-restore";
+                    }
+
+                    el += '<li id="registry_server_hosted_' + len.toString() + '"><a class="registry_link" href="' + url + '" onClick="return gotoHostedModalHandler(\'' + url + '\');">' + hostname + '</a></li>';
+                    a1 += '<li id="registry_action_hosted_' + len.toString() + '"><a class="registry_link" href="' + url + '" onClick="return gotoHostedModalHandler(\'' + url + '\');"><i class="fa fa-' + icon + '" aria-hidden="true" style="color: #999;"></i></a></li>';
+                    hosted++;
+                    i++;
+                }
+
+                el += '<li role="separator" class="divider"></li>';
+                a1 += '<li role="separator" class="divider"></li>';
+            }
 
             if(machines_array === null) {
                 var ret = loadLocalStorage("registryCallback");
                     return 0;
                 });
 
-                var len = machines.length;
+                len = machines.length;
                 while(len--) {
                     var u = machines[len];
                     found++;
             location.reload();
         }
 
+        function gotoHostedModalHandler(url) {
+            document.location = url + urlOptions.genHash();
+            return false;
+        }
+
         var gotoServerValidateRemaining = 0;
         var gotoServerMiddleClick = false;
         var gotoServerStop = false;
             categories_idx: {},
             families: [],
             families_idx: {},
+            hosts: [],
 
             chartsPerRow: 0,
-            chartsMinWidth: 1450,
+            // chartsMinWidth: 1450,
             chartsHeight: 180
         };
 
         function chartsPerRow(total) {
             if(options.chartsPerRow === 0) {
-                var width = Math.floor(total / options.chartsMinWidth);
-                if(width === 0) width = 1;
-                return width;
+                return 1;
+                //var width = Math.floor(total / options.chartsMinWidth);
+                //if(width === 0) width = 1;
+                //return width;
             }
             else return options.chartsPerRow;
         }
 
         // ----------------------------------------------------------------------------
 
+        // user editable information
+        var customDashboard = {
+            menu: {},
+            submenu: {},
+            context: {}
+        };
+
+        // netdata standard information
         var netdataDashboard = {
             sparklines_registry: {},
             os: 'unknown',
                     chart.menu = chart.type;
                     if(parts.length > 2 && parts[1] === 'cache')
                         chart.menu_pattern = tmp + '_' + parts[1];
+                    else if(parts.length > 1)
+                        chart.menu_pattern = tmp;
                     break;
 
                 case 'bind':
                     chart.menu = chart.type;
                     if(parts.length > 2 && parts[1] === 'rndc')
                         chart.menu_pattern = tmp + '_' + parts[1];
+                    else if(parts.length > 1)
+                        chart.menu_pattern = tmp;
                     break;
 
                 case 'cgroup':
                     chart.menu = chart.type;
                     if(parts.length > 2 && parts[1] === 'dhcpd')
                         chart.menu_pattern = tmp + '_' + parts[1];
+                    else if(parts.length > 1)
+                        chart.menu_pattern = tmp;
                     break;
 
                 case 'ovpn':
                     chart.menu = chart.type;
                     if(parts.length > 3 && parts[1] === 'status' && parts[2] === 'log')
                         chart.menu_pattern = tmp + '_' + parts[1];
+                    else if(parts.length > 1)
+                        chart.menu_pattern = tmp;
                     break;
 
                 case 'smartd':
                     chart.menu = chart.type;
                     if(parts.length > 2 && parts[1] === 'log')
                         chart.menu_pattern = tmp + '_' + parts[1];
-                    break;
-
-                case 'dovecot':
-                case 'exim':
-                case 'hddtemp':
-                case 'ipfs':
-                case 'memcached':
-                case 'mysql':
-                case 'named':
-                case 'nginx':
-                case 'nut':
-                case 'phpfpm':
-                case 'postfix':
-                case 'postgres':
-                case 'redis':
-                case 'retroshare':
-                case 'smawebbox':
-                case 'snmp':
-                case 'squid':
-                case 'tomcat':
-                    chart.menu = chart.type;
-                    chart.menu_pattern = tmp;
+                    else if(parts.length > 1)
+                        chart.menu_pattern = tmp;
                     break;
 
                 case 'tc':
 
                 default:
                     chart.menu = chart.type;
+                    if(parts.length > 1)
+                        chart.menu_pattern = tmp;
                     break;
             }
 
 
             sidebar += '<li class="" style="padding-top:15px;"><a href="https://github.com/firehol/netdata/wiki/Add-more-charts-to-netdata" target="_blank"><i class="fa fa-plus" aria-hidden="true"></i> add more charts</a></li>';
             sidebar += '<li class=""><a href="https://github.com/firehol/netdata/wiki/Add-more-alarms-to-netdata" target="_blank"><i class="fa fa-plus" aria-hidden="true"></i> add more alarms</a></li>';
-            sidebar += '<li class="" style="margin:20px;color:#666;"><small>netdata on <b>' + data.hostname.toString() + '</b>, collects every ' + ((data.update_every == 1)?'second':data.update_every.toString() + ' seconds') + ' <b>' + data.dimensions_count.toLocaleString() + '</b> metrics, presented as <b>' + data.charts_count.toLocaleString() + '</b> charts and monitored by <b>' + data.alarms_count.toLocaleString() + '</b> alarms, using ' + Math.round(data.rrd_memory_bytes / 1024 / 1024).toLocaleString() + ' MB of memory for ' + Math.round(data.history / (3600/data.update_every)).toLocaleString() + ' ' + ((data.history == (3600/data.update_every))?'hour':'hours').toString() + ' of real-time history.<br/>&nbsp;<br/><b>netdata</b><br/>v' +  data.version.toString() +'</small></li>';
+            sidebar += '<li class="" style="margin:20px;color:#666;"><small>netdata on <b>' + data.hostname.toString() + '</b>, collects every ' + ((data.update_every == 1)?'second':data.update_every.toString() + ' seconds') + ' <b>' + data.dimensions_count.toLocaleString() + '</b> metrics, presented as <b>' + data.charts_count.toLocaleString() + '</b> charts and monitored by <b>' + data.alarms_count.toLocaleString() + '</b> alarms, using ' + Math.round(data.rrd_memory_bytes / 1024 / 1024).toLocaleString() + ' MB of memory for ' + seconds4human(data.update_every * data.history) + ' of real-time history.<br/>&nbsp;<br/><b>netdata</b><br/>v' +  data.version.toString() +'</small></li>';
             sidebar += '</ul>';
             div.innerHTML = html;
             document.getElementById('sidebar').innerHTML = sidebar;
                     return t.toLocaleDateString() + space + t.toLocaleTimeString();
                 }
 
-                function seconds4human(seconds, options) {
-                    var default_options = {
-                        now: 'now',
-                        space: '&nbsp;',
-                        negative_suffix: 'ago',
-                        hour: 'hour',
-                        hours: 'hours',
-                        minute: 'minute',
-                        minutes: 'minutes',
-                        second: 'second',
-                        seconds: 'seconds',
-                        and: 'and'
-                    };
-
-                    if(typeof options !== 'object')
-                        options = default_options;
-                    else {
-                        var x;
-                        for(x in default_options) {
-                            if(typeof options[x] !== 'string')
-                                options[x] = default_options[x];
-                        }
-                    }
-
-                    if(typeof seconds === 'string')
-                        seconds = parseInt(seconds);
-
-                    if(seconds === 0)
-                        return options.now;
-
-                    var suffix = '';
-                    if(seconds < 0) {
-                        seconds = -seconds;
-                        if(options.negative_suffix !== '') suffix = options.space + options.negative_suffix;
-                    }
-
-                    var hours = Math.floor(seconds / 3600);
-                    seconds -= (hours * 3600);
-
-                    var minutes = Math.floor(seconds / 60);
-                    seconds -= (minutes * 60);
-
-                    var txt = '';
-
-                    if(hours > 1) txt += hours.toString() + options.space + options.hours;
-                    else if(hours === 1) txt += hours.toString() + options.space + options.hour;
-
-                    if(hours > 0 && minutes > 0 && seconds == 0)
-                        txt += options.space + options.and + options.space;
-                    else if(hours > 0 && minutes > 0 && seconds > 0)
-                        txt += ',' + options.space;
-
-                    if(minutes > 1) txt += minutes.toString() + options.space + options.minutes;
-                    else if(minutes === 1) txt += minutes.toString() + options.space + options.minute;
-
-                    if((minutes > 0 || minutes > 0) && seconds > 0)
-                        txt += options.space + options.and + options.space;
-
-                    if(seconds > 1) txt += Math.floor(seconds).toString() + options.space + options.seconds;
-                    else if(seconds === 1) txt += Math.floor(seconds).toString() + options.space + options.second;
-
-                    return txt + suffix;
-                }
-
                 function alarm_lookup_explain(alarm, chart) {
                     var dimensions = ' of all values ';
 
             });
         }
 
+        function seconds4human(seconds, options) {
+            var default_options = {
+                now: 'now',
+                space: '&nbsp;',
+                negative_suffix: 'ago',
+                hour: 'hour',
+                hours: 'hours',
+                minute: 'minute',
+                minutes: 'minutes',
+                second: 'second',
+                seconds: 'seconds',
+                and: 'and'
+            };
+
+            if(typeof options !== 'object')
+                options = default_options;
+            else {
+                var x;
+                for(x in default_options) {
+                    if(typeof options[x] !== 'string')
+                        options[x] = default_options[x];
+                }
+            }
+
+            if(typeof seconds === 'string')
+                seconds = parseInt(seconds);
+
+            if(seconds === 0)
+                return options.now;
+
+            var suffix = '';
+            if(seconds < 0) {
+                seconds = -seconds;
+                if(options.negative_suffix !== '') suffix = options.space + options.negative_suffix;
+            }
+
+            var hours = Math.floor(seconds / 3600);
+            seconds -= (hours * 3600);
+
+            var minutes = Math.floor(seconds / 60);
+            seconds -= (minutes * 60);
+
+            var txt = '';
+
+            if(hours > 1) txt += hours.toString() + options.space + options.hours;
+            else if(hours === 1) txt += hours.toString() + options.space + options.hour;
+
+            if(hours > 0 && minutes > 0 && seconds == 0)
+                txt += options.space + options.and + options.space;
+            else if(hours > 0 && minutes > 0 && seconds > 0)
+                txt += ',' + options.space;
+
+            if(minutes > 1) txt += minutes.toString() + options.space + options.minutes;
+            else if(minutes === 1) txt += minutes.toString() + options.space + options.minute;
+
+            if((minutes > 0 || minutes > 0) && seconds > 0)
+                txt += options.space + options.and + options.space;
+
+            if(seconds > 1) txt += Math.floor(seconds).toString() + options.space + options.seconds;
+            else if(seconds === 1) txt += Math.floor(seconds).toString() + options.space + options.second;
+
+            return txt + suffix;
+        }
+
         function alarmsCallback(data) {
             var count = 0;
             for(x in data.alarms) {
                 document.getElementById('alarms_count_badge').innerHTML = '';
         }
 
+        function initializeDynamicDashboardWithData(data) {
+            if(data !== null) {
+                options.hostname = data.hostname;
+                options.data = data;
+                options.version = data.version;
+                netdataDashboard.os = data.os;
+
+                if(typeof data.hosts != 'undefined')
+                    options.hosts = data.hosts;
+
+                // update the dashboard hostname
+                document.getElementById('hostname').innerHTML = options.hostname;
+                document.getElementById('hostname').href = NETDATA.serverDefault;
+                document.getElementById('netdataVersion').innerHTML = options.version;
+
+                // update the dashboard title
+                document.title = options.hostname + ' netdata dashboard';
+
+                // close the splash screen
+                $("#loadOverlay").css("display","none");
+
+                // create a chart_by_name index
+                data.charts_by_name = {};
+                var charts = data.charts;
+                var x;
+                for(x in charts) {
+                    if(!charts.hasOwnProperty(x)) continue;
+
+                    var chart = charts[x];
+                    data.charts_by_name[chart.name] = chart;
+                }
+
+                // render all charts
+                renderChartsAndMenu(data);
+            }
+        }
+
         function initializeDynamicDashboard(netdata_url) {
             if(typeof netdata_url === 'undefined' || netdata_url === null)
                 netdata_url = NETDATA.serverDefault;
 
                 // download all the charts the server knows
                 NETDATA.chartRegistry.downloadAll(netdata_url, function(data) {
-                    if(data !== null) {
-                        options.hostname = data.hostname;
-                        options.data = data;
-                        options.version = data.version;
-                        netdataDashboard.os = data.os;
-
-                        // update the dashboard hostname
-                        document.getElementById('hostname').innerHTML = options.hostname;
-                        document.getElementById('hostname').href = NETDATA.serverDefault;
-                        document.getElementById('netdataVersion').innerHTML = options.version;
-
-                        // update the dashboard title
-                        document.title = options.hostname + ' netdata dashboard';
-
-                        // close the splash screen
-                        $("#loadOverlay").css("display","none");
-
-                        // create a chart_by_name index
-                        data.charts_by_name = {};
-                        var charts = data.charts;
-                        var x;
-                        for(x in charts) {
-                            if(!charts.hasOwnProperty(x)) continue;
-
-                            var chart = charts[x];
-                            data.charts_by_name[chart.name] = chart;
+                    if(data != null) {
+                        if(typeof data.custom_info !== 'undefined' && data.custom_info !== "") {
+                            loadJs(data.custom_info, function () {
+                                $.extend(true, netdataDashboard, customDashboard);
+                                initializeDynamicDashboardWithData(data);
+                            });
+                        }
+                        else {
+                            initializeDynamicDashboardWithData(data);
                         }
-
-                        // render all charts
-                        renderChartsAndMenu(data);
                     }
                 });
             });
             })
             .done(function(data) {
                 data = data.replace(/(\r\n|\n|\r| |\t)/gm,"");
-
-                var c = getNetdataCommitIdFromVersion();
-                if(c !== null && data.length === 40 && data.substring(0, 7) !== c) {
-                    versionLog('Installed files commit id and internal netdata git commit id do not match');
-                    data = c;
+                if(data.length !== 40) {
+                    var c = getNetdataCommitIdFromVersion();
+                    if(c === null) versionLog('Cannot find the git commit id of netdata.');
+                    callback(c);
                 }
-
-                if(data.length >= 7) {
+                else {
                     versionLog('Installed git commit id of netdata is ' + data);
                     document.getElementById('netdataCommitId').innerHTML = data.substring(0, 7);
                     callback(data);
             });
 
             NETDATA.requiredJs.push({
-                url: NETDATA.serverDefault + 'dashboard_info.js?v20170211-20',
+                url: NETDATA.serverDefault + 'dashboard_info.js?v20170325-1',
                 async: false,
                 isAlreadyLoaded: function() { return false; }
             });
     </div>
 </body>
 </html>
-<script type="text/javascript" src="dashboard.js?v20170211-2"></script>
+<script type="text/javascript" src="dashboard.js?v20170325-1"></script>