Enric Tobella
7 years ago
No known key found for this signature in database
GPG Key ID: 1A2546A1B7BA2451
14 changed files with 368 additions and 198 deletions
-
1.travis.yml
-
41nsca_client/README.rst
-
1nsca_client/__init__.py
-
6nsca_client/__manifest__.py
-
14nsca_client/data/nsca_server.xml
-
18nsca_client/demo/demo_data.xml
-
4nsca_client/models/__init__.py
-
64nsca_client/models/nsca_check.py
-
50nsca_client/models/nsca_server.py
-
1nsca_client/tests/__init__.py
-
97nsca_client/tests/test_nsca.py
-
51nsca_client/views/nsca_check.xml
-
4nsca_client/views/nsca_menu.xml
-
22nsca_client/views/nsca_server.xml
@ -1,4 +1,3 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
# © 2015 ABF OSIELL <http://osiell.com> |
# © 2015 ABF OSIELL <http://osiell.com> |
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
@ -1,19 +1,17 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
# © 2015 ABF OSIELL <http://osiell.com> |
# © 2015 ABF OSIELL <http://osiell.com> |
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
{ |
{ |
||||
"name": "NSCA Client", |
"name": "NSCA Client", |
||||
"summary": "Send passive alerts to monitor your Odoo application.", |
"summary": "Send passive alerts to monitor your Odoo application.", |
||||
"version": "8.0.1.0.0", |
|
||||
|
"version": "11.0.1.0.0", |
||||
"category": "Tools", |
"category": "Tools", |
||||
"website": "http://osiell.com/", |
|
||||
|
"website": "http://github.com/OCA/server-tools", |
||||
"author": "ABF OSIELL, Odoo Community Association (OCA)", |
"author": "ABF OSIELL, Odoo Community Association (OCA)", |
||||
"license": "AGPL-3", |
"license": "AGPL-3", |
||||
"application": False, |
"application": False, |
||||
"installable": True, |
"installable": True, |
||||
"data": [ |
"data": [ |
||||
"security/ir.model.access.csv", |
"security/ir.model.access.csv", |
||||
"data/nsca_server.xml", |
|
||||
"views/nsca_menu.xml", |
"views/nsca_menu.xml", |
||||
"views/nsca_check.xml", |
"views/nsca_check.xml", |
||||
"views/nsca_server.xml", |
"views/nsca_server.xml", |
@ -1,14 +0,0 @@ |
|||||
<?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> |
|
||||
<field name="node_hostname">MY-SERVER</field> |
|
||||
</record> |
|
||||
|
|
||||
</data> |
|
||||
</openerp> |
|
@ -1,5 +1 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
# © 2015 ABF OSIELL <http://osiell.com> |
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
||||
|
|
||||
from . import nsca_check, nsca_server |
from . import nsca_check, nsca_server |
@ -0,0 +1 @@ |
|||||
|
from . import test_nsca |
@ -0,0 +1,97 @@ |
|||||
|
# Copyright 2018 Creu Blanca |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
import mock |
||||
|
|
||||
|
from odoo.tests.common import TransactionCase |
||||
|
|
||||
|
|
||||
|
class Popen: |
||||
|
def __init__(self, cmd, stdout, stdin, stderr): |
||||
|
self.cmd = cmd |
||||
|
self.stdout = stdout |
||||
|
self.stdin = stdin |
||||
|
self.stderr = stderr |
||||
|
|
||||
|
def communicate(input): |
||||
|
return ['test'] |
||||
|
|
||||
|
|
||||
|
class TestNsca(TransactionCase): |
||||
|
|
||||
|
def test_nsca(self): |
||||
|
server = self.env['nsca.server'].create({ |
||||
|
'name': 'localhost', |
||||
|
'password': 'pass', |
||||
|
'encryption_method': '3', |
||||
|
'node_hostname': 'odoodev', |
||||
|
}) |
||||
|
self.assertTrue(server.config_file_path) |
||||
|
with mock.patch('subprocess.Popen') as post: |
||||
|
post.return_value = Popen |
||||
|
check = self.env['nsca.check'].create({ |
||||
|
'server_id': server.id, |
||||
|
'service': 'test', |
||||
|
'nsca_model': 'nsca.server', |
||||
|
'nsca_function': 'current_status' |
||||
|
}) |
||||
|
self.assertTrue(check.model_id) |
||||
|
self.env['nsca.check']._cron_check(check.id,) |
||||
|
|
||||
|
def test_write(self): |
||||
|
server = self.env['nsca.server'].create({ |
||||
|
'name': 'localhost', |
||||
|
'password': 'pass', |
||||
|
'encryption_method': '3', |
||||
|
'node_hostname': 'odoodev', |
||||
|
}) |
||||
|
self.assertTrue(server.config_file_path) |
||||
|
check = self.env['nsca.check'].create({ |
||||
|
'server_id': server.id, |
||||
|
'service': 'test', |
||||
|
'nsca_model': 'nsca.server', |
||||
|
'nsca_function': 'current_status' |
||||
|
}) |
||||
|
check.cron_id.state = 'object_create' |
||||
|
check.write({'interval_number': 1}) |
||||
|
self.assertEqual(check.cron_id.state, 'object_create') |
||||
|
check.write({'service': 'change'}) |
||||
|
self.assertNotEqual(check.cron_id.state, 'object_create') |
||||
|
|
||||
|
def test_void_failure(self): |
||||
|
server = self.env['nsca.server'].create({ |
||||
|
'name': 'localhost', |
||||
|
'password': 'pass', |
||||
|
'encryption_method': '3', |
||||
|
'node_hostname': 'odoodev', |
||||
|
}) |
||||
|
check = self.env['nsca.check'].create({ |
||||
|
'server_id': server.id, |
||||
|
'service': 'test', |
||||
|
'nsca_model': 'nsca.check', |
||||
|
'allow_void_result': False, |
||||
|
'nsca_function': '_check_send_nsca_command' |
||||
|
}) |
||||
|
with mock.patch('subprocess.Popen') as post: |
||||
|
post.return_value = Popen |
||||
|
self.env['nsca.check']._cron_check(check.id,) |
||||
|
post.assert_called_once() |
||||
|
|
||||
|
def test_void_ok(self): |
||||
|
server = self.env['nsca.server'].create({ |
||||
|
'name': 'localhost', |
||||
|
'password': 'pass', |
||||
|
'encryption_method': '3', |
||||
|
'node_hostname': 'odoodev', |
||||
|
}) |
||||
|
check = self.env['nsca.check'].create({ |
||||
|
'server_id': server.id, |
||||
|
'service': 'test', |
||||
|
'nsca_model': 'nsca.check', |
||||
|
'allow_void_result': True, |
||||
|
'nsca_function': '_check_send_nsca_command' |
||||
|
}) |
||||
|
with mock.patch('subprocess.Popen') as post: |
||||
|
post.return_value = Popen |
||||
|
self.env['nsca.check']._cron_check(check.id,) |
||||
|
post.assert_not_called() |
Write
Preview
Loading…
Cancel
Save
Reference in new issue