summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--conf/glances.conf17
-rw-r--r--docs/_static/amp-python-warning.pngbin0 -> 9474 bytes
-rw-r--r--docs/_static/amp-python.pngbin0 -> 9362 bytes
-rw-r--r--docs/_static/amps-dropbox.pngbin0 -> 29273 bytes
-rw-r--r--docs/_static/amps.pngbin56944 -> 80498 bytes
-rw-r--r--docs/aoa/amps.rst101
-rw-r--r--docs/aoa/monitor.rst61
-rw-r--r--docs/cmds.rst6
-rw-r--r--glances/amps/glances_default.py78
-rw-r--r--glances/main.py4
-rw-r--r--glances/outputs/glances_curses.py2
-rw-r--r--glances/outputs/static/html/stats.html2
-rw-r--r--glances/outputs/static/js/stats_controller.js4
-rw-r--r--glances/plugins/glances_amps.py2
15 files changed, 201 insertions, 81 deletions
diff --git a/NEWS b/NEWS
index b9847652..c40e6972 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,11 @@ Bugs corrected:
* [Web UI] Fix folders plugin never displayed (issue #829)
* Correct issue IP plugin: VPN with no internet access (issue #842)
+Deprecated:
+
+ * Python 2.6 is no longer supported
+ * Monitoring process list module is replaced by AMP
+
Version 2.6.1
=============
diff --git a/conf/glances.conf b/conf/glances.conf
index 9fa40ce3..d0b2893d 100644
--- a/conf/glances.conf
+++ b/conf/glances.conf
@@ -253,19 +253,18 @@ queue=glances_queue
[amp_dropbox]
# Use the default AMP (no dedicated AMP Python script)
-enable=true
+enable=false
regex=.*dropbox.*
refresh=3
one_line=false
command=dropbox status
countmin=1
-[amp_xeyes]
-# Use the default AMP (no dedicated AMP Python script)
-enable=true
-regex=.*xeyes.*
+[amp_python]
+# Monitor all Python scripts
+enable=false
+regex=.*python.*
refresh=3
-countmin=1
countmax=2
[amp_nginx]
@@ -291,9 +290,3 @@ regex=\/sbin\/init
refresh=30
one_line=true
service_cmd=/usr/bin/service --status-all
-
-[amp_python]
-# Monitor all Python scripts
-enable=true
-regex=.*python.*
-refresh=3
diff --git a/docs/_static/amp-python-warning.png b/docs/_static/amp-python-warning.png
new file mode 100644
index 00000000..bd991c76
--- /dev/null
+++ b/docs/_static/amp-python-warning.png
Binary files differ
diff --git a/docs/_static/amp-python.png b/docs/_static/amp-python.png
new file mode 100644
index 00000000..ab8f2d72
--- /dev/null
+++ b/docs/_static/amp-python.png
Binary files differ
diff --git a/docs/_static/amps-dropbox.png b/docs/_static/amps-dropbox.png
new file mode 100644
index 00000000..7a1bcda2
--- /dev/null
+++ b/docs/_static/amps-dropbox.png
Binary files differ
diff --git a/docs/_static/amps.png b/docs/_static/amps.png
index bbcc7efe..c165a9c0 100644
--- a/docs/_static/amps.png
+++ b/docs/_static/amps.png
Binary files differ
diff --git a/docs/aoa/amps.rst b/docs/aoa/amps.rst
new file mode 100644
index 00000000..bdaf777f
--- /dev/null
+++ b/docs/aoa/amps.rst
@@ -0,0 +1,101 @@
+.. _amps:
+
+Applications Monitoring Process
+===============================
+
+Thanks to Glances and it AMP module, you can add specific monitoring
+to running process. AMP are defined in the Glances configuration file.
+
+You can disable AMP using the --disable-amps option or pressing the `A` shortkey.
+
+Simple AMP
+----------
+
+For example, a simple AMP which monitor the CPU/MEM of all Python processes
+can be define using:
+
+.. code-block:: ini
+
+ [amp_python]
+ enable=true
+ regex=.*python.*
+ refresh=3
+
+Every 3 seconds (*refresh*) and if the *enable* key is true, Glances will
+filter the running processes list thanks to the .*python.* regular
+expression (*regex*). The default behavor for an AMP is to display:
+the number of matching processes, the CPU and MEM:
+
+.. image:: ../_static/amp-python.png
+
+You can also define the minimum (*countmin*) and/or maximum (*countmax*) process
+number. For example:
+
+.. code-block:: ini
+
+ [amp_python]
+ enable=true
+ regex=.*python.*
+ refresh=3
+ countmin=1
+ countmax=2
+
+With this configuration, if the number of running Python script is higher than 2
+then the AMP is display with a purple color (red if < countmin):
+
+.. image:: ../_static/amp-python-warning.png
+
+User define AMP
+---------------
+
+If you need to execute a specific command line, you can use the *command* option.
+For example, if you want to display the Dropbox process status, you can define the
+following section in the Glances configuration file:
+
+.. code-block:: ini
+
+ [amp_dropbox]
+ # Use the default AMP (no dedicated AMP Python script)
+ enable=true
+ regex=.*dropbox.*
+ refresh=3
+ one_line=false
+ command=dropbox status
+ countmin=1
+
+The *dropbox status* command line will be executed and displayed in the Glances UI:
+
+.. image:: ../_static/amp-python-dropbox.png
+
+You can force Glances to display the result in one line setting the *one_line* to true.
+
+Embeded AMP
+-----------
+
+Glances provides some specifics AMP scripts (replacing the *command* line) hosted
+in the glances/amps folder. You can write your own AMP script to fill yours needs.
+AMP scripts are located in the glances/amps folder and should be names glances_*.py.
+An AMP script define an Amp class (GlancesAmp) with a mandatory update method.
+The update method call the set_result method to set the AMP return string.
+The return string is a string with one or more line (\n between lines).
+
+You can write your owns AMP and enable its from the configuration file.
+The configuration file section should be named [amp_*].
+
+For example, if you want to enable the Nginx AMP, the following definition
+should do the job (NGinx AMP is provided by the Glances team as an example):
+
+.. code-block:: ini
+
+ [amp_nginx]
+ enable=true
+ regex=\/usr\/sbin\/nginx
+ refresh=60
+ one_line=false
+ status_url=http://localhost/nginx_status
+
+Here is the result:
+
+.. image:: ../_static/amps.png
+
+In client/server mode, the AMP list is defined on the server side.
diff --git a/docs/aoa/monitor.rst b/docs/aoa/monitor.rst
index c0bdb3ee..16d81d4d 100644
--- a/docs/aoa/monitor.rst
+++ b/docs/aoa/monitor.rst
@@ -3,63 +3,6 @@
Monitored Processes List
========================
-The monitored processes list allows user, through the configuration
-file, to group processes and quickly show if the number of running
-processes is not good.
+The monitored processes list is deprecated.
-.. image:: ../_static/monitored.png
-
-Each item is defined by:
-
-- ``description``: description of the processes (max 16 chars).
-- ``regex``: regular expression of the processes to monitor.
-- ``command``: (optional) full path to shell command/script for extended
-- stat. Should return a single line string. Use with caution.
-- ``countmin``: (optional) minimal number of processes. A warning will
-- be displayed if number of processes < count.
-- ``countmax``: (optional) maximum number of processes. A warning will
- be displayed if number of processes > count.
-
-Up to ``10`` items can be defined.
-
-For example, if you want to monitor the Nginx processes on a web server,
-the following definition should do the job:
-
-.. code-block:: ini
-
- [monitor]
- list_1_description=Nginx server
- list_1_regex=.*nginx.*
- list_1_command=nginx -v
- list_1_countmin=1
- list_1_countmax=4
-
-If you also want to monitor the PHP-FPM daemon processes, you should add
-another item:
-
-.. code-block:: ini
-
- [monitor]
- list_1_description=Nginx server
- list_1_regex=.*nginx.*
- list_1_command=nginx -v
- list_1_countmin=1
- list_1_countmax=4
- list_2_description=PHP-FPM
- list_2_regex=.*php-fpm.*
- list_2_countmin=1
- list_2_countmax=20
-
-In client/server mode, the list is defined on the server side.
-A new method, called `getAllMonitored`, is available in the APIs and
-get the JSON representation of the monitored processes list.
-
-Alerts are set as following:
-
-================= ============
-# of process Status
-================= ============
-``0`` ``CRITICAL``
-``min < p < max`` ``OK``
-``p > max`` ``WARNING``
-================= ============
+Please use the Application Monitoring Process (AMP).
diff --git a/docs/cmds.rst b/docs/cmds.rst
index e67bd974..9078b4ea 100644
--- a/docs/cmds.rst
+++ b/docs/cmds.rst
@@ -95,11 +95,7 @@ Command-Line Options
disable process module
-.. option:: --disable-monitor
-
- disable monitoring process list module
-
-.. option:: --disable-amp
+.. option:: --disable-amps
disable application monitoring process module
diff --git a/glances/amps/glances_default.py b/glances/amps/glances_default.py
new file mode 100644
index 00000000..3c6294a3
--- /dev/null
+++ b/glances/amps/glances_default.py
@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of Glances.
+#
+# Copyright (C) 2016 Nicolargo <nicolas@nicolargo.com>
+#
+# Glances is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Glances is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Default AMP
+=========
+
+Monitor a process by executing a command line. This is the default AMP's behavor
+if no AMP script is found.
+
+Configuration file example
+--------------------------
+
+[amp_foo]
+enable=true
+regex=\/usr\/bin\/foo
+refresh=10
+one_line=false
+command=foo status
+"""
+
+from subprocess import check_output, STDOUT
+
+from glances.compat import u, to_ascii
+from glances.logger import logger
+from glances.amps.glances_amp import GlancesAmp
+
+
+class Amp(GlancesAmp):
+ """Glances' Default AMP."""
+
+ NAME = ''
+ VERSION = '1.0'
+ DESCRIPTION = ''
+ AUTHOR = 'Nicolargo'
+ EMAIL = 'contact@nicolargo.com'
+
+ def __init__(self, name=None, args=None):
+ """Init the AMP."""
+ self.NAME = name.capitalize()
+ super(Amp, self).__init__(name=name, args=args)
+
+ def update(self, process_list):
+ """Update the AMP"""
+ # Get the systemctl status
+ logger.debug('{0}: Update stats using service {1}'.format(self.NAME, self.get('service_cmd')))
+ try:
+ res = self.get('command')
+ except OSError as e:
+ logger.debug('{0}: Error while executing service ({1})'.format(self.NAME, e))
+ else:
+ if res is not None:
+ msg = u(check_output(res.split(), stderr=STDOUT))
+ self.set_result(to_ascii(msg.rstrip()))
+ else:
+ # Set the default message if command return None
+ # Default sum of CPU and MEM for the matching regex
+ self.set_result('CPU: {0:.1f}% | MEM: {1:.1f}%'.format(
+ sum([p['cpu_percent'] for p in process_list]),
+ sum([p['memory_percent'] for p in process_list])))
+
+ return self.result()
diff --git a/glances/main.py b/glances/main.py
index e68e443f..7db835ba 100644
--- a/glances/main.py
+++ b/glances/main.py
@@ -138,8 +138,8 @@ Start the client browser (browser mode):\n\
help='disable network, disk I/O, FS and sensors modules')
parser.add_argument('--disable-process', action='store_true', default=False,
dest='disable_process', help='disable process module')
- parser.add_argument('--disable-amp', action='store_true', default=False,
- dest='disable_amp', help='disable applications monitoring process (AMP) module')
+ parser.add_argument('--disable-amps', action='store_true', default=False,
+ dest='disable_amps', help='disable applications monitoring process (AMP) module')
parser.add_argument('--disable-log', action='store_true', default=False,
dest='disable_log', help='disable log module')
parser.add_argument('--disable-bold', action='store_true', default=False,
diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py
index a38eb176..b35ae1ef 100644
--- a/glances/outputs/glances_curses.py
+++ b/glances/outputs/glances_curses.py
@@ -330,7 +330,7 @@ class _GlancesCurses(object):
glances_processes.sort_key = 'cpu_percent'
elif self.pressedkey == ord('A'):
# 'A' > enable/disable AMP module
- self.args.disable_amp = not self.args.disable_amp
+ self.args.disable_amps = not self.args.disable_amps
elif self.pressedkey == ord('b'):
# 'b' > Switch between bit/s and Byte/s for network IO
self.args.byte = not self.args.byte
diff --git a/glances/outputs/static/html/stats.html b/glances/outputs/static/html/stats.html
index 34912321..de0daf54 100644
--- a/glances/outputs/static/html/stats.html
+++ b/glances/outputs/static/html/stats.html
@@ -59,7 +59,7 @@
<section id="alert" class="plugin" ng-show="!arguments.disable_log" ng-include src="'plugins/alert.html'"></section>
<div ng-show="!arguments.disable_process">
<section id="processcount" class="plugin" ng-include src="'plugins/processcount.html'"></section>
- <div class="row">
+ <div class="row" ng-if="!arguments.disable_amps">
<div class="col-lg-18">
<section id="amps" class="plugin" ng-include src="'plugins/amps.html'"></section>
</div>
diff --git a/glances/outputs/static/js/stats_controller.js b/glances/outputs/static/js/stats_controller.js
index 810c749b..d0eac213 100644
--- a/glances/outputs/static/js/stats_controller.js
+++ b/glances/outputs/static/js/stats_controller.js
@@ -64,6 +64,10 @@ glancesApp.controller('statsController', function ($scope, $rootScope, $interval
$scope.sorter.column = "cpu_percent";
$scope.sorter.auto = true;
break;
+ case $event.shiftKey && $event.keyCode == keycodes.A:
+ // D => Enable/disable AMPs
+ $scope.arguments.disable_amps = !$scope.arguments.disable_amps;
+ break;
case !$event.shiftKey && $event.keyCode == keycodes.c:
// c => Sort processes by CPU%
$scope.sorter.column = "cpu_percent";
diff --git a/glances/plugins/glances_amps.py b/glances/plugins/glances_amps.py
index 08d06363..63020153 100644
--- a/glances/plugins/glances_amps.py
+++ b/glances/plugins/glances_amps.py
@@ -97,7 +97,7 @@ class Plugin(GlancesPlugin):
# Only process if stats exist and display plugin enable...
ret = []
- if not self.stats or args.disable_process or args.disable_amp:
+ if not self.stats or args.disable_process or args.disable_amps:
return ret
# Build the string message