Add monitoring_status

This commit is contained in:
Patrick Tombez
2019-05-10 17:32:49 +02:00
parent 3e42c8838c
commit 8ac8f5ac6c
6 changed files with 61 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License
Monitoring: Status
==================
Provides a HTTP route that returns health status of the instance.
The url to call is ``http://server/monitoring/status``
+2
View File
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import controllers
+15
View File
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{'name': 'Monitoring: Status',
'version': '7.0.1.0.0',
'author': 'Camptocamp,Odoo Community Association (OCA)',
'license': 'AGPL-3',
'category': 'category',
'depends': ['base', 'web'],
'website': 'http://www.camptocamp.com',
'data': [],
'installable': True,
}
@@ -0,0 +1 @@
from . import main
+34
View File
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import json
import werkzeug
from openerp.addons.web import http as oeweb
from openerp.addons.web.controllers.main import db_monodb_redirect
class Monitoring(oeweb.Controller):
_cp_path = '/monitoring'
@oeweb.httprequest
def status(self, req, **kwargs):
db, redirect = db_monodb_redirect(req)
if redirect:
werkzeug.exceptions.abort(werkzeug.utils.redirect(redirect, 303))
# TODO: add 'sub-systems' status and infos:
# queue job, cron, database, ...
headers = {'Content-Type': 'application/json'}
info = {'status': 1}
session = req.session
# We set a custom expiration of 1 second for this request, as we do a
# lot of health checks, we don't want those anonymous sessions to be
# kept. Beware, it works only when session_redis is used.
# Alternatively, we could set 'session.should_save = False', which is
# tested in odoo source code, but we wouldn't check the health of
# Redis.
if not session._uid:
session.expiration = 1
return werkzeug.wrappers.Response(json.dumps(info), headers=headers)
View File