From 871172444b014db859e711758456451166ec11e8 Mon Sep 17 00:00:00 2001 From: sebalix Date: Thu, 7 Apr 2016 09:05:49 +0200 Subject: [PATCH] [IMP] nsca_client - Configure the node hostname at the NSCA server level --- nsca_client/__openerp__.py | 1 - nsca_client/data/ir_config_parameter.xml | 13 ------------- nsca_client/models/nsca_check.py | 3 +-- nsca_client/models/nsca_server.py | 4 ++++ nsca_client/views/nsca_server.xml | 3 +++ 5 files changed, 8 insertions(+), 16 deletions(-) delete mode 100644 nsca_client/data/ir_config_parameter.xml diff --git a/nsca_client/__openerp__.py b/nsca_client/__openerp__.py index 6bfaf81a4..5571fb51d 100644 --- a/nsca_client/__openerp__.py +++ b/nsca_client/__openerp__.py @@ -13,7 +13,6 @@ "installable": True, "data": [ "security/ir.model.access.csv", - "data/ir_config_parameter.xml", "data/nsca_server.xml", "views/nsca_menu.xml", "views/nsca_check.xml", diff --git a/nsca_client/data/ir_config_parameter.xml b/nsca_client/data/ir_config_parameter.xml deleted file mode 100644 index 5a7cac83a..000000000 --- a/nsca_client/data/ir_config_parameter.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - nsca_client.hostname - localhost - - - - diff --git a/nsca_client/models/nsca_check.py b/nsca_client/models/nsca_check.py index 1159d7e76..71734cbd2 100644 --- a/nsca_client/models/nsca_check.py +++ b/nsca_client/models/nsca_check.py @@ -106,8 +106,7 @@ class NscaCheck(models.Model): def _format_check_result(self, check, rc, message): """Format the check result with tabulations as delimiter.""" message = message.replace('\t', ' ') - hostname = self.env['ir.config_parameter'].get_param( - 'nsca_client.hostname', 'localhost') + hostname = check.server_id.node_hostname check_result = u"%s\t%s\t%s\t%s" % ( hostname, check.service, rc, message) return check_result.encode('utf-8') diff --git a/nsca_client/models/nsca_server.py b/nsca_client/models/nsca_server.py index ea66c348c..441fd1c27 100644 --- a/nsca_client/models/nsca_server.py +++ b/nsca_client/models/nsca_server.py @@ -11,6 +11,10 @@ class NscaServer(models.Model): name = fields.Char(u"Hostname", required=True) port = fields.Integer(u"Port", default=5667, required=True) + node_hostname = fields.Char( + u"Hostname of this node", required=True, + help=u"This is the hostname of the current node declared in the " + u"monitoring server.") config_file_path = fields.Char( u"Configuration file", default="/etc/send_nsca.cfg", required=True) check_ids = fields.One2many( diff --git a/nsca_client/views/nsca_server.xml b/nsca_client/views/nsca_server.xml index f03263dd9..d5b00472d 100644 --- a/nsca_client/views/nsca_server.xml +++ b/nsca_client/views/nsca_server.xml @@ -16,6 +16,9 @@ + + +