alignak.daemons package

Submodules

alignak.daemons.arbiterdaemon module

This module provie Arbiter class used to run a arbiter daemon

class alignak.daemons.arbiterdaemon.Arbiter(config_files, is_daemon, do_replace, verify_only, debug, debug_file, profile=None, analyse=None, migrate=None, arb_name='')[source]

Bases: alignak.daemon.Daemon

Arbiter class. Referenced as “app” in most Interface

add(b)[source]

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
check_and_log_tp_activation_change()[source]

Raise log for timeperiod change (useful for debug)

Returns:None
do_loop_turn()[source]

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
get_daemons(daemon_type)[source]

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_satellites()[source]

Get external commands from all other satellites

Returns:None

Get initial broks from my internal satellitelinks (satellite status)

Returns:None
get_retention_data()[source]

Get data for retention

Returns:broks and external commands in a dict
Return type:dict
get_stats_struct()[source]

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
go_migrate()[source]

Migrate configuration

Returns:None

TODO: Remove it

launch_analyse()[source]

Print the number of objects we have for each type.

Returns:None
load_config_file()[source]

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
load_external_command(ecm)[source]

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_modules_configuration_objects(raw_objects)[source]

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()[source]

Main arbiter function:

* Set logger
* Log Alignak headers
* Init daemon
* Launch modules
* Load retention
* Do mainloop
Returns:None
push_broks_to_broker()[source]

Send all broks from arbiter internal list to broker

Returns:None
push_external_commands_to_schedulers()[source]

Send external commands to schedulers

Returns:None
restore_retention_data(data)[source]

Restore data from retention (broks, and external commands)

Parameters:data (dict) – data to restore
Returns:None
run()[source]

Run Arbiter daemon

* Dispatch conf
* Get initial brok from links
* Load external command manager
* Principal loop (send broks, external command, re dispatch etc.)

:return:None

setup_new_conf()[source]

Setup a new conf received from a Master arbiter.

Returns:None
wait_for_master_death()[source]

Wait for a master timeout and take the lead if necessary

Returns:None

alignak.daemons.brokerdaemon module

This module provide Broker class used to run a broker daemon

class alignak.daemons.brokerdaemon.Broker(config_file, is_daemon, do_replace, debug, debug_file, profile='')[source]

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)[source]

Add elt to this broker

Original comment : Schedulers have some queues. We can simplify the call by adding
elements into the proper queue just by looking at their type Brok -> self.broks TODO: better tag ID? External commands -> self.external_commands
Parameters:elt (object) – object to add
Returns:None
add_broks_to_queue(broks)[source]

Add broks to global queue

Parameters:broks (object) – some items
Returns:None
clean_previous_run()[source]

Clean all (when we received new conf)

Returns:None
do_loop_turn()[source]

Loop use to: * check if modules are alive, if not restart them * add broks to queue of each modules

Returns:None
do_pynag_con_init(s_id, i_type='scheduler')[source]

Initialize or re-initialize connection with scheduler or arbiter if type == arbiter

Parameters:
  • s_id (int) – s_id
  • i_type (str) – type of item
Returns:

None

do_stop()[source]

Stop all children of this process

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(i_type='scheduler')[source]

Get new broks from daemon defined in type parameter

Parameters:i_type (str) – type of object
Returns:None
get_retention_data()[source]

Get all broks

Returns:broks container
Return type:object
get_stats_struct()[source]

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
interger_arbiter_broks()[source]

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
interger_internal_broks()[source]

Get all broks from self.broks_internal_raised and we put them in self.broks

Returns:None
is_connection_try_too_close(elt)[source]

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
main()[source]

Main function, will loop forever

Returns:None
manage_brok(brok)[source]

Get a brok. We put brok data to the modules

