Browse Source

[IMP] Module 'nsca_client' - Review + Default NSCA server added + Configuration file path added on the NSCA server (each server can require a different password)

pull/1280/head
sebalix 9 years ago
committed by Enric Tobella
parent
commit
e3f00518d4
No known key found for this signature in database GPG Key ID: 1A2546A1B7BA2451
  1. 16
      nsca_client/README.rst
  2. 5
      nsca_client/__openerp__.py
  3. 13
      nsca_client/data/nsca_server.xml
  4. 9
      nsca_client/demo/demo_data.xml
  5. 8
      nsca_client/models/nsca_check.py
  6. 4
      nsca_client/models/nsca_server.py
  7. BIN
      nsca_client/static/description/check.png
  8. BIN
      nsca_client/static/description/server.png
  9. 2
      nsca_client/views/nsca_server.xml

16
nsca_client/README.rst

@ -27,18 +27,26 @@ Configuration
To configure this module, you need to:
* Configure your server and a passive service in your moniroting tool
(e.g service ``ODOO MAIL QUEUE`` on host ``MY-SERVER``).
* Configure your server and a passive service in your monitoring tool
(e.g service ``Odoo Mail Queue`` on host ``MY-SERVER``).
* On Odoo, set the previous hostname in the system parameters::
nsca_client.hostname = MY-SERVER
* Declare your NSCA server in the menu Configuration / Technical / NSCA Client / Servers
.. image:: nsca_client/static/description/server.png
:width: 400 px
* Create NSCA checks in the menu Configuration / Technical / NSCA Client / Checks
.. image:: nsca_client/static/description/check.png
:width: 400 px
* Code the methods which will be called by the NSCA checks.
Such methods must return a tuple (RC, MESSAGE) where RC is an integer,
and MESSAGE a unicode string. ``RC`` values and the corresponding status are:
Such methods must return a tuple ``(RC, MESSAGE)`` where ``RC`` is an integer,
and ``MESSAGE`` a unicode string. ``RC`` values and the corresponding status are:
- 0: OK
- 1: WARNING

5
nsca_client/__openerp__.py

@ -12,11 +12,14 @@
"application": False,
"installable": True,
"external_dependencies": {
"bin": ['/usr/sbin/send_nsca'],
"bin": [
'/usr/sbin/send_nsca',
],
},
"data": [
"security/ir.model.access.csv",
"data/ir_config_parameter.xml",
"data/nsca_server.xml",
"views/nsca_menu.xml",
"views/nsca_check.xml",
"views/nsca_server.xml",

13
nsca_client/data/nsca_server.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2015 ABF OSIELL <http://osiell.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data noupdate="1">
<record id="nsca_server_default" model="nsca.server">
<field name="name">nagios.example.net</field>
<field name="port">5667</field>
</record>
</data>
</openerp>

9
nsca_client/demo/demo_data.xml

@ -2,14 +2,9 @@
<openerp>
<data>
<record id="demo_nsca_server" model="nsca.server">
<field name="name">nagios.example.net</field>
<field name="port">5667</field>
</record>
<record id="demo_nsca_check_mails" model="nsca.check">
<field name="server_id" ref="demo_nsca_server"/>
<field name="service">ODOO MAIL QUEUE</field>
<field name="server_id" ref="nsca_server_default"/>
<field name="service">Odoo Mail Queue</field>
<field name="interval_number" eval="10"/>
<field name="interval_type">minutes</field>
<field name="nsca_model">mail.mail</field>

8
nsca_client/models/nsca_check.py

@ -6,7 +6,7 @@ import logging
import shlex
import subprocess
from openerp import models, fields, api, _
from openerp import _, api, fields, models
from openerp.addons.base.ir.ir_cron import str2tuple
@ -108,8 +108,10 @@ class NscaCheck(models.Model):
"""Prepare the shell command used to send the check result
to the NSCA daemon.
"""
cmd = u"/usr/sbin/send_nsca -H %s -p %s" % (
check.server_id.name, check.server_id.port)
cmd = u"/usr/sbin/send_nsca -H %s -p %s -c %s" % (
check.server_id.name,
check.server_id.port,
check.server_id.config_file_path)
return shlex.split(cmd)
@api.model

4
nsca_client/models/nsca_server.py

@ -2,7 +2,7 @@
# © 2015 ABF OSIELL <http://osiell.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields
from openerp import fields, models
class NscaServer(models.Model):
@ -11,5 +11,7 @@ class NscaServer(models.Model):
name = fields.Char(u"Hostname", required=True)
port = fields.Integer(u"Port", default=5667, required=True)
config_file_path = fields.Char(
u"Configuration file", default="/etc/send_nsca.cfg", required=True)
check_ids = fields.One2many(
'nsca.check', 'server_id', string=u"Checks")

BIN
nsca_client/static/description/check.png

After

Width: 655  |  Height: 368  |  Size: 36 KiB

BIN
nsca_client/static/description/server.png

After

Width: 635  |  Height: 373  |  Size: 17 KiB

2
nsca_client/views/nsca_server.xml

@ -14,6 +14,7 @@
<group string="NSCA Server">
<field name="name" style="width: 30%;"/>
<field name="port"/>
<field name="config_file_path"/>
</group>
<group string="Checks">
<field name="check_ids" nolabel="1"/>
@ -30,6 +31,7 @@
<tree string="NSCA Servers">
<field name="name"/>
<field name="port"/>
<field name="config_file_path"/>
</tree>
</field>
</record>

Loading…
Cancel
Save