This module provie Arbiter class used to run a arbiter daemon
Bases: alignak.daemon.Daemon
Arbiter class. Referenced as “app” in most Interface
Generic function to add objects to queues. Only manage Broks and ExternalCommand
Parameters: | b (alignak.brok.Brok | alignak.external_command.ExternalCommand) – objects to add |
---|---|
Returns: | None |
Raise log for timeperiod change (useful for debug)
Returns: | None |
---|
Loop turn for Arbiter If master, run, else wait for master death
Returns: | None |
---|
Get broks from my internal satellitelinks (satellite status)
Returns: | None |
---|
TODO: Why satellitelink obj have broks and not the app itself?
Get the name of arbiter link (here arbiters)
Parameters: | daemon_type (str) – daemon type |
---|---|
Returns: | named used to stroke this deamon type links |
Return type: | str |
Returns the daemons list defined in our conf for the given type
Parameters: | daemon_type (str) – deamon type needed |
---|---|
Returns: | attribute value if exist |
Return type: | str | None |
Get external commands from all other satellites
Returns: | None |
---|
Get initial broks from my internal satellitelinks (satellite status)
Returns: | None |
---|
Get data for retention
Returns: | broks and external commands in a dict |
---|---|
Return type: | dict |
Get state of modules and create a scheme for stats data of daemon
Returns: | A dict with the following structure |
---|
{ 'metrics': ['arbiter.%s.external-commands.queue %d %d'],
'version': __version__,
'name': self.name,
'type': 'arbiter',
'hosts': len(self.conf.hosts)
'services': len(self.conf.services)
'modules':
{'internal': {'name': "MYMODULE1", 'state': 'ok'},
{'external': {'name': "MYMODULE2", 'state': 'stopped'},
]
}
Return type: | dict |
---|
Load main configuration file (alignak.cfg):
* Read all files given in the -c parameters
* Read all .cfg files in cfg_dir
* Read all files in cfg_file
* Create objects (Arbiter, Module)
* Set HTTP links info (ssl etc)
* Load its own modules
* Execute read_configuration hook (for arbiter modules)
* Create all objects (Service, Host, Realms ...)
* "Compile" configuration (Linkify, explode, apply inheritance, fill default values ...)
* Cut conf into parts and prepare it for sending
Returns: | None |
---|
Set external_command attribute to the external command manager and fifo attribute to a new fifo fd
Parameters: | ecm (alignak.external_command.ExternalCommandManager) – External command manager to set |
---|---|
Returns: | None |
TODO: Is fifo useful?
Load configuration objects from arbiter modules If module implements get_objects arbiter will call it and add create objects
Parameters: | raw_objects (dict) – raw objects we got from reading config files |
---|---|
Returns: | None |
Main arbiter function:
* Set logger
* Log Alignak headers
* Init daemon
* Launch modules
* Load retention
* Do mainloop
Returns: | None |
---|
Restore data from retention (broks, and external commands)
Parameters: | data (dict) – data to restore |
---|---|
Returns: | None |
This module provide Broker class used to run a broker daemon
Bases: alignak.satellite.BaseSatellite
Class to manage a Broker daemon A Broker is used to get data from Scheduler and send them to modules. These modules in most cases export to other softwares, databases...
Add elt to this broker
Parameters: | elt (object) – object to add |
---|---|
Returns: | None |
Add broks to global queue
Parameters: | broks (object) – some items |
---|---|
Returns: | None |
Loop use to: * check if modules are alive, if not restart them * add broks to queue of each modules
Returns: | None |
---|
Initialize or re-initialize connection with scheduler or arbiter if type == arbiter
Parameters: | |
---|---|
Returns: | None |
If d_type parameter is in list, return this object linked, else None
Parameters: | d_type (str) – name of object |
---|---|
Returns: | return the object linked |
Return type: | object |
Get new broks from daemon defined in type parameter
Parameters: | i_type (str) – type of object |
---|---|
Returns: | None |
Get information of modules (internal and external) and add metrics of them
Returns: | dictionary with state of all modules (internal and external) |
---|---|
Return type: | dict |
Returns: | None |
We will get in the broks list the broks from the arbiters, but as the arbiter_broks list can be push by arbiter without Global lock, we must protect this with he list lock
Returns: | None |
---|
Get all broks from self.broks_internal_raised and we put them in self.broks
Returns: | None |
---|
Check if last_connection has been made very recently
Parameters: | elt (list) – list with last_connection property |
---|---|
Returns: | True if last connection has been made less than 5 seconds |
Return type: | bool |
Get a brok. We put brok data to the modules
Parameters: | brok (object) – object with data |
---|---|
Returns: | None |
Wrapper function for the real function do_ just for timing the connection
Parameters: | |
---|---|
Returns: | do_pynag_con_init return always True, so we return always True |
Return type: | bool |
This modules provides class for the Poller daemon
Bases: alignak.satellite.Satellite
Poller class. Referenced as “app” in most Interface
This module provide Reactionner class used to launch notifications or event handlers
Bases: alignak.satellite.Satellite
This class is an application that launches actions for the schedulers Actions can be:
Notifications Event handlers
The configuration consists of a list of Schedulers for which the Reactionner will launch actions for.
This module provide Receiver class used to run a receiver daemon
Bases: alignak.satellite.Satellite
Receiver class. Referenced as “app” in most Interface
Add an object to the receiver one Handles brok and externalcommand
Parameters: | elt (object) – object to add |
---|---|
Returns: | None |
Stop the Receiver Wait for children to stop and call super(Receiver, self).do_stop()
Returns: | None |
---|
Get scheduler linked to the given host_name
Parameters: | hname (str) – host_name we want the scheduler from |
---|---|
Returns: | scheduler with id corresponding to the mapping table |
Return type: | dict |
Get state of modules and create a scheme for stats data of daemon This may be overridden in subclasses
Returns: | A dict with the following structure |
---|
{ 'metrics': ['%s.%s.external-commands.queue %d %d'],
'version': __version__,
'name': self.name,
'direct_routing': self.direct_routing,
'type': _type,
'passive': self.passive,
'modules':
{'internal': {'name': "MYMODULE1", 'state': 'ok'},
{'external': {'name': "MYMODULE2", 'state': 'stopped'},
]
}
Return type: | dict |
---|
Send brok to modules. Modules have to implement their own manage_brok function. They usually do if they inherits from basemodule REF: doc/receiver-modules.png (4-5)
Parameters: | brok (alignak.brok.Brok) – brok to manage |
---|---|
Returns: | None |
Send a HTTP request to the schedulers (POST /run_external_commands) with external command list if the receiver is in direct routing. If not in direct_routing just clear the unprocessed_external_command list and return
Returns: | None |
---|
This module provide Alignak which is the main scheduling daemon class
Bases: alignak.satellite.BaseSatellite
Scheduler class. Referenced as “app” in most Interface
Compensate a system time change of difference for all hosts/services/checks/notifs
Parameters: | difference (int) – difference in seconds |
---|---|
Returns: | None |
Main function for Scheduler, launch after the init:
* Init daemon
* Load module manager
* Launch main loop
* Catch any Exception that occurs
Returns: | None |
---|
Manage signals caught by the daemon signal.SIGUSR1 : dump_memory signal.SIGUSR2 : dump_object (nothing) signal.SIGTERM, signal.SIGINT : terminate process
Parameters: |
|
---|---|
Returns: | None |
TODO: Refactor with Daemon one
Daemon package init, nothing necessary to do here