Parameters:brok (object) – object with data
Returns:None
properties = {'modules_dir': <alignak.property.PathProp object at 0x7fd17aa3ccd0>, 'server_cert': <alignak.property.StringProp object at 0x7fd17aa674d0>, 'workdir': <alignak.property.PathProp object at 0x7fd17aa3cc90>, 'ca_cert': <alignak.property.StringProp object at 0x7fd17aa67490>, 'hard_ssl_name_check': <alignak.property.BoolProp object at 0x7fd17aa67590>, 'host': <alignak.property.StringProp object at 0x7fd17aa3ce90>, 'local_log': <alignak.property.PathProp object at 0x7fd17a5ff4d0>, 'spare': <alignak.property.BoolProp object at 0x7fd17aa67650>, 'user': <alignak.property.StringProp object at 0x7fd17aa3cfd0>, 'use_ssl': <alignak.property.BoolProp object at 0x7fd17aa4a190>, 'log_level': <alignak.property.LogLevelProp object at 0x7fd17aa67550>, 'use_local_log': <alignak.property.BoolProp object at 0x7fd17aa67510>, 'port': <alignak.property.IntegerProp object at 0x7fd17a5ff490>, 'idontcareaboutsecurity': <alignak.property.BoolProp object at 0x7fd17aa675d0>, 'server_key': <alignak.property.StringProp object at 0x7fd17aa4a250>, 'group': <alignak.property.StringProp object at 0x7fd17aa4a050>, 'max_queue_size': <alignak.property.IntegerProp object at 0x7fd17aa67690>, 'daemon_enabled': <alignak.property.BoolProp object at 0x7fd17aa67610>, 'pidfile': <alignak.property.PathProp object at 0x7fd17a5ff450>, 'daemon_thread_pool_size': <alignak.property.IntegerProp object at 0x7fd17aa676d0>}
pynag_con_init(_id, i_type='scheduler')[source]

Wrapper function for the real function do_ just for timing the connection

Parameters:
  • _id (int) – id
  • i_type (str) – type of item
Returns:

do_pynag_con_init return always True, so we return always True

Return type:

bool

restore_retention_data(data)[source]

Add data to broks container

Parameters:data (list) – broks to add
Returns:None
setup_new_conf()[source]

Parse new configuration and initialize all required

Returns:None

alignak.daemons.pollerdaemon module

This modules provides class for the Poller daemon

class alignak.daemons.pollerdaemon.Poller(config_file, is_daemon, do_replace, debug, debug_file, profile)[source]

Bases: alignak.satellite.Satellite

Poller class. Referenced as “app” in most Interface

do_actions = False
do_checks = True
my_type = 'poller'
properties = {'modules_dir': <alignak.property.PathProp object at 0x7fd17aa3ccd0>, 'server_cert': <alignak.property.StringProp object at 0x7fd17aa674d0>, 'workdir': <alignak.property.PathProp object at 0x7fd17aa3cc90>, 'ca_cert': <alignak.property.StringProp object at 0x7fd17aa67490>, 'hard_ssl_name_check': <alignak.property.BoolProp object at 0x7fd17aa67590>, 'host': <alignak.property.StringProp object at 0x7fd17aa3ce90>, 'local_log': <alignak.property.PathProp object at 0x7fd17a60add0>, 'spare': <alignak.property.BoolProp object at 0x7fd17aa67650>, 'user': <alignak.property.StringProp object at 0x7fd17aa3cfd0>, 'use_ssl': <alignak.property.BoolProp object at 0x7fd17aa4a190>, 'log_level': <alignak.property.LogLevelProp object at 0x7fd17aa67550>, 'use_local_log': <alignak.property.BoolProp object at 0x7fd17aa67510>, 'port': <alignak.property.IntegerProp object at 0x7fd17a60ad90>, 'idontcareaboutsecurity': <alignak.property.BoolProp object at 0x7fd17aa675d0>, 'server_key': <alignak.property.StringProp object at 0x7fd17aa4a250>, 'group': <alignak.property.StringProp object at 0x7fd17aa4a050>, 'max_queue_size': <alignak.property.IntegerProp object at 0x7fd17aa67690>, 'daemon_enabled': <alignak.property.BoolProp object at 0x7fd17aa67610>, 'pidfile': <alignak.property.PathProp object at 0x7fd17a60ad50>, 'daemon_thread_pool_size': <alignak.property.IntegerProp object at 0x7fd17aa676d0>}

alignak.daemons.reactionnerdaemon module

This module provide Reactionner class used to launch notifications or event handlers

class alignak.daemons.reactionnerdaemon.Reactionner(config_file, is_daemon, do_replace, debug, debug_file, profile='')[source]

