diff options
author | nicolargo <nicolashennion@gmail.com> | 2016-04-24 17:51:55 +0200 |
---|---|---|
committer | nicolargo <nicolashennion@gmail.com> | 2016-04-24 17:51:55 +0200 |
commit | 83b098a16c1c6ef7e99d6cf21cfca09dfb2ece7c (patch) | |
tree | 062ba43d067972025a93fefe267e648316d90edc /glances/amps | |
parent | 5481771263216ad28abd694a41f247d53e24893d (diff) |
AMP is now compatible with Glances client/server mode
Diffstat (limited to 'glances/amps')
-rw-r--r-- | glances/amps/glances_amp.py | 2 | ||||
-rw-r--r-- | glances/amps/glances_nginx.py | 31 |
2 files changed, 26 insertions, 7 deletions
diff --git a/glances/amps/glances_amp.py b/glances/amps/glances_amp.py index e46f5b77..f3395d42 100644 --- a/glances/amps/glances_amp.py +++ b/glances/amps/glances_amp.py @@ -83,7 +83,7 @@ class GlancesAmp(object): self.configs[param] = self.configs[param][0] logger.debug("{0}: Load parameter: {1} = {2}".format(self.NAME, param, self.configs[param])) else: - logger.warning("{0}: Can not find section {1} in the configuration file".format(self.NAME, self.amp_name)) + logger.warning("{0}: Can not find section {1} in the configuration file {2}".format(self.NAME, self.amp_name, config)) # enable, regex and refresh are mandatories # if not configured then AMP is disabled diff --git a/glances/amps/glances_nginx.py b/glances/amps/glances_nginx.py index 9c2cb9e3..b43da089 100644 --- a/glances/amps/glances_nginx.py +++ b/glances/amps/glances_nginx.py @@ -17,13 +17,32 @@ # 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/>. -"""Nginx AMP.""" - """ -A Glances AMP is a Python script called if a process is running. -The script should define a Amp (GlancesAmp) class with an update method. -The update method should call the set_result method to fill the AMP return string. +AMP (Application Monitoring Process) +A Glances AMP is a Python script called (every *refresh* seconds) if: +- the AMP is *enabled* in the Glances configuration file +- a process is running (match the *regex* define in the configuration file) +The script should define a Amp (GlancesAmp) class with, at least, an update method. +The update method should 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). +If the *one_line* var is true then the AMP will be displayed in one line. +""" + +""" +Nginx AMP +========= + +Monitor the Nginx process using the status page + +Configuration file example: + +[nginx] +# Nginx status page should be enable (https://easyengine.io/tutorials/nginx/status-page/) +enable=true +regex=\/usr\/sbin\/nginx +refresh=60 +one_line=false +status_url=http://localhost/nginx_status """ import requests @@ -49,8 +68,8 @@ class Amp(GlancesAmp): """Update the AMP""" if self.should_update(): - logger.debug('{0}: Update stats using status URL {1}'.format(self.NAME, self.get('status_url'))) # Get the Nginx status + logger.debug('{0}: Update stats using status URL {1}'.format(self.NAME, self.get('status_url'))) req = requests.get(self.get('status_url')) if req.ok: # u'Active connections: 1 \nserver accepts handled requests\n 1 1 1 \nReading: 0 Writing: 1 Waiting: 0 \n' |