]> arthur.barton.de Git - netdata.git/blobdiff - web/index.html
apps.plugin: major new features and optimizations: now it reports system usage (all...
[netdata.git] / web / index.html
old mode 100755 (executable)
new mode 100644 (file)
index c37be7c..b9b1785
 
        <!-- check which theme to use -->
        <script>
-               function getTheme(def) {
+               function loadLocalStorage(name) {
                        var ret = null;
 
                        try {
                                if(typeof Storage !== "undefined" && typeof localStorage === 'object')
-                                       ret = localStorage.getItem('netdataTheme');
+                                       ret = localStorage.getItem(name);
                        }
                        catch(error) {
                                ;
                        }
 
-                       if(ret === null || ret === 'undefined') return def;
-                       else return ret;
-               }
-               var netdataTheme = getTheme('slate');
+                       if(typeof ret === 'undefined' || ret === null)
+                               return null;
 
-               function setTheme(theme) {
-                       if(netdataTheme === theme)
-                               return false;
+                       return ret;
+               }
 
+               function saveLocalStorage(name, value) {
                        try {
                                if(typeof Storage !== "undefined" && typeof localStorage === 'object') {
-                                       localStorage.setItem('netdataTheme', theme);
+                                       localStorage.setItem(name, value.toString());
                                        return true;
                                }
                        }
 
                        return false;
                }
+
+               function getTheme(def) {
+                       var ret = loadLocalStorage('netdataTheme');
+                       if(typeof ret === 'undefined' || ret === null || ret === 'undefined')
+                               return def;
+                       else
+                               return ret;
+               }
+               var netdataTheme = getTheme('slate');
+
+               function setTheme(theme) {
+                       if(theme === netdataTheme) return false;
+
+                       return saveLocalStorage('netdataTheme', theme);
+               }
        </script>
 
        <!-- load the dashboard manager - it will do the rest -->
-       <script type="text/javascript" src="dashboard.js?v25"></script>
+       <script type="text/javascript" src="dashboard.js?v26"></script>
 </head>
 
 <body data-spy="scroll" data-target="#sidebar">
                                <ul class="nav navbar-nav">
                                        <li><a href="#" class="btn" data-toggle="modal" data-target="#optionsModal"><i class="fa fa-cog"></i> settings</a></li>
                                        <li><a href="https://github.com/firehol/netdata/wiki" class="btn" target="_blank"><i class="fa fa-github"></i> community</a></li>
+                                       <li id="updateButton"><a href="#" class="btn" data-toggle="modal" data-target="#updateModal"><i class="fa fa-cloud-download"></i> update</a></li>
 <!--                                   <li><a href="old/" class="btn" target="_blank"><i class="fa fa-step-backward"></i> old dashboard</a></li> -->
                                        <li><a href="#" class="btn" data-toggle="modal" data-target="#helpModal"><i class="fa fa-question-circle"></i> help</a></li>
 <!--                                   <li><a href="#sec">Visualize</a></li>
                                        <!-- Tab panes -->
                                        <div class="tab-content">
                                                <div role="tabpanel" class="tab-pane active" id="settings_performance">
-                                                       <form id="optionsForm" method="get" class="form-horizontal">
+                                                       <form id="optionsForm1" method="get" class="form-horizontal">
                                                                <div class="form-group">
                                                                        <table>
                                                                        <tr class="option-row">
                                                        </form>
                                                </div>
                                                <div role="tabpanel" class="tab-pane" id="settings_sync">
-                                                       <form id="optionsForm" method="get" class="form-horizontal">
+                                                       <form id="optionsForm2" method="get" class="form-horizontal">
                                                                <div class="form-group">
                                                                        <table>
                                                                        <tr class="option-row">
                                                        </form>
                                                </div>
                                                <div role="tabpanel" class="tab-pane" id="settings_visual">
-                                                       <form id="optionsForm" method="get" class="form-horizontal">
+                                                       <form id="optionsForm3" method="get" class="form-horizontal">
                                                                <div class="form-group">
                                                                        <table>
                                                                        <tr class="option-row">
                </div>
        </div>
 
+
+       <div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel">
+               <div class="modal-dialog" role="document">
+                       <div class="modal-content">
+                               <div class="modal-header">
+                                       <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                                       <h4 class="modal-title" id="updateModalLabel">Update Check</h4>
+                               </div>
+                               <div class="modal-body">
+                                       Your netdata version: <b><code><span id="netdataVersion">Unknown</span></code></b>
+                                       <br/>
+                                       <div style="padding: 10px;"></div>
+                                       <div id="versionCheckLog">Not checked yet. Please press the Check Now button.</div>
+                               </div>
+                               <div class="modal-footer">
+                                       <a href="#" onclick="notifyForUpdate(true);" type="button" class="btn btn-default">Check Now</a>
+                                       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                               </div>
+                       </div>
+               </div>
+       </div>
+
 <script>
 
 var demo_hostname = 'netdata.firehol.org';
@@ -903,6 +939,18 @@ var menuData = {
                height: 1.5
        },
 
+       'users': {
+               title: 'Users',
+               info: 'Per user statistics are collected using netdata\'s <code>apps.plugin</code>. This plugin walks through the entire <code>/proc</code> filesystem and aggregates statistics per user.<br/><b>IMPORTANT</b>: The values shown here are not 100% accurate. They only include values for the processes running. If an application is spawning childs continiously, which are terminated in just a few milliseconds (like shell scripts do), the values reported will be inaccurate. Linux does report the values for the exited childs of a process. However, these values are reported to the parent process <b>only when the child exits</b>. If these values, of the exited child processes, were also aggregated in the charts below, the charts would have been full of spikes, presenting unrealisting utilization for each process group. So, we decided to ignore these values and present only the utilization of <b>the currently running processes</b>.',
+               height: 1.5
+       },
+
+       'groups': {
+               title: 'User Groups',
+               info: 'Per user group statistics are collected using netdata\'s <code>apps.plugin</code>. This plugin walks through the entire <code>/proc</code> filesystem and aggregates statistics per user group.<br/><b>IMPORTANT</b>: The values shown here are not 100% accurate. They only include values for the processes running. If an application is spawning childs continiously, which are terminated in just a few milliseconds (like shell scripts do), the values reported will be inaccurate. Linux does report the values for the exited childs of a process. However, these values are reported to the parent process <b>only when the child exits</b>. If these values, of the exited child processes, were also aggregated in the charts below, the charts would have been full of spikes, presenting unrealisting utilization for each process group. So, we decided to ignore these values and present only the utilization of <b>the currently running processes</b>.',
+               height: 1.5
+       },
+
        'netdata': {
                title: 'Netdata Monitoring',
                info: undefined
@@ -980,7 +1028,7 @@ var chartData = {
 
        'system.idlejitter': {
                colors: '#5555AA',
-               info: 'Idle jitter is calculated by netdata. A thread is spawned that requests to sleep for a few microseconds. When the system wakes it up, it measures how many microseconds have passed. The different between the requested and the actual duration of the sleep, is the <b>idle jitter</b>. This number is useful in realtime environments, where CPU jitter can affect the quality of the service (like VoIP media gateways).'
+               info: 'Idle jitter is calculated by netdata. A thread is spawned that requests to sleep for a few microseconds. When the system wakes it up, it measures how many microseconds have passed. The difference between the requested and the actual duration of the sleep, is the <b>idle jitter</b>. This number is useful in realtime environments, where CPU jitter can affect the quality of the service (like VoIP media gateways).'
        },
 
        'system.ipv4': {
@@ -1039,6 +1087,30 @@ var chartData = {
                height: 2.0
        },
 
+       'users.cpu': {
+               height: 2.0
+       },
+
+       'users.preads': {
+               height: 2.0
+       },
+
+       'users.pwrites': {
+               height: 2.0
+       },
+
+       'groups.cpu': {
+               height: 2.0
+       },
+
+       'groups.preads': {
+               height: 2.0
+       },
+
+       'groups.pwrites': {
+               height: 2.0
+       },
+
        'tc.qos': {
                heads: [
                        function(id) {
@@ -1188,7 +1260,7 @@ function menuTitle(menu) {
 }
 
 function menuInfo(menu) {
-       return anyAttribute(menuData, 'title', menu, null);
+       return anyAttribute(menuData, 'info', menu, null);
 }
 
 function menuHeight(menu, relative) {
@@ -1574,6 +1646,126 @@ function downloadAllCharts(netdata_url) {
 
 // ----------------------------------------------------------------------------
 
+function versionLog(msg) {
+       document.getElementById('versionCheckLog').innerHTML = msg;
+}
+
+function getNetdataVersion(callback) {
+       versionLog('Downloading installed version info from netdata...');
+
+       $.ajax({
+               url: 'version.txt',
+               async: true,
+               cache: false
+       })
+       .done(function(data) {
+               data = data.replace(/(\r\n|\n|\r| |\t)/gm,"");
+               if(data.length !== 40) {
+                       versionLog('Received version string is invalid.');
+                       callback(null);
+               }
+               else {
+                       versionLog('Installed version of netdata is ' + data);
+                       document.getElementById('netdataVersion').innerHTML = data;
+                       callback(data);
+               }
+       })
+       .fail(function() {
+               versionLog('Failed to download installed version info from netdata!');
+               callback(null);
+       });
+}
+
+function getGithubLatestCommit(callback) {
+       versionLog('Downloading latest version info from github...');
+
+       $.ajax({
+               url: 'https://api.github.com/repos/firehol/netdata/commits',
+               async: true,
+               cache: false
+       })
+       .done(function(data) {
+               versionLog('Latest version info from github is ' + data[0].sha);
+               callback(data[0].sha);
+       })
+       .fail(function() {
+               versionLog('Failed to download installed version info from github!');
+               callback(null);
+       });
+}
+
+function checkForUpdate(callback) {
+       getNetdataVersion(function(sha1) {
+               if(sha1 === null) callback(null, null);
+
+               getGithubLatestCommit(function(sha2) {
+                       callback(sha1, sha2);
+               });
+       });
+
+       return null;
+}
+
+var updateBlinkCounter = 0;
+function notifyForUpdate(force) {
+       versionLog('<p>checking for updates...</p>');
+
+       var now = new Date().getTime();
+
+       if(typeof force === 'undefined' || force !== true) {
+               var last = loadLocalStorage('last_update_check');
+
+               if(typeof last === 'string')
+                       last = parseInt(last);
+               else
+                       last = 0;
+
+               if(now - last < 3600000 * 8) {
+                       // no need to check it - too soon
+                       return;
+               }
+       }
+
+       checkForUpdate(function(sha1, sha2) {
+               var save = false;
+
+               if(sha1 === null) {
+                       save = false;
+                       versionLog('<p><big>Failed to get your netdata version!</big></p><p>You can always get the latest version of netdata from <a href="https://github.com/firehol/netdata" target="_blank">its github page</a>.</p>');
+               }
+               else if(sha2 === null) {
+                       save = false;
+                       versionLog('<p><big>Failed to get the latest version from github.</big></p><p>You can always get the latest version of netdata from <a href="https://github.com/firehol/netdata" target="_blank">its github page</a>.</p>');
+               }
+               else if(sha1 === sha2) {
+                       save = true;
+                       versionLog('<p><big>You already have the latest version of netdata!</big></p><p>No update yet?<br/>Probably, we need some motivation to keep going on!</p><p>If you haven\'t already, <a href="https://github.com/firehol/netdata" target="_blank">give netdata a <b>Star</b> at its github page</a>.</p>');
+               }
+               else {
+                       save = true;
+                       var compare = 'https://github.com/firehol/netdata/compare/' + sha1.toString() + '...' + sha2.toString();
+
+                       versionLog('<p><big><strong>New version of netdata available!</strong></big></p><p>Latest version: ' + sha2.toString() + '</p><p><a href="' + compare + '" target="_blank">Click here for the changes log</a> since your installed version, and<br/><a href="https://github.com/firehol/netdata/wiki/Updating-Netdata" target="_blank">click here for directions on updating</a> your netdata installation.</p><p>We suggest to review the changes log for new features you may be interested, or important bug fixes you may need.<br/>Keeping your netdata updated, is generally a good idea.</p>');
+
+                       function updateButtonBlink() {
+                               updateBlinkCounter--;
+                               if(updateBlinkCounter > 0)
+                                       $('#updateButton').fadeOut(500).fadeIn(500, updateButtonBlink);
+                       }
+
+                       if(updateBlinkCounter === 0) {
+                               updateBlinkCounter = 300;
+                               updateButtonBlink();
+                       }
+               }
+
+               if(save)
+                       saveLocalStorage('last_update_check', now.toString());
+       });
+}
+
+// ----------------------------------------------------------------------------
+
 function finalizePage() {
        // resize all charts - without starting the background thread
        // this has to be done while NETDATA is paused
@@ -1669,15 +1861,22 @@ function finalizePage() {
 
        // this has to be the last
        // it reloads the page
-       $('#netdata_theme_control').change(function()           {
+       $('#netdata_theme_control').change(function() {
                if(setTheme($(this).prop('checked')?'slate':'default'))
                        location.reload();
        });
 
-       if(document.location.hostname === demo_hostname)
+       if(document.location.hostname === demo_hostname) {
                setTimeout(function() {
                        $('#welcomeModal').modal();
                }, 1000);
+       }
+       else
+               notifyForUpdate();
+
+       $('#updateModal').on('shown.bs.modal', function() {
+               notifyForUpdate(true);
+       })
 }
 
 function resetDashboardOptions() {