Bases: alignak.satellite.Satellite

This class is an application that launches actions for the schedulers Actions can be:

Notifications Event handlers
When running the Reactionner will :
Respond to pings from Arbiter Listen for new configurations from Arbiter

The configuration consists of a list of Schedulers for which the Reactionner will launch actions for.

do_actions = True
do_checks = False
my_type = 'reactionner'
properties = {'modules_dir': <alignak.property.PathProp object at 0x7fd17aa3ccd0>, 'server_cert': <alignak.property.StringProp object at 0x7fd17aa674d0>, 'workdir': <alignak.property.PathProp object at 0x7fd17aa3cc90>, 'ca_cert': <alignak.property.StringProp object at 0x7fd17aa67490>, 'hard_ssl_name_check': <alignak.property.BoolProp object at 0x7fd17aa67590>, 'host': <alignak.property.StringProp object at 0x7fd17aa3ce90>, 'local_log': <alignak.property.PathProp object at 0x7fd17a62a150>, 'spare': <alignak.property.BoolProp object at 0x7fd17aa67650>, 'user': <alignak.property.StringProp object at 0x7fd17aa3cfd0>, 'use_ssl': <alignak.property.BoolProp object at 0x7fd17aa4a190>, 'log_level': <alignak.property.LogLevelProp object at 0x7fd17aa67550>, 'use_local_log': <alignak.property.BoolProp object at 0x7fd17aa67510>, 'port': <alignak.property.IntegerProp object at 0x7fd17a62a110>, 'idontcareaboutsecurity': <alignak.property.BoolProp object at 0x7fd17aa675d0>, 'server_key': <alignak.property.StringProp object at 0x7fd17aa4a250>, 'group': <alignak.property.StringProp object at 0x7fd17aa4a050>, 'max_queue_size': <alignak.property.IntegerProp object at 0x7fd17aa67690>, 'daemon_enabled': <alignak.property.BoolProp object at 0x7fd17aa67610>, 'pidfile': <alignak.property.PathProp object at 0x7fd17a62a0d0>, 'daemon_thread_pool_size': <alignak.property.IntegerProp object at 0x7fd17aa676d0>}

alignak.daemons.receiverdaemon module

This module provide Receiver class used to run a receiver daemon

class alignak.daemons.receiverdaemon.Receiver(config_file, is_daemon, do_replace, debug, debug_file)[source]

Bases: alignak.satellite.Satellite

Receiver class. Referenced as “app” in most Interface

add(elt)[source]

Add an object to the receiver one Handles brok and externalcommand

Parameters:elt (object) – object to add
Returns:None
do_loop_turn()[source]

Receiver daemon main loop

Returns:None
do_stop()[source]

Stop the Receiver Wait for children to stop and call super(Receiver, self).do_stop()

Returns:None
get_sched_from_hname(hname)[source]

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_stats_struct()[source]

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
main()[source]

Main receiver function Init daemon and loop forever

Returns:None
manage_brok(brok)[source]

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
my_type = 'receiver'
properties = {'modules_dir': <alignak.property.PathProp object at 0x7fd17aa3ccd0>, 'server_cert': <alignak.property.StringProp object at 0x7fd17aa674d0>, 'workdir': <alignak.property.PathProp object at 0x7fd17aa3cc90>, 'ca_cert': <alignak.property.StringProp object at 0x7fd17aa67490>, 'hard_ssl_name_check': <alignak.property.BoolProp object at 0x7fd17aa67590>, 'host': <alignak.property.StringProp object at 0x7fd17aa3ce90>, 'local_log': <alignak.property.PathProp object at 0x7fd17a62a050>, 'spare': <alignak.property.BoolProp object at 0x7fd17aa67650>, 'user': <alignak.property.StringProp object at 0x7fd17aa3cfd0>, 'use_ssl': <alignak.property.BoolProp object at 0x7fd17aa4a190>, 'log_level': <alignak.property.LogLevelProp object at 0x7fd17aa67550>, 'use_local_log': <alignak.property.BoolProp object at 0x7fd17aa67510>, 'port': <alignak.property.IntegerProp object at 0x7fd17a60afd0>, 'idontcareaboutsecurity': <alignak.property.BoolProp object at 0x7fd17aa675d0>, 'server_key': <alignak.property.StringProp object at 0x7fd17aa4a250>, 'group': <alignak.property.StringProp object at 0x7fd17aa4a050>, 'max_queue_size': <alignak.property.IntegerProp object at 0x7fd17aa67690>, 'daemon_enabled': <alignak.property.BoolProp object at 0x7fd17aa67610>, 'pidfile': <alignak.property.PathProp object at 0x7fd17a60af90>, 'daemon_thread_pool_size': <alignak.property.IntegerProp object at 0x7fd17aa676d0>}
push_external_commands_to_schedulers()[source]

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
push_host_names(sched_id, hnames)[source]

Link hostnames to scheduler id. Called by alignak.satellite.IForArbiter.push_host_names

Parameters:
  • sched_id (int) – scheduler id to link to
  • hnames (list) – host names list
Returns:

None

setup_new_conf()[source]

Receiver custom setup_new_conf method Implements specific setup for receiver

Returns:None

alignak.daemons.schedulerdaemon module

This module provide Alignak which is the main scheduling daemon class

class alignak.daemons.schedulerdaemon.Alignak(config_file, is_daemon, do_replace, debug, debug_file, profile='')[source]

Bases: alignak.satellite.BaseSatellite

Scheduler class. Referenced as “app” in most Interface

compensate_system_time_change(difference)[source]

Compensate a system time change of difference for all hosts/services/checks/notifs

Parameters:difference (int) – difference in seconds
Returns:None
do_loop_turn()[source]

Scheduler loop turn Basically wait initial conf and run

Returns:None
main()[source]

Main function for Scheduler, launch after the init:

* Init daemon
* Load module manager
* Launch main loop
* Catch any Exception that occurs
Returns:None
manage_signal(sig, frame)[source]

Manage signals caught by the daemon signal.SIGUSR1 : dump_memory signal.SIGUSR2 : dump_object (nothing) signal.SIGTERM, signal.SIGINT : terminate process

Parameters:
  • sig (str) – signal caught by daemon
  • frame – current stack frame
Returns:

None

TODO: Refactor with Daemon one

properties = {'modules_dir': <alignak.property.PathProp object at 0x7fd17aa3ccd0>, 'server_cert': <alignak.property.StringProp object at 0x7fd17aa674d0>, 'workdir': <alignak.property.PathProp object at 0x7fd17aa3cc90>, 'ca_cert': <alignak.property.StringProp object at 0x7fd17aa67490>, 'hard_ssl_name_check': <alignak.property.BoolProp object at 0x7fd17aa67590>, 'host': <alignak.property.StringProp object at 0x7fd17aa3ce90>, 'local_log': <alignak.property.PathProp object at 0x7fd17a60acd0>, 'spare': <alignak.property.BoolProp object at 0x7fd17aa67650>, 'user': <alignak.property.StringProp object at 0x7fd17aa3cfd0>, 'use_ssl': <alignak.property.BoolProp object at 0x7fd17aa4a190>, 'log_level': <alignak.property.LogLevelProp object at 0x7fd17aa67550>, 'use_local_log': <alignak.property.BoolProp object at 0x7fd17aa67510>, 'port': <alignak.property.IntegerProp object at 0x7fd17a60ac90>, 'idontcareaboutsecurity': <alignak.property.BoolProp object at 0x7fd17aa675d0>, 'server_key': <alignak.property.StringProp object at 0x7fd17aa4a250>, 'group': <alignak.property.StringProp object at 0x7fd17aa4a050>, 'max_queue_size': <alignak.property.IntegerProp object at 0x7fd17aa67690>, 'daemon_enabled': <alignak.property.BoolProp object at 0x7fd17aa67610>, 'pidfile': <alignak.property.PathProp object at 0x7fd17a60ac50>, 'daemon_thread_pool_size': <alignak.property.IntegerProp object at 0x7fd17aa676d0>}
setup_new_conf()[source]

Setup new conf received for scheduler

Returns:None
what_i_managed()[source]

Get my managed dict (instance id and push_flavor)

Returns:dict containing instance_id key and push flavor value
Return type:dict

Module contents

Daemon package init, nothing necessary to do here