[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Naparuba
naparuba at gmail.com
Tue Feb 28 22:07:16 UTC 2012
The following commit has been merged in the debian/master branch:
commit d58aaf76c48c9be033d82671a685a0e815d3a610
Author: Naparuba <naparuba at gmail.com>
Date: Mon Nov 21 12:53:11 2011 +0100
*Add : poller can now load a standard external modules like the namedPipe one, and get external commands from it
*Fix : missing a Pyro exception in poller/reactionner code.
diff --git a/etc/shinken-specific.cfg b/etc/shinken-specific.cfg
index afcc9ae..0967944 100644
--- a/etc/shinken-specific.cfg
+++ b/etc/shinken-specific.cfg
@@ -58,7 +58,13 @@ define poller{
# advanced features
- #modules NrpeBooster
+ #modules NrpeBooster,CommandFile
+ # NRPE Boster will avoid to use the check_nrpe binary
+ # and so can enhance your performances if you got
+ # lot of nrpe calls
+ # CommandFile can allow a nagios.cmd named pipe to be read by your
+ # poller, and so use a distributed check_mk check is you want
+
#poller_tags None
realm All
}
diff --git a/shinken/daemons/brokerdaemon.py b/shinken/daemons/brokerdaemon.py
index 8038972..f792175 100644
--- a/shinken/daemons/brokerdaemon.py
+++ b/shinken/daemons/brokerdaemon.py
@@ -275,6 +275,7 @@ class Broker(BaseSatellite):
except Empty :
full_queue = False
+
# We get new broks from schedulers
# REF: doc/broker-modules.png (2)
def get_new_broks(self, type='scheduler'):
diff --git a/shinken/modules/android_sms.py b/shinken/modules/android_sms.py
index 5df5fda..e6cd290 100644
--- a/shinken/modules/android_sms.py
+++ b/shinken/modules/android_sms.py
@@ -38,6 +38,8 @@ properties = {
'daemons' : ['reactionner'],
'type' : 'android_sms',
'external' : False,
+ # To be a real worker module, you must set this
+ 'worker_capable' : True,
}
diff --git a/shinken/modules/dummy_poller.py b/shinken/modules/dummy_poller.py
index 72d3e7e..236075b 100644
--- a/shinken/modules/dummy_poller.py
+++ b/shinken/modules/dummy_poller.py
@@ -33,7 +33,8 @@ properties = {
'daemons' : ['poller'],
'type' : 'dummy_poller',
'external' : False,
- 'phases' : ['worker'],
+ # To be a real worker module, you must set this
+ 'worker_capable' : True,
}
diff --git a/shinken/modules/named_pipe.py b/shinken/modules/named_pipe.py
index f3e0cd2..bbe1279 100644
--- a/shinken/modules/named_pipe.py
+++ b/shinken/modules/named_pipe.py
@@ -29,9 +29,10 @@ from shinken.basemodule import BaseModule
from shinken.external_command import ExternalCommand
properties = {
- 'daemons' : ['arbiter', 'receiver'],
+ 'daemons' : ['arbiter', 'receiver', 'poller'],
'type' : 'named_pipe',
'external' : True,
+ 'worker_capable' : False,
}
#called by the plugin manager to get a broker
diff --git a/shinken/modules/nrpe_poller.py b/shinken/modules/nrpe_poller.py
index 5458cad..4f36d22 100644
--- a/shinken/modules/nrpe_poller.py
+++ b/shinken/modules/nrpe_poller.py
@@ -53,7 +53,8 @@ properties = {
'daemons' : ['poller'],
'type' : 'nrpe_poller',
'external' : False,
- 'phases' : ['worker'],
+ # To be a real worker module, you must set this
+ 'worker_capable' : True,
}
diff --git a/shinken/satellite.py b/shinken/satellite.py
index 6803d84..625b98f 100644
--- a/shinken/satellite.py
+++ b/shinken/satellite.py
@@ -41,6 +41,8 @@ try:
except ImportError:
is_android = False
+from Queue import Empty
+
if not is_android:
from multiprocessing import Queue, Manager, active_children, cpu_count
else:
@@ -79,6 +81,12 @@ Pyro_exp_pack = (Pyro.errors.ProtocolError, Pyro.errors.URIError, \
Pyro.errors.DaemonError)
+# Class for say we are facing a non worker module
+# but a standard one
+class NotWorkerMod(BaseException):
+ pass
+
+
# Interface for Arbiter, our big MASTER
# It put us our conf
class IForArbiter(Interface):
@@ -248,7 +256,7 @@ class Satellite(BaseSatellite):
try:
pyro.set_timeout(sch_con, 5)
new_run_id = sch_con.get_running_id()
- except (Pyro.errors.ProtocolError, Pyro.errors.NamingError, cPickle.PicklingError, KeyError, Pyro.errors.CommunicationError) , exp:
+ except (Pyro.errors.ProtocolError, Pyro.errors.NamingError, cPickle.PicklingError, KeyError, Pyro.errors.CommunicationError, Pyro.errors.DaemonError) , exp:
logger.log("[%s] Scheduler %s is not initilised or got network problem: %s" % (self.name, sname, str(exp)))
sched['con'] = None
return
@@ -390,7 +398,10 @@ class Satellite(BaseSatellite):
else:
for module in self.modules_manager.instances:
if module.properties['type'] == module_name:
- target = module.work
+ # First to see if the module is a 'worker' one or not
+ if not module.properties.get('worker_capable', False):
+ raise NotWorkerMod
+ target = module.work
if target is None:
return
w = Worker(1, q, self.returns_queue, self.processes_by_worker, \
@@ -569,14 +580,7 @@ class Satellite(BaseSatellite):
# REF: doc/shinken-action-queues.png (1)
def get_new_actions(self):
now = time.time()
- # HACK
- #r = []
- #for i in xrange(1, 1500):#750):
- # c = Check('scheduled', '/bin/ping localhost -p 1 -c 1', None, now)
- # r.append(c)
- #self.add_actions(r, 0)
- #return
-
+
# Here are the differences between a
# poller and a reactionner:
# Poller will only do checks,
@@ -625,18 +629,30 @@ class Satellite(BaseSatellite):
# In android we got a Queue, and a manager list for others
def get_returns_queue_len(self):
-# if not is_android:
-# return len(self.returns_queue)
return self.returns_queue.qsize()
# In android we got a Queue, and a manager list for others
def get_returns_queue_item(self):
-# if not is_android:
-# return self.returns_queue.pop()
return self.returns_queue.get()
+ # Get 'objects' from external modules
+ # from now nobody use it, but it can be useful
+ # for a moduel like livestatus to raise external
+ # commandsfor example
+ def get_objects_from_from_queues(self):
+ for f in self.modules_manager.get_external_from_queues():
+ full_queue = True
+ while full_queue:
+ try:
+ o = f.get(block=False)
+ self.add(o)
+ except Empty :
+ full_queue = False
+
+
+
# An arbiter ask us to wait a new conf, so we must clean
# all our mess we did, and close modules too
def clean_previous_run(self):
@@ -741,6 +757,9 @@ class Satellite(BaseSatellite):
# REF: doc/shinken-action-queues.png (6)
self.manage_returns()
+ # Get objects from our modules that are not wroker based
+ self.get_objects_from_from_queues()
+
# Say to modules it's a new tick :)
self.hook_point('tick')
@@ -908,8 +927,19 @@ we must register our interfaces for 3 possible callers: arbiter, schedulers or b
# Allocate Mortal Threads
for _ in xrange(1, self.min_workers):
- for mod in self.q_by_mod:
- self.create_and_launch_worker(module_name=mod)
+ to_del = []
+ for mod in self.q_by_mod:
+ try:
+ self.create_and_launch_worker(module_name=mod)
+ # Maybe this modules is not a true worker one.
+ # if so, just delete if from q_by_mod
+ except NotWorkerMod:
+ to_del.append(mod)
+
+ for mod in to_del:
+ print 'The module %s is not a worker one, I remove it from the worker list' % mod
+ del self.q_by_mod[mod]
+
# Now main loop
self.do_mainloop()
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list