[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a
Naparuba
naparuba at gmail.com
Tue Feb 28 22:13:20 UTC 2012
The following commit has been merged in the debian/master branch:
commit 11bd5a4cba1006dccdef3311408547c541a9b39b
Author: Naparuba <naparuba at gmail.com>
Date: Thu Jan 12 16:34:46 2012 +0100
Add : first attempt for the skonf daemon. Don't loose your time in running it, it doesn't work from now :)
diff --git a/bin/shinken-arbiter b/bin/shinken-skonf
similarity index 96%
copy from bin/shinken-arbiter
copy to bin/shinken-skonf
index 09082d1..af9157c 100755
--- a/bin/shinken-arbiter
+++ b/bin/shinken-skonf
@@ -66,7 +66,7 @@ except ImportError:
from shinken.bin import VERSION
from shinken.pyro_wrapper import PYRO_VERSION
-from shinken.daemons.arbiterdaemon import Arbiter
+from shinken.daemons.skonfdaemon import Skonf
parser = optparse.OptionParser(
"%prog [options] -c configfile [-c additional_config_file]",
@@ -92,13 +92,13 @@ opts, args = parser.parse_args()
if not opts.config_files:
- parser.error("Requires at least one config file (option -c/--config")
+ parser.error("Requires at least one config file (option -c/--config)")
if args:
parser.error("Does not accept any argument. Use option -c/--config")
# Protect for windows multiprocessing that will RELAUNCH all
if __name__ == '__main__':
- daemon = Arbiter(debug=opts.debug_file is not None, **opts.__dict__)
+ daemon = Skonf(debug=opts.debug_file is not None, **opts.__dict__)
daemon.main()
# For perf tuning :
#import cProfile
diff --git a/etc/discovery.cfg b/etc/skonf.cfg
similarity index 89%
copy from etc/discovery.cfg
copy to etc/skonf.cfg
index 35850e3..50a39c2 100644
--- a/etc/discovery.cfg
+++ b/etc/skonf.cfg
@@ -1,6 +1,6 @@
# Log file of the discovery command
-log_file=/tmp/discovery.log
+log_file=/tmp/skonf.log
# Configuration files with common discovery objects
@@ -19,7 +19,7 @@ cfg_file=commands.cfg
resource_file=resource.cfg
# Lock file (with pid) for Arbiterd
-lock_file=discovery.pid
+lock_file=skonf.pid
# Strip FQDN of the name ID to keep only the
# basename of the element
diff --git a/shinken/daemons/arbiterdaemon.py b/shinken/daemons/skonfdaemon.py
similarity index 83%
copy from shinken/daemons/arbiterdaemon.py
copy to shinken/daemons/skonfdaemon.py
index f3eac5a..daac622 100644
--- a/shinken/daemons/arbiterdaemon.py
+++ b/shinken/daemons/skonfdaemon.py
@@ -36,6 +36,23 @@ from shinken.brok import Brok
from shinken.external_command import ExternalCommand
from shinken.util import safe_print
+
+# Now the bottle HTTP part :)
+from shinken.webui.bottle import Bottle, run, static_file, view, route, request, response
+# Debug
+import shinken.webui.bottle as bottle
+bottle.debug(True)
+
+#Import bottle lib to make bottle happy
+bottle_dir = os.path.abspath(os.path.dirname(bottle.__file__))
+sys.path.insert(0, bottle_dir)
+
+
+bottle.TEMPLATE_PATH.append(os.path.join(bottle_dir, 'views'))
+bottle.TEMPLATE_PATH.append(bottle_dir)
+
+
+
# Interface for the other Arbiter
# It connects, and together we decide who's the Master and who's the Slave, etc.
# Here is a also a function to get a new conf from the master
@@ -111,12 +128,12 @@ class IForArbiter(Interface):
return res
-# Main Arbiter Class
-class Arbiter(Daemon):
+# Main Skonf Class
+class Skonf(Daemon):
def __init__(self, config_files, is_daemon, do_replace, verify_only, debug, debug_file):
- super(Arbiter, self).__init__('arbiter', config_files[0], is_daemon, do_replace, debug, debug_file)
+ super(Skonf, self).__init__('skonf', config_files[0], is_daemon, do_replace, debug, debug_file)
self.config_files = config_files
@@ -150,73 +167,6 @@ class Arbiter(Daemon):
logger.log('Warning : cannot manage object type %s (%s)' % (type(b), b))
- # We must push our broks to the broker
- # because it's stupid to make a crossing connection
- # so we find the broker responbile for our broks,
- # and we send him it
- # TODO : better find the broker, here it can be dead?
- # or not the good one?
- def push_broks_to_broker(self):
- for brk in self.conf.brokers:
- # Send only if alive of course
- if brk.manage_arbiters and brk.alive:
- is_send = brk.push_broks(self.broks)
- if is_send:
- # They are gone, we keep none!
- self.broks.clear()
-
-
- # We must take external_commands from all satellites
- # like brokers, pollers, reactionners or receivers
- def get_external_commands_from_satellites(self):
- sat_lists = [self.conf.brokers, self.conf.receivers,
- self.conf.pollers, self.conf.reactionners]
- for lst in sat_lists:
- for sat in lst:
- # Get only if alive of course
- if sat.alive:
- new_cmds = sat.get_external_commands()
- for new_cmd in new_cmds:
- self.external_commands.append(new_cmd)
-
-
- # Our links to satellites can raise broks. We must send them
- def get_broks_from_satellitelinks(self):
- tabs = [self.conf.brokers, self.conf.schedulerlinks,
- self.conf.pollers, self.conf.reactionners,
- self.conf.receivers]
- for tab in tabs:
- for s in tab:
- new_broks = s.get_all_broks()
- for b in new_broks:
- self.add(b)
-
-
- # Our links to satellites can raise broks. We must send them
- def get_initial_broks_from_satellitelinks(self):
- tabs = [self.conf.brokers, self.conf.schedulerlinks,
- self.conf.pollers, self.conf.reactionners,
- self.conf.receivers]
- for tab in tabs:
- for s in tab:
- b = s.get_initial_status_brok()
- self.add(b)
-
-
- # Load the external commander
- def load_external_command(self, e):
- self.external_command = e
- self.fifo = e.open()
-
-
- def get_daemon_links(self, daemon_type):
- #the attribute name to get those differs for schedulers and arbiters
- if (daemon_type == 'scheduler' or daemon_type == 'arbiter'):
- daemon_links = daemon_type+'links'
- else:
- daemon_links = daemon_type+'s'
- return daemon_links
-
def load_config_file(self):
print "Loading configuration"
@@ -421,12 +371,31 @@ class Arbiter(Daemon):
## We need to set self.host & self.port to be used by do_daemon_init_and_start
self.host = self.me.address
- self.port = self.me.port
+ self.port = 8766#self.me.port
logger.log("Configuration Loaded")
print ""
+ def load_web_configuration(self):
+ self.plugins = []
+
+ self.http_port = 7766#int(getattr(modconf, 'port', '7767'))
+ self.http_host = '0.0.0.0'#getattr(modconf, 'host', '0.0.0.0')
+ self.auth_secret = 'CHANGE_ME'.encode('utf8', 'replace')#getattr(modconf, 'auth_secret').encode('utf8', 'replace')
+ self.http_backend = 'auto'#getattr(modconf, 'http_backend', 'auto')
+ self.login_text = None#getattr(modconf, 'login_text', None)
+ self.allow_html_output = False#to_bool(getattr(modconf, 'allow_html_output', '0'))
+ self.remote_user_enable = '0'#getattr(modconf, 'remote_user_enable', '0')
+ self.remote_user_variable = 'X_REMOTE_USER'#getattr(modconf, 'remote_user_variable', 'X_REMOTE_USER')
+
+ # Load the photo dir and make it a absolute path
+ self.photo_dir = 'photos'#getattr(modconf, 'photo_dir', 'photos')
+ self.photo_dir = os.path.abspath(self.photo_dir)
+ print "Webui : using the backend", self.http_backend
+
+
+
# Main loop function
def main(self):
try:
@@ -435,6 +404,7 @@ class Arbiter(Daemon):
self.log.log(line)
self.load_config_file()
+ self.load_web_configuration()
self.do_daemon_init_and_start()
self.uri_arb = self.pyro_daemon.register(self.interface, "ForArbiter")
@@ -572,16 +542,7 @@ class Arbiter(Daemon):
if self.conf.human_timestamp_log:
logger.set_human_format()
- logger.log("Begin to dispatch configurations to satellites")
- self.dispatcher = Dispatcher(self.conf, self.me)
- self.dispatcher.check_alive()
- self.dispatcher.check_dispatch()
- # REF: doc/shinken-conf-dispatching.png (3)
- self.dispatcher.dispatch()
-
- # Now we can get all initial broks for our satellites
- self.get_initial_broks_from_satellitelinks()
-
+
suppl_socks = None
# Now create the external commander. It's just here to dispatch
@@ -626,35 +587,7 @@ class Arbiter(Daemon):
# Call modules that manage a starting tick pass
self.hook_point('tick')
-
- self.dispatcher.check_alive()
- self.dispatcher.check_dispatch()
- # REF: doc/shinken-conf-dispatching.png (3)
- self.dispatcher.dispatch()
- self.dispatcher.check_bad_dispatch()
-
- # Now get things from our module instances
- self.get_objects_from_from_queues()
-
- # Maybe our satellites links raise new broks. Must reap them
- self.get_broks_from_satellitelinks()
-
- # One broker is responsible for our broks,
- # we must give him our broks
- self.push_broks_to_broker()
- self.get_external_commands_from_satellites()
- #self.get_external_commands_from_receivers()
- # send_conf_to_schedulers()
-
- if self.nb_broks_send != 0:
- print "Nb Broks send:", self.nb_broks_send
- self.nb_broks_send = 0
-
- self.push_external_commands_to_schedulers()
-
- # It's send, do not keep them
- # TODO: check if really send. Queue by scheduler?
- self.external_commands = []
+ print "Tick"
# If ask me to dump my memory, I do it
if self.need_dump_memory:
--
UNNAMED PROJECT
More information about the Pkg-nagios-changes
mailing list