# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test Mongodb retention. """ from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx mongodb_retention = modulesctx.get_module('retention_mongodb') get_instance = mongodb_retention.get_instance modconf = Module() modconf.module_name = "MongodbRetention" modconf.uri = 'mongodb://127.0.0.1:27017' modconf.database = 'test' modconf.module_type = mongodb_retention.properties['type'] modconf.properties = mongodb_retention.properties.copy() class TestMongodbRetention(ShinkenTest): # setUp is inherited from ShinkenTest def test_mongodb_retention(self): # get our modules
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test the named pipe arbiter module. """ import os, time, platform from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx named_pipe = modulesctx.get_module('named_pipe') Named_Pipe_arbiter = named_pipe.Named_Pipe_arbiter get_instance = named_pipe.get_instance modconf = Module() modconf.module_name = "NamedPipe" modconf.module_type = named_pipe.properties['type'] modconf.properties = named_pipe.properties.copy() class TestModuleNamedPipe(ShinkenTest): # setUp is inherited from ShinkenTest def test_read_named_pipe(self): # Ok, windows do not have named pipe, we know...
import time import random import copy from shinken_modules import ShinkenModulesTest from shinken_test import time_hacker, unittest from shinken.objects.module import Module from shinken.objects.service import Service from shinken.modulesctx import modulesctx from shinken.comment import Comment from shinken.log import logger from shinken.modulesmanager import ModulesManager from shinken.misc.datamanager import datamgr livestatus_broker = modulesctx.get_module('livestatus') LiveStatus_broker = livestatus_broker.LiveStatus_broker LiveStatus = livestatus_broker.LiveStatus LiveStatusRegenerator = livestatus_broker.LiveStatusRegenerator LiveStatusQueryCache = livestatus_broker.LiveStatusQueryCache Logline = livestatus_broker.Logline LiveStatusLogStoreSqlite = modulesctx.get_module( 'logstore-sqlite').LiveStatusLogStoreSqlite from mock_livestatus import mock_livestatus_handle_request sys.setcheckinterval(10000) @mock_livestatus_handle_request class TestConfig(ShinkenModulesTest):
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.brok import Brok from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module('simplelog').get_instance class TestConfig(ShinkenTest): # setUp is inherited from ShinkenTest def test_simplelog(self): print self.conf.modules # get our modules mod = None for m in self.conf.modules: if m.module_type == 'simple_log': mod = m self.assert_(mod is not None) self.assert_(mod.path == 'tmp/nagios.log') self.assert_(mod.module_name == 'Simple-log')
# # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test the named pipe arbiter module. """ import os, time, platform from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx named_pipe = modulesctx.get_module('named_pipe') Named_Pipe_arbiter = named_pipe.Named_Pipe_arbiter get_instance = named_pipe.get_instance modconf = Module() modconf.module_name = "NamedPipe" modconf.module_type = named_pipe.properties['type'] modconf.properties = named_pipe.properties.copy() class TestModuleNamedPipe(ShinkenTest): # setUp is inherited from ShinkenTest def test_read_named_pipe(self):
# Shinken is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test memcache retention. """ from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx memcache_retention_scheduler = modulesctx.get_module('retention_memcache') get_instance = memcache_retention_scheduler.get_instance modconf = Module() modconf.module_name = "MemcacheRetention" modconf.module_type = memcache_retention_scheduler.properties['type'] modconf.properties = memcache_retention_scheduler.properties.copy() try: import memcache except ImportError: memcache = None class TestMemcacheRetention(ShinkenTest): # setUp is inherited from ShinkenTest
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # from shinken_test import unittest, ShinkenTest from shinken.brok import Brok from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module('merlindb').get_instance class TestConfig(ShinkenTest): # setUp is inherited from ShinkenTest def test_simplelog(self): print self.conf.modules # get our modules mod = None for m in self.conf.modules: if m.module_name == 'ToMerlindb_Sqlite': mod = m self.assert_(mod is not None) self.assert_(mod.database_path == '/usr/local/shinken/var/merlindb.sqlite')
# along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from tempfile import mktemp from shinken_test import unittest, ShinkenTest from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module('file_tag').get_instance class TestFileTag(ShinkenTest): def setUp(self): self.setup_with_file('etc/nagios_module_file_tag.cfg') def test_hack_cmd_poller_tag(self): modconf = self.conf.modules.find_by_name('FileTag') # look for a objects that use it h1 = self.sched.hosts.find_by_name("test_host_0") h2 = self.sched.hosts.find_by_name("test_router_0") # get our modules path = mktemp()
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os import time from shinken_test import unittest, ShinkenTest from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module('perfdata_service').get_instance class TestModSRVPErfdata(ShinkenTest): # setUp is inherited from ShinkenTest def test_service_perfdata(self): print self.conf.modules # get our modules mod = None for m in self.conf.modules: if m.module_type == 'service_perfdata': mod = m self.assert_(mod is not None) self.assert_(mod.path == 'tmp/service-perfdata') self.assert_(mod.module_name == 'Service-Perfdata')
# # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import * sys.path.append("../shinken/modules") from shinken.brok import Brok from shinken.modulesctx import modulesctx host_perfdata_broker = modulesctx.get_module('perfdata_host') get_instance = host_perfdata_broker.get_instance class TestConfig(ShinkenTest): # setUp is inherited from ShinkenTest def test_host_perfdata(self): print self.conf.modules # get our modules mod = None for m in self.conf.modules: if m.module_type == 'host_perfdata': mod = m self.assert_(mod is not None) self.assert_(mod.path == 'tmp/host-perfdata')
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module('status_dat').get_instance class TestConfig(ShinkenTest): # setUp is inherited from ShinkenTest def nb_of_string(self, buf, s): nb_s = 0 for line in buf.splitlines(): if line == s: print "Find string" nb_s += 1 return nb_s def test_simplelog(self): print self.conf.modules
# You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test pickle retention broker. """ import os import copy from shinken_test import unittest, ShinkenTest from shinken.daemons.brokerdaemon import Broker from shinken.objects.module import Module from shinken.modulesctx import modulesctx pickle_retention_file_generic = modulesctx.get_module( 'pickle_retention_file_generic') get_instance = pickle_retention_file_generic.get_instance modconf = Module() modconf.module_name = "PickleRetentionGeneric" modconf.module_type = pickle_retention_file_generic.properties['type'] modconf.properties = pickle_retention_file_generic.properties.copy() class TestPickleRetentionBroker(ShinkenTest): # setUp is inherited from ShinkenTest def test_pickle_retention(self): # get our modules mod = pickle_retention_file_generic.Pickle_retention_generic( modconf, 'tmp/retention-test.dat')
from shinken_modules import ShinkenModulesTest from shinken_test import time_hacker, unittest from shinken.modulesctx import modulesctx from shinken.objects.module import Module from shinken.comment import Comment from shinken.objects.service import Service from mock_livestatus import mock_livestatus_handle_request from livestatus.log_line import Logline LiveStatusLogStoreMongoDB = modulesctx.get_module("logstore-mongodb").LiveStatusLogStoreMongoDB sys.setcheckinterval(10000) @mock_livestatus_handle_request class TestConfig(ShinkenModulesTest): # how much seconds give to mongod be fully started # == listening on its input socket/port. mongod_start_timeout = 60 @classmethod def _read_mongolog_and_raise(cls, log, proc, reason): try:
# along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx ip_tag_arbiter = modulesctx.get_module('ip_tag') get_instance = ip_tag_arbiter.get_instance class TestIpTag(ShinkenTest): def setUp(self): self.setup_with_file('etc/nagios_module_ip_tag.cfg') def test_hack_cmd_poller_tag(self): modconf = self.conf.modules.find_by_name('IpTag') # look for a objects that use it h1 = self.sched.hosts.find_by_name("test_host_0") h2 = self.sched.hosts.find_by_name("test_router_0")
# along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import * sys.path.append("../shinken/modules") from shinken.brok import Brok from shinken.modulesctx import modulesctx host_perfdata_broker = modulesctx.get_module('perfdata_host') get_instance = host_perfdata_broker.get_instance class TestConfig(ShinkenTest): # setUp is inherited from ShinkenTest def test_host_perfdata(self): print self.conf.modules # get our modules mod = None for m in self.conf.modules: if m.module_type == 'host_perfdata': mod = m self.assert_(mod is not None) self.assert_(mod.path == 'tmp/host-perfdata')
Test the hot dependencies arbiter module. """ import os, time from shinken_test import unittest, ShinkenTest, original_time_time, original_time_sleep # Need to use the real time-functions as we are reading timestamps # from the filesystem. time.time = original_time_time time.sleep = original_time_sleep from shinken.objects.module import Module from shinken.modulesctx import modulesctx hot_dependencies_arbiter = modulesctx.get_module('hot_dependencies') Hot_dependencies_arbiter = hot_dependencies_arbiter.Hot_dependencies_arbiter get_instance = hot_dependencies_arbiter.get_instance modconf = Module() modconf.module_name = "PickleRetention" modconf.module_type = hot_dependencies_arbiter.properties['type'] modconf.modules = [] modconf.properties = hot_dependencies_arbiter.properties.copy() try: import json except ImportError: # For old Python version, load # simple json (it can be hard json?! It's 2 functions guy!)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test Redis retention. """ from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.log import logger from shinken.modulesctx import modulesctx redis_retention_scheduler = modulesctx.get_module('retention_redis') get_instance = redis_retention_scheduler.get_instance modconf = Module() modconf.module_name = "RedisRetention" modconf.module_type = redis_retention_scheduler.properties['type'] modconf.properties = redis_retention_scheduler.properties.copy() try: import redis except ImportError: redis = None class TestRedis(ShinkenTest): # setUp is inherited from ShinkenTest
This class is for attaching a sqlite database to a livestatus broker module. It is one possibility for an exchangeable storage for log broks """ import os import sys import time import datetime import re from functools import partial from shinken.log import logger from shinken.modulesctx import modulesctx livestatus_broker = modulesctx.get_module('livestatus') LiveStatusStack = livestatus_broker.LiveStatusStack LOGCLASS_INVALID = livestatus_broker.LOGCLASS_INVALID Logline = livestatus_broker.Logline old_implementation = False try: import sqlite3 except ImportError: # python 2.4 do not have it try: import pysqlite2.dbapi2 as sqlite3 # but need the pysqlite2 install from http://code.google.com/p/pysqlite/downloads/list except ImportError: # python 2.4 do not have it import sqlite as sqlite3 # one last try old_implementation = True
try: from nose.exc import SkipTest except ImportError: SkipTest = None if not sys.version_info > (2, 5): if SkipTest: raise SkipTest("bah, i am 2.4.x") else: raise SystemExit(0) from shinken.objects.module import Module from shinken.modulesctx import modulesctx passwd_ui = modulesctx.get_module("auth_htpasswd") get_instance = passwd_ui.get_instance from shinken.log import logger if sys.version_info > (2, 5): modconf = Module() modconf.module_name = "PasswdUI" modconf.module_type = passwd_ui.properties["type"] modconf.properties = passwd_ui.properties.copy() class TestPasswdUI(ShinkenTest): # setUp is inherited from ShinkenTest
""" This class is for attaching a sqlite database to a livestatus broker module. It is one possibility for an exchangeable storage for log broks """ import os import sys import time import datetime import re from shinken.objects.service import Service from shinken.log import logger from shinken.modulesctx import modulesctx livestatus_broker = modulesctx.get_module('livestatus') # Import a class from the livestatus module, should be already loaded! #from shinken.modules.livestatus import module as livestatus_broker LiveStatusStack = livestatus_broker.LiveStatusStack LOGCLASS_INVALID = livestatus_broker.LOGCLASS_INVALID Logline = livestatus_broker.Logline old_implementation = False try: import sqlite3 except ImportError: # python 2.4 do not have it try: import pysqlite2.dbapi2 as sqlite3 # but need the pysqlite2 install from http://code.google.com/p/pysqlite/downloads/list except ImportError: # python 2.4 do not have it
# You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test generic pickle retention. """ import os import time from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx pickle_retention_file_scheduler = modulesctx.get_module( 'pickle_retention_file_scheduler') get_instance = pickle_retention_file_scheduler.get_instance modconf = Module() modconf.module_name = "PickleRetention" modconf.module_type = pickle_retention_file_scheduler.properties['type'] modconf.modules = [] modconf.properties = pickle_retention_file_scheduler.properties.copy() class TestPickleRetention(ShinkenTest): # setUp is inherited from ShinkenTest def test_pickle_retention(self): now = time.time() # get our modules
# Shinken is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # from shinken_test import * from shinken.modulesctx import modulesctx modulesctx.set_modulesdir(modules_dir) webui = modulesctx.get_module('webui') helper = webui.helper class TestUIHelper(ShinkenTest): def setUp(self): self.setup_with_file('etc/shinken_1r_1h_1s.cfg') def test_duration_print(self): now = time.time() # Got bogus return s = helper.print_duration(None) print "Res", s self.assert_(s == 'N/A') s = helper.print_duration(0)
# # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test the npcd broker module # import os, sys, string, time from multiprocessing import Queue from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx npcdmod_broker = modulesctx.get_module('npcdmod') Npcd_broker = npcdmod_broker.Npcd_broker sys.setcheckinterval(10000) modconf = Module() modconf.module_name = "ncpd" modconf.module_type = npcdmod_broker.properties['type'] modconf.modules = [] modconf.properties = npcdmod_broker.properties.copy() class TestNpcd(ShinkenTest): def add(self, b): self.broks[b.id] = b
# # This file is used to test reading and processing of config files # import os from tempfile import mktemp from shinken_test import unittest, ShinkenTest from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module("file_tag").get_instance class TestFileTag(ShinkenTest): def setUp(self): self.setup_with_file("etc/nagios_module_file_tag.cfg") def test_hack_cmd_poller_tag(self): modconf = self.conf.modules.find_by_name("FileTag") # look for a objects that use it h1 = self.sched.hosts.find_by_name("test_host_0") h2 = self.sched.hosts.find_by_name("test_router_0") # get our modules path = mktemp()
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import * from shinken.brok import Brok from shinken.modulesctx import modulesctx trending_broker = modulesctx.get_module('trending') get_instance = trending_broker.get_instance modconf = Module() modconf.module_name = "Trending" modconf.module_type = trending_broker.properties['type'] modconf.properties = trending_broker.properties.copy() class TestTrendingModule(ShinkenTest): # setUp is inherited from ShinkenTest def test_trending_module(self): mod = trending_broker.Trending_broker(modconf)
# along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx hack_poller_tag_by_macros = modulesctx.get_module('hack_poller_tag_by_macros') get_instance = hack_poller_tag_by_macros.get_instance class TestHackPollerTagByMacors(ShinkenTest): def setUp(self): self.setup_with_file('etc/nagios_module_hack_poller_tag_by_macros.cfg') def test_hack_cmd_poller_tag(self): modconf = self.conf.modules.find_by_name('HackCommandsPollerTag') # get our modules mod = hack_poller_tag_by_macros.Hack_pt_by_macros(modconf) # Look if we really change our commands
""" import os import time import datetime import re import sys import pymongo from pymongo import MongoClient import traceback from shinken.objects.service import Service from shinken.modulesctx import modulesctx # Import a class from the livestatus module, should be already loaded! livestatus = modulesctx.get_module('livestatus') LiveStatusStack = livestatus.LiveStatusStack # LOGCLASS_INVALID = livestatus.LOGCLASS_INVALID # Logline = livestatus.Logline from log_line import (Logline, LOGCLASS_INVALID) try: from pymongo import ReplicaSetConnection, ReadPreference except ImportError: ReplicaSetConnection = None ReadPreference = None from pymongo.errors import AutoReconnect from shinken.basemodule import BaseModule from shinken.log import logger
Test the hot dependencies arbiter module. """ import os, time from shinken_test import unittest, ShinkenTest, time_hacker # Need to use the real time-functions as we are reading timestamps # from the filesystem. time_hacker.set_real_time() from shinken.objects.module import Module from shinken.modulesctx import modulesctx hot_dependencies_arbiter = modulesctx.get_module('hot_dependencies') Hot_dependencies_arbiter = hot_dependencies_arbiter.Hot_dependencies_arbiter get_instance = hot_dependencies_arbiter.get_instance modconf = Module() modconf.module_name = "PickleRetention" modconf.module_type = hot_dependencies_arbiter.properties['type'] modconf.modules = [] modconf.properties = hot_dependencies_arbiter.properties.copy() try: import json except ImportError: # For old Python version, load # simple json (it can be hard json?! It's 2 functions guy!) try:
# You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from Queue import Empty from multiprocessing import Queue, Manager, active_children from shinken_test import * from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx nrpe_poller = modulesctx.get_module('booster_nrpe') get_instance = nrpe_poller.get_instance from shinken.message import Message modconf = Module() modconf.module_name = "NrpePoller" modconf.module_type = nrpe_poller.properties['type'] modconf.properties = nrpe_poller.properties.copy() class TestNrpePoller(ShinkenTest): # Uncomment this is you want to use a specific configuration # for your test #def setUp(self): # self.setup_with_file('etc/shinken_module_hack_cmd_poller_tag.cfg')
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # from shinken_test import unittest, ShinkenTest from shinken.brok import Brok from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module('merlindb').get_instance class TestConfig(ShinkenTest): # setUp is inherited from ShinkenTest def test_simplelog(self): print self.conf.modules # get our modules mod = None for m in self.conf.modules: if m.module_name == 'ToMerlindb_Sqlite': mod = m self.assert_(mod is not None) self.assert_( mod.database_path == '/usr/local/shinken/var/merlindb.sqlite')
# along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx hack_poller_tag_by_macros = modulesctx.get_module('hack_poller_tag_by_macros') get_instance = hack_poller_tag_by_macros.get_instance class TestHackPollerTagByMacors(ShinkenTest): def setUp(self): self.setup_with_file('etc/nagios_module_hack_poller_tag_by_macros.cfg') def test_hack_cmd_poller_tag(self): modconf = self.conf.modules.find_by_name('HackCommandsPollerTag') # get our modules mod = hack_poller_tag_by_macros.Hack_pt_by_macros(modconf) # Look if we really change our commands # Calls the mod with our config
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test Nagios retention """ from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx nagios_retention_file_scheduler = modulesctx.get_module('retention_nagios') get_instance = nagios_retention_file_scheduler.get_instance modconf = Module() modconf.module_name = "NagiosRetention" modconf.module_type = nagios_retention_file_scheduler.properties['type'] modconf.properties = nagios_retention_file_scheduler.properties.copy() class TestNagiosRetention(ShinkenTest): # setUp is inherited from ShinkenTest def test_pickle_retention(self): # get our modules mod = nagios_retention_file_scheduler.Nagios_retention_scheduler( modconf, 'etc/module_nagios_retention/retention.dat')
# # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx hack_commands_poller_tag_arbiter = modulesctx.get_module( 'hack_commands_poller_tag_arbiter') get_instance = hack_commands_poller_tag_arbiter.get_instance class TestHackCmdPollerTag(ShinkenTest): def setUp(self): self.setup_with_file('etc/nagios_module_hack_cmd_poller_tag.cfg') def test_hack_cmd_poller_tag(self): modconf = self.conf.modules.find_by_name('HackCommandsPollerTag') # get our modules mod = hack_commands_poller_tag_arbiter.Hack_cmds_pt(modconf) # Look if we really change our commands # Calls the mod with our config
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test Mongodb retention. """ from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx mongodb_retention = modulesctx.get_module('retention_mongodb') get_instance = mongodb_retention.get_instance modconf = Module() modconf.module_name = "MongodbRetention" modconf.uri = 'mongodb://127.0.0.1:27017' modconf.database = 'test' modconf.module_type = mongodb_retention.properties['type'] modconf.properties = mongodb_retention.properties.copy() class TestMongodbRetention(ShinkenTest): # setUp is inherited from ShinkenTest def test_mongodb_retention(self): # get our modules
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module('status_dat').get_instance class TestConfig(ShinkenTest): # setUp is inherited from ShinkenTest def nb_of_string(self, buf, s): nb_s = 0 for line in buf.splitlines(): if line == s: print "Find string" nb_s += 1 return nb_s
# along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx ip_tag_arbiter = modulesctx.get_module('ip-tag') get_instance = ip_tag_arbiter.get_instance class TestIpTag(ShinkenTest): def setUp(self): self.setup_with_file('etc/nagios_module_ip_tag.cfg') def test_hack_cmd_poller_tag(self): modconf = self.conf.modules.find_by_name('IpTag') # look for a objects that use it h1 = self.sched.hosts.find_by_name("test_host_0") h2 = self.sched.hosts.find_by_name("test_router_0")
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # exit() import os from shinken_test import * from shinken.brok import Brok from shinken.modulesctx import modulesctx trending_broker = modulesctx.get_module('trending') get_instance = trending_broker.get_instance modconf = Module() modconf.module_name = "Trending" modconf.module_type = trending_broker.properties['type'] modconf.properties = trending_broker.properties.copy() class TestTrendingModule(ShinkenTest): # setUp is inherited from ShinkenTest def test_trending_module(self): mod = trending_broker.Trending_broker(modconf)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test Nagios retention """ from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx nagios_retention_file_scheduler = modulesctx.get_module('retention_nagios') get_instance = nagios_retention_file_scheduler.get_instance modconf = Module() modconf.module_name = "NagiosRetention" modconf.module_type = nagios_retention_file_scheduler.properties['type'] modconf.properties = nagios_retention_file_scheduler.properties.copy() class TestNagiosRetention(ShinkenTest): # setUp is inherited from ShinkenTest def test_pickle_retention(self): # get our modules mod = nagios_retention_file_scheduler.Nagios_retention_scheduler(
# You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx hack_commands_poller_tag_arbiter = modulesctx.get_module('hack_commands_poller_tag_arbiter') get_instance = hack_commands_poller_tag_arbiter.get_instance class TestHackCmdPollerTag(ShinkenTest): def setUp(self): self.setup_with_file('etc/nagios_module_hack_cmd_poller_tag.cfg') def test_hack_cmd_poller_tag(self): modconf = self.conf.modules.find_by_name('HackCommandsPollerTag') # get our modules mod = hack_commands_poller_tag_arbiter.Hack_cmds_pt(modconf) # Look if we really change our commands
# along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test pickle retention arbiter. """ import os import copy from shinken_test import unittest, ShinkenTest from shinken.daemons.arbiterdaemon import Arbiter from shinken.objects.module import Module from shinken.modulesctx import modulesctx pickle_retention_file_generic = modulesctx.get_module('pickle_retention_file_generic') get_instance = pickle_retention_file_generic.get_instance modconf = Module() modconf.module_name = "PickleRetentionGeneric" modconf.module_type = pickle_retention_file_generic.properties['type'] modconf.properties = pickle_retention_file_generic.properties.copy() class TestPickleRetentionArbiter(ShinkenTest): # setUp is inherited from ShinkenTest def test_pickle_retention(self): # get our modules mod = pickle_retention_file_generic.Pickle_retention_generic( modconf, 'tmp/retention-test.dat')
This class is for attaching a mongodb database to a livestatus broker module. It is one possibility for an exchangeable storage for log broks """ import os import time import datetime import re import sys import pymongo from shinken.objects.service import Service from shinken.modulesctx import modulesctx # Import a class from the livestatus module, should be already loaded! livestatus = modulesctx.get_module("livestatus") # when livestatus will be correctly setup, replace: LiveStatusStack = livestatus.LiveStatusStack LOGCLASS_INVALID = livestatus.LOGCLASS_INVALID Logline = livestatus.Logline # by: # from livestatus import LiveStatusStack # from livestatus.log_line import LOGCLASS_INVALID, Logline try: from pymongo import ReplicaSetConnection, ReadPreference except ImportError: ReplicaSetConnection = None ReadPreference = None
from shinken.misc.datamanager import datamgr from shinken.log import logger # from shinken_test import ( modules_dir, ShinkenTest, time_hacker, # not used here but "sub"-imported by lvestatus test (to be corrected) ) modulesctx.set_modulesdir(modules_dir) # Special Livestatus module opening since the module rename #from shinken.modules.livestatus import module as livestatus_broker livestatus_broker = modulesctx.get_module('livestatus') LiveStatus_broker = livestatus_broker.LiveStatus_broker LiveStatus = livestatus_broker.LiveStatus LiveStatusRegenerator = livestatus_broker.LiveStatusRegenerator LiveStatusQueryCache = livestatus_broker.LiveStatusQueryCache Logline = livestatus_broker.Logline LiveStatusLogStoreMongoDB = modulesctx.get_module('logstore-mongodb').LiveStatusLogStoreMongoDB LiveStatusLogStoreSqlite = modulesctx.get_module('logstore-sqlite').LiveStatusLogStoreSqlite livestatus_modconf = Module() livestatus_modconf.module_name = "livestatus" livestatus_modconf.module_type = livestatus_broker.properties['type'] livestatus_modconf.properties = livestatus_broker.properties.copy()
# along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from Queue import Empty from multiprocessing import Queue, Manager, active_children from shinken_test import * from shinken.log import logger from shinken.objects.module import Module from shinken.modulesctx import modulesctx nrpe_poller = modulesctx.get_module('booster_nrpe') get_instance = nrpe_poller.get_instance from shinken.message import Message modconf = Module() modconf.module_name = "NrpePoller" modconf.module_type = nrpe_poller.properties['type'] modconf.properties = nrpe_poller.properties.copy() class TestNrpePoller(ShinkenTest): # Uncomment this is you want to use a specific configuration # for your test #def setUp(self): # self.setup_with_file('etc/nagios_module_hack_cmd_poller_tag.cfg')
from shinken_test import time_hacker, unittest from shinken.modulesctx import modulesctx from shinken.objects.module import Module from shinken.comment import Comment from shinken.objects.service import Service from mock_livestatus import mock_livestatus_handle_request from livestatus.log_line import Logline LiveStatusLogStoreMongoDB = modulesctx.get_module('logstore-mongodb').LiveStatusLogStoreMongoDB sys.setcheckinterval(10000) @mock_livestatus_handle_request class TestConfig(ShinkenModulesTest): # how much seconds give to mongod be fully started # == listening on its input socket/port. mongod_start_timeout = 60 @classmethod def _read_mongolog_and_raise(cls, log, proc, reason): try:
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os from shinken_test import unittest, ShinkenTest from shinken.brok import Brok from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module('simplelog').get_instance class TestConfig(ShinkenTest): # setUp is inherited from ShinkenTest def test_simplelog(self): print self.conf.modules # get our modules mod = None for m in self.conf.modules: if m.module_type == 'simple_log': mod = m self.assert_(mod is not None) self.assert_(mod.path == 'tmp/nagios.log')
# You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test the npcd broker module # import os, sys, string, time from multiprocessing import Queue from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx npcdmod_broker = modulesctx.get_module('npcdmod') Npcd_broker = npcdmod_broker.Npcd_broker sys.setcheckinterval(10000) modconf = Module() modconf.module_name = "ncpd" modconf.module_type = npcdmod_broker.properties['type'] modconf.modules = [] modconf.properties = npcdmod_broker.properties.copy() class TestNpcd(ShinkenTest): def add(self, b):
# You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. """ Test generic pickle retention. """ import os import time from shinken_test import unittest, ShinkenTest from shinken.objects.module import Module from shinken.modulesctx import modulesctx pickle_retention_file_scheduler = modulesctx.get_module('pickle_retention_file_scheduler') get_instance = pickle_retention_file_scheduler.get_instance modconf = Module() modconf.module_name = "PickleRetention" modconf.module_type = pickle_retention_file_scheduler.properties['type'] modconf.modules = [] modconf.properties = pickle_retention_file_scheduler.properties.copy() class TestPickleRetention(ShinkenTest): # setUp is inherited from ShinkenTest def test_pickle_retention(self): now = time.time() # get our modules
# # Shinken is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # from shinken_test import * from shinken.modulesctx import modulesctx webui = modulesctx.get_module('webui') helper = webui.helper class TestUIHelper(ShinkenTest): def setUp(self): self.setup_with_file('etc/nagios_1r_1h_1s.cfg') def test_duration_print(self): now = time.time() # Got bogus return s = helper.print_duration(None) print "Res", s self.assert_(s == 'N/A') s = helper.print_duration(0)
from shinken_test import unittest, ShinkenTest try: from nose.exc import SkipTest except ImportError: SkipTest = None if not sys.version_info > (2, 5): if SkipTest: raise SkipTest("bah, i am 2.4.x") else: raise SystemExit(0) from shinken.objects.module import Module from shinken.modulesctx import modulesctx passwd_ui = modulesctx.get_module('auth_htpasswd') get_instance = passwd_ui.get_instance from shinken.log import logger if sys.version_info > (2, 5): modconf = Module() modconf.module_name = "PasswdUI" modconf.module_type = passwd_ui.properties['type'] modconf.properties = passwd_ui.properties.copy() class TestPasswdUI(ShinkenTest): # setUp is inherited from ShinkenTest
This class is for attaching a mongodb database to a livestatus broker module. It is one possibility for an exchangeable storage for log broks """ import os import time import datetime import re import sys import pymongo from shinken.objects.service import Service from shinken.modulesctx import modulesctx # Import a class from the livestatus module, should be already loaded! livestatus = modulesctx.get_module('livestatus') # when livestatus will be correctly setup, replace: LiveStatusStack = livestatus.LiveStatusStack LOGCLASS_INVALID = livestatus.LOGCLASS_INVALID Logline = livestatus.Logline # by: #from livestatus import LiveStatusStack #from livestatus.log_line import LOGCLASS_INVALID, Logline try: from pymongo import ReplicaSetConnection, ReadPreference except ImportError: ReplicaSetConnection = None
# # You should have received a copy of the GNU Affero General Public License # along with Shinken. If not, see <http://www.gnu.org/licenses/>. # # This file is used to test reading and processing of config files # import os import time from shinken_test import unittest, ShinkenTest from shinken.modulesctx import modulesctx get_instance = modulesctx.get_module('perfdata_service').get_instance class TestModSRVPErfdata(ShinkenTest): # setUp is inherited from ShinkenTest def test_service_perfdata(self): print self.conf.modules # get our modules mod = None for m in self.conf.modules: if m.module_type == 'service_perfdata': mod = m self.assert_(mod is not None) self.assert_(mod.path == 'tmp/service-perfdata') self.assert_(mod.module_name == 'Service-Perfdata')