X-Git-Url: https://arthur.barton.de/gitweb/?p=netdata.git;a=blobdiff_plain;f=web%2Findex.html;h=b62306a2655ae56069a26e1bb909d0a1b94ee4e1;hp=b21998bdc0e08e8b43c0afe33ea9307a2f3abaf5;hb=8679670bdbe3c5928ec2e266d9c72e1a758fdf37;hpb=6f44ad6ea02e5e5bd316af09756cda740c3c6f56 diff --git a/web/index.html b/web/index.html index b21998bd..b62306a2 100644 --- a/web/index.html +++ b/web/index.html @@ -35,7 +35,7 @@ - + @@ -597,7 +597,52 @@ 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 += '
  • databases available on this host
  • '; + a1 += '
  • '; + + 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 += '
  • ' + hostname + '
  • '; + a1 += '
  • '; + hosted++; + i++; + } + + el += ''; + a1 += ''; + } if(machines_array === null) { var ret = loadLocalStorage("registryCallback"); @@ -616,7 +661,7 @@ return 0; }); - var len = machines.length; + len = machines.length; while(len--) { var u = machines[len]; found++; @@ -707,6 +752,11 @@ location.reload(); } + function gotoHostedModalHandler(url) { + document.location = url + urlOptions.genHash(); + return false; + } + var gotoServerValidateRemaining = 0; var gotoServerMiddleClick = false; var gotoServerStop = false; @@ -873,21 +923,24 @@ submenu_names: {}, data: null, hostname: 'netdata_server', // will be overwritten by the netdata server + version: 'unknown', categories: [], 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; } @@ -939,6 +992,14 @@ // ---------------------------------------------------------------------------- + // user editable information + var customDashboard = { + menu: {}, + submenu: {}, + context: {} + }; + + // netdata standard information var netdataDashboard = { sparklines_registry: {}, os: 'unknown', @@ -1110,12 +1171,16 @@ 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': @@ -1130,12 +1195,16 @@ 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': @@ -1143,28 +1212,8 @@ 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': @@ -1195,6 +1244,8 @@ default: chart.menu = chart.type; + if(parts.length > 1) + chart.menu_pattern = tmp; break; } @@ -1420,7 +1471,7 @@ sidebar += '
  • add more charts
  • '; sidebar += '
  • add more alarms
  • '; - sidebar += '
  • netdata on ' + data.hostname.toString() + ', collects every ' + ((data.update_every == 1)?'second':data.update_every.toString() + ' seconds') + ' ' + data.dimensions_count.toLocaleString() + ' metrics, presented as ' + data.charts_count.toLocaleString() + ' charts and monitored by ' + data.alarms_count.toLocaleString() + ' 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.
  • '; + sidebar += '
  • netdata on ' + data.hostname.toString() + ', collects every ' + ((data.update_every == 1)?'second':data.update_every.toString() + ' seconds') + ' ' + data.dimensions_count.toLocaleString() + ' metrics, presented as ' + data.charts_count.toLocaleString() + ' charts and monitored by ' + data.alarms_count.toLocaleString() + ' 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.
     
    netdata
    v' + data.version.toString() +'
  • '; sidebar += ''; div.innerHTML = html; document.getElementById('sidebar').innerHTML = sidebar; @@ -1574,70 +1625,6 @@ return t.toLocaleDateString() + space + t.toLocaleTimeString(); } - function seconds4human(seconds, options) { - var default_options = { - now: 'now', - space: ' ', - 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 '; @@ -2219,6 +2206,70 @@ }); } + function seconds4human(seconds, options) { + var default_options = { + now: 'now', + space: ' ', + 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) { @@ -2235,6 +2286,43 @@ 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; @@ -2249,34 +2337,16 @@ // download all the charts the server knows NETDATA.chartRegistry.downloadAll(netdata_url, function(data) { - if(data !== null) { - options.hostname = data.hostname; - options.data = data; - netdataDashboard.os = data.os; - - // update the dashboard hostname - document.getElementById('hostname').innerHTML = options.hostname; - document.getElementById('hostname').href = NETDATA.serverDefault; - - // 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); } }); }); @@ -2288,8 +2358,23 @@ document.getElementById('versionCheckLog').innerHTML = msg; } - function getNetdataVersion(callback) { - versionLog('Downloading installed version info from netdata...'); + function getNetdataCommitIdFromVersion() { + var s = options.version.split('-'); + + if(s.length !== 3) return null; + if(s[2][0] == 'g') { + var v = s[2].split('_')[0].substring(1, 8); + if(v.length === 7) { + versionLog('Installed git commit id of netdata is ' + v); + document.getElementById('netdataCommitId').innerHTML = v; + return v; + } + } + return null; + } + + function getNetdataCommitId(force, callback) { + versionLog('Downloading installed git commit id from netdata...'); $.ajax({ url: 'version.txt', @@ -2300,23 +2385,31 @@ .done(function(data) { data = data.replace(/(\r\n|\n|\r| |\t)/gm,""); if(data.length !== 40) { - versionLog('Received version string is invalid.'); - callback(null); + var c = getNetdataCommitIdFromVersion(); + if(c === null) versionLog('Cannot find the git commit id of netdata.'); + callback(c); } else { - versionLog('Installed version of netdata is ' + data); - document.getElementById('netdataVersion').innerHTML = data; + versionLog('Installed git commit id of netdata is ' + data); + document.getElementById('netdataCommitId').innerHTML = data.substring(0, 7); callback(data); } }) .fail(function() { - versionLog('Failed to download installed version info from netdata!'); - callback(null); + versionLog('Failed to download installed git commit id from netdata!'); + + if(force === true) { + var c = getNetdataCommitIdFromVersion(); + if(c === null) versionLog('Cannot find the git commit id of netdata.'); + callback(c); + } + else + callback(null); }); } function getGithubLatestCommit(callback) { - versionLog('Downloading latest version info from github...'); + versionLog('Downloading latest git commit id info from github...'); $.ajax({ url: 'https://api.github.com/repos/firehol/netdata/commits', @@ -2324,17 +2417,17 @@ cache: false }) .done(function(data) { - versionLog('Latest version info from github is ' + data[0].sha); + versionLog('Latest git commit id from github is ' + data[0].sha); callback(data[0].sha); }) .fail(function() { - versionLog('Failed to download installed version info from github!'); + versionLog('Failed to download installed git commit id from github!'); callback(null); }); } - function checkForUpdate(callback) { - getNetdataVersion(function(sha1) { + function checkForUpdate(force, callback) { + getNetdataCommitId(force, function(sha1) { if(sha1 === null) callback(null, null); getGithubLatestCommit(function(sha2) { @@ -2364,26 +2457,26 @@ } } - checkForUpdate(function(sha1, sha2) { + checkForUpdate(force, function(sha1, sha2) { var save = false; if(sha1 === null) { save = false; - versionLog('

    Failed to get your netdata version!

    You can always get the latest version of netdata from its github page.

    '); + versionLog('

    Failed to get your netdata git commit id!

    You can always get the latest netdata from its github page.

    '); } else if(sha2 === null) { save = false; - versionLog('

    Failed to get the latest version from github.

    You can always get the latest version of netdata from its github page.

    '); + versionLog('

    Failed to get the latest git commit id from github.

    You can always get the latest netdata from its github page.

    '); } else if(sha1 === sha2) { save = true; - versionLog('

    You already have the latest version of netdata!

    No update yet?
    Probably, we need some motivation to keep going on!

    If you haven\'t already, give netdata a Star at its github page.

    '); + versionLog('

    You already have the latest netdata!

    No update yet?
    Probably, we need some motivation to keep going on!

    If you haven\'t already, give netdata a Star at its github page.

    '); } else { save = true; var compare = 'https://github.com/firehol/netdata/compare/' + sha1.toString() + '...' + sha2.toString(); - versionLog('

    New version of netdata available!

    Latest version: ' + sha2.toString() + '

    Click here for the changes log since your installed version, and
    click here for directions on updating your netdata installation.

    We suggest to review the changes log for new features you may be interested, or important bug fixes you may need.
    Keeping your netdata updated, is generally a good idea.

    '); + versionLog('

    New version of netdata available!

    Latest commit: ' + sha2.substring(0, 7).toString() + '

    Click here for the changes log since your installed version, and
    click here for directions on updating your netdata installation.

    We suggest to review the changes log for new features you may be interested, or important bug fixes you may need.
    Keeping your netdata updated, is generally a good idea.

    '); document.getElementById('update_badge').innerHTML = '!'; } @@ -2800,7 +2893,7 @@ }); NETDATA.requiredJs.push({ - url: NETDATA.serverDefault + 'dashboard_info.js?v20170211-19', + url: NETDATA.serverDefault + 'dashboard_info.js?v20170308-1', async: false, isAlreadyLoaded: function() { return false; } }); @@ -3312,7 +3405,8 @@ - +