alignak package

Subpackages

Submodules

alignak.acknowledge module

This module provides Acknowledge class that implements acknowledgment for notification. Basically used for parsing.

class alignak.acknowledge.Acknowledge(ref, sticky, notify, persistent, author, comment, end_time=0)[source]

Allows you to acknowledge the current problem for the specified service. By acknowledging the current problem, future notifications (for the same servicestate) are disabled.

properties = {'comment': None, 'author': None, 'sticky': None, 'end_time': None, '_id': None, 'notify': None}

alignak.action module

This module provides a system-independent Action class. Action class is used for handling check and notification execution (handle output, execute process, kill process..)

class alignak.action.Action[source]

Bases: alignak.action.ActionBase

Action class for *NIX systems

execute__(force_shell=False)[source]

Execute action in a subprocess

Parameters:force_shell (bool) – if True, force execution in a shell
Returns:None or str ‘toomanyopenfiles’

TODO: Clean this

kill__()[source]

Kill the action and close fds

Returns:None
properties = {'status': <alignak.property.StringProp object at 0x7f447ceb4d50>, 'check_time': <alignak.property.IntegerProp object at 0x7f447ceb4e50>, 'exit_status': <alignak.property.IntegerProp object at 0x7f447ceb4d90>, 'output': <alignak.property.StringProp object at 0x7f447ceb4dd0>, 'execution_time': <alignak.property.FloatProp object at 0x7f447ceb4e90>, 'worker': <alignak.property.StringProp object at 0x7f447ce44090>, 't_to_go': <alignak.property.FloatProp object at 0x7f447ceb4e10>, 'is_a': <alignak.property.StringProp object at 0x7f447ceb4c50>, 'reactionner_tag': <alignak.property.StringProp object at 0x7f447ceb4f50>, 'module_type': <alignak.property.StringProp object at 0x7f447ce44050>, 'u_time': <alignak.property.FloatProp object at 0x7f447ceb4ed0>, 'env': <alignak.property.DictProp object at 0x7f447ceb4f90>, 's_time': <alignak.property.FloatProp object at 0x7f447ceb4f10>, '_in_timeout': <alignak.property.BoolProp object at 0x7f447ceb4d10>, 'type': <alignak.property.StringProp object at 0x7f447ceb4cd0>}

alignak.autoslots module

The AutoSlots Class is a MetaClass: it manages how other classes are created (Classes, not instances of theses classes). Here it’s role is to create the __slots__ list of the class with all properties of Class.properties and Class.running_properties so we do not have to add manually all properties to the __slots__ list when we add a new entry

class alignak.autoslots.AutoSlots[source]

Bases: type

AutoSlots inherit from type, it’s compulsory for metaclass statement

alignak.basemodule module

This python module contains the class BaseModule that alignak modules will subclass

class alignak.basemodule.BaseModule(mod_conf)[source]

Bases: object

This is the base class for the Alignak modules. Modules can be used by the different Alignak daemons/services for different tasks. Example of task that a Alignak module can do:

  • load additional configuration objects.

  • recurrently save hosts/services status/perfdata

    information in different format.

  • ...

clear_queues(manager)[source]

Release the resources associated to the queues of this instance

Parameters:manager (None | object) – None on android, otherwise Manager() object
Returns:None
create_queues(manager=None)[source]

The manager is None on android, but a true Manager() elsewhere Create the shared queues that will be used by alignak daemon process and this module process. But clear queues if they were already set before recreating new one.

Parameters:manager (None | object) – None on android, otherwise Manager() object
Returns:None
do_loop_turn()[source]

For external modules only: implement in this method the body of you main loop

Returns:None
do_stop()[source]

Called just before the module will exit Put in this method all you need to cleanly release all open resources used by your module

Returns:None
get_name()[source]

Wrapper to access name attribute

Returns:module name
Return type:str
has(prop)[source]

The classic has: do we have a prop or not?

Parameters:prop (str) – property name
Returns:True if has a property, otherwise False
Return type:bool
init()[source]

Handle this module “post” init ; just before it’ll be started. Like just open necessaries file(s), database(s), or whatever the module will need.

Returns:None
manage_brok(brok)[source]

Request the module to manage the given brok. There a lot of different possible broks to manage.

Parameters:brok
Returns:
Return type:
manage_signal(sig, frame)[source]

Generic function to handle signals Set interrupted attribute to True and return

Parameters:
  • sig – signal sent
  • frame – frame before catching signal
Returns:

None

set_exit_handler(sigs=None)

Set the signal handler function (manage_signal) for sigs signals or signal.SIGINT and signal.SIGTERM if sigs is None

Parameters:sigs – signals to handle
Returns:None
set_loaded_into(daemon_name)[source]

Setter for loaded_into attribute Used to know what daemon has loaded this module

Parameters:daemon_name (str) – value to set
Returns:None
set_proctitle(name)[source]

Wrapper for setproctitle method

Parameters:name (str) – module name
Returns:None
set_signal_handler(sigs=None)[source]

Set the signal handler function (manage_signal) for sigs signals or signal.SIGINT and signal.SIGTERM if sigs is None

Parameters:sigs – signals to handle
Returns:None
start(http_daemon=None)[source]

Actually restart the process if the module is external Try first to stop the process and create a new Process instance with target start_module. Finally start process.

Parameters:http_daemon (None | object) – Not used here but can be used in other modules
Returns:None
start_module()[source]

Wrapper for _main function. Catch and raise any exception occurring in the main function

Returns:None
stop_process()[source]

Request the module process to stop and release it

Returns:None
want_brok(b)[source]

Generic function to check if the module need a specific brok In this case it is always True

Parameters:b (alignak.brok.Brok) – brok to check
Returns:True if the module wants the brok, False otherwise
Return type:bool
work()

module “main” method. Only used by external modules.

Returns:None

alignak.borg module

Borg module provides Borg class. Used only for MacroSolver

class alignak.borg.Borg[source]

Bases: object

Borg class define a simple __shared_state class attribute. __dict__ points to this value when calling __init__

TODO: Is this class really needed? Only subclassed by MacroSolver

alignak.brok module

Brok module provide Brok class which is basically event for Alignak. Brok are filled depending on their type (check_result, initial_state ...)

class alignak.brok.Brok(_type, data)[source]

A Brok is a piece of information exported by Alignak to the Broker. Broker can do whatever he wants with it.

id[source]

Getter for id, raise deprecation warning :return: self._id

my_type = 'brok'
prepare()[source]

Unpickle data from data attribute and add instance_id key if necessary

Returns:None
use_ujson()[source]

Check if we use ujson or cPickle

Returns:True if type in list allowed, otherwise False
Return type:bool

alignak.check module

This module provides Check classe which is a simple abstraction for monitoring checks

class alignak.check.Check(status, command, ref, t_to_go, dep_check=None, _id=None, timeout=10, poller_tag='None', reactionner_tag='None', env={}, module_type='fork', from_trigger=False, dependency_check=False)[source]

Bases: alignak.action.Action

Check class implements monitoring concepts of checks :(status, state, output) Check instance are used to store monitoring plugins data (exit status, output) and used by schedule to raise alert, reschedule check etc.

copy_shell()[source]

return a copy of the check but just what is important for execution So we remove the ref and all

Returns:a copy of check
Return type:object
get_id()[source]

Getter for id attribute

Returns:id
Return type:int
get_return_from(check)[source]

Update check data from action (notification for instance)

Parameters:check (alignak.action.Action) – action to get data from
Returns:None
is_dependent()[source]

Getter for dependency_check attribute

Returns:True if this check was created for dependent one, False otherwise
Return type:bool
is_launchable(timestamp)[source]

Check if the check can be launched

Parameters:timestamp (int) – time to compare with t_to_go attribute
Returns:True if t > self.t_to_go, False otherwise
Return type:bool
my_type = 'check'
properties = {'status': <alignak.property.StringProp object at 0x7f447ceb4d50>, 'check_type': <alignak.property.IntegerProp object at 0x7f447ce44210>, 'exit_status': <alignak.property.IntegerProp object at 0x7f447ceb4d90>, 'execution_time': <alignak.property.FloatProp object at 0x7f447ceb4e90>, 'dep_check': <alignak.property.ListProp object at 0x7f447ce44190>, 'worker': <alignak.property.StringProp object at 0x7f447ce44090>, 't_to_go': <alignak.property.FloatProp object at 0x7f447ceb4e10>, 'reactionner_tag': <alignak.property.StringProp object at 0x7f447ceb4f50>, 'module_type': <alignak.property.StringProp object at 0x7f447ce44050>, 's_time': <alignak.property.FloatProp object at 0x7f447ceb4f10>, '_in_timeout': <alignak.property.BoolProp object at 0x7f447ceb4d10>, 'check_time': <alignak.property.IntegerProp object at 0x7f447ceb4e50>, 'long_output': <alignak.property.StringProp object at 0x7f447ce440d0>, 'ref': <alignak.property.IntegerProp object at 0x7f447ce44110>, 'depend_on': <alignak.property.ListProp object at 0x7f447ce44150>, 'is_a': <alignak.property.StringProp object at 0x7f447ceb4790>, 'poller_tag': <alignak.property.StringProp object at 0x7f447ce44250>, 'state': <alignak.property.IntegerProp object at 0x7f447ceb47d0>, 'internal': <alignak.property.BoolProp object at 0x7f447ce44290>, 'u_time': <alignak.property.FloatProp object at 0x7f447ceb4ed0>, 'env': <alignak.property.DictProp object at 0x7f447ceb4f90>, 'output': <alignak.property.StringProp object at 0x7f447ceb4dd0>, 'type': <alignak.property.StringProp object at 0x7f447ceb4cd0>, 'perf_data': <alignak.property.StringProp object at 0x7f447ce441d0>, 'from_trigger': <alignak.property.BoolProp object at 0x7f447ce442d0>}
set_type_active()[source]

Set check_type attribute to 0

Returns:None
set_type_passive()[source]

Set check_type attribute to 1

Returns:None

alignak.commandcall module

This modules provide CommandCall class which is a abstraction for dealing with command line (resolve macro, parse commands etc)

class alignak.commandcall.CommandCall(commands, call, poller_tag='None', reactionner_tag='None', enable_environment_macros=0)[source]

Bases: alignak.commandcall.DummyCommandCall

This class is use when a service, contact or host define a command with args.

args
call
command
enable_environment_macros
get_command_and_args()[source]

We want to get the command and the args with ! splitting. but don’t forget to protect against the ! to do not split them

Returns:None
get_name()[source]

Getter for call attribute

Returns:call attribute
Return type:str
is_valid()[source]

Getter for valid attribute

Returns:True if object is valid, False otherwise
Return type:bool
module_type
my_type = 'CommandCall'
poller_tag
properties = {'poller_tag': <alignak.property.StringProp object at 0x7f447d1007d0>, 'reactionner_tag': <alignak.property.StringProp object at 0x7f447d100810>, 'valid': <alignak.property.BoolProp object at 0x7f447d100890>, 'call': <alignak.property.StringProp object at 0x7f447d100710>, 'enable_environment_macros': <alignak.property.BoolProp object at 0x7f447d100990>, 'timeout': <alignak.property.IntegerProp object at 0x7f447d100910>, 'late_relink_done': <alignak.property.BoolProp object at 0x7f447d100950>, 'command': <alignak.property.StringProp object at 0x7f447d100790>, 'args': <alignak.property.StringProp object at 0x7f447d1008d0>, 'module_type': <alignak.property.StringProp object at 0x7f447d100850>}
reactionner_tag
timeout
valid
class alignak.commandcall.DummyCommandCall[source]

Bases: object

Ok, slots are fun: you cannot set the __autoslots__
on the same class you use, fun isn’t it? So we define* a dummy useless class to get such :)

TODO: Remove this class and use __slots__ properly

alignak.comment module

This module provide Comment class, used to attach comments to hosts / services

class alignak.comment.Comment(ref, persistent, author, comment, comment_type, entry_type, source, expires, expire_time)[source]

Comment class implements comments for monitoring purpose. It contains data like author, type, expire_time, persistent etc..

id[source]

Getter for id, raise deprecation warning

Returns:self._id
properties = {'comment': None, 'source': None, 'entry_time': None, 'comment_type': None, 'author': None, 'expire_time': None, 'entry_type': None, 'can_be_deleted': None, 'expires': None, 'persistent': None}

alignak.complexexpression module

This module provides ComplexExpressionNode and ComplexExpressionFactory used for parsing expression (business rules)

class alignak.complexexpression.ComplexExpressionFactory(ctx='hostgroups', grps=None, all_elements=None)[source]

Bases: object

ComplexExpressionFactory provides complex expression parsing functions

eval_cor_pattern(pattern)[source]

Parse and build recursively a tree of ComplexExpressionNode from pattern

Parameters:pattern (str) – pattern to parse
Returns:root node of parsed tree
Type:alignak.complexexpression.ComplexExpressionNode
find_object(pattern)[source]

Get a list of host corresponding to the pattern regarding the context

Parameters:pattern (str) – pattern to find
Returns:Host list matching pattern (hostgroup name, template, all)
Return type:list[alignak.objects.host.Host]
class alignak.complexexpression.ComplexExpressionNode[source]

Bases: object

ComplexExpressionNode is a node class for complex_expression(s)

is_valid()[source]

Check if all leaves are correct (no error)

Returns:True if correct, else False
Return type:bool

TODO: Fix this function and use it. DependencyNode should be ComplexExpressionNode Should return true on a leaf

resolve_elements()[source]

Get element of this node recursively Compute rules with OR or AND rule then NOT rules.

Returns:set of element
Return type:set

alignak.contactdowntime module

This module provides ContactDowntime class which implement downtime for contact

class alignak.contactdowntime.ContactDowntime(ref, start_time, end_time, author, comment)[source]

ContactDowntime class allows a contact to be in downtime. During this time the contact won’t get notifications

cancel()[source]

Wrapper to call raise_cancel_downtime_log_entry for ref (host/service) set can_be_deleted to True set is_in_effect to False

Returns:None
check_activation()[source]

Enter or exit downtime if necessary

Returns:None
enter()[source]

Wrapper to call raise_enter_downtime_log_entry for ref (host/service)

Returns:None
exit()[source]

Wrapper to call raise_exit_downtime_log_entry for ref (host/service) set can_be_deleted to True

Returns:None
in_scheduled_downtime()[source]

Getter for is_in_effect attribute

Returns:True if downtime is active, False otherwise
Return type:bool
properties = {'comment': None, 'author': None, 'start_time': None, 'is_in_effect': None, 'end_time': None, 'can_be_deleted': None}

alignak.daemon module

This module provides abstraction for creating daemon in Alignak

class alignak.daemon.Daemon(name, config_file, is_daemon, do_replace, debug, debug_file)[source]

Bases: object

Class providing daemon level call for Alignak TODO: Consider clean this code and use standard libs

add(elt)[source]
Abstract method for adding brok
It is overridden in subclasses of Daemon
Parameters:elt – element to add
Returns:None
change_to_user_group(insane=None)[source]

Change to user of the running program. If change failed we sys.exit(2)

Parameters:insane (bool) – boolean to allow running as root
Returns:None
change_to_workdir()[source]

Change working directory to working attribute

Returns:None
check_and_del_zombie_modules()[source]

Check alive instance and try to restart the dead ones

Returns:None
check_for_system_time_change()[source]

Check if our system time change. If so, change our

Returns:0 if the difference < 900, difference else
Return type:int

TODO: Duplicate of alignak.worker.Worker.check_for_system_time_change

check_parallel_run()[source]

Check (in pid file) if there isn’t already a daemon running. If yes and do_replace: kill it. Keep in self.fpid the File object to the pid file. Will be used by writepid.

Returns:None
check_shm()[source]

Check /dev/shm right permissions

Returns:None
close_fds(skip_close_fds)[source]

Close all the process file descriptors. Skip the descriptors present in the skip_close_fds list

Parameters:skip_close_fds (list) – list of fd to skip
Returns:None
compensate_system_time_change(difference)[source]

Default action for system time change. Actually a log is done

Returns:None
daemonize(skip_close_fds=None)[source]

Go in “daemon” mode: close unused fds, redirect stdout/err, chdir, umask, fork-setsid-fork-writepid Do the double fork to properly go daemon

Parameters:skip_close_fds (list) – list of fd to keep open
Returns:None
do_daemon_init_and_start(fake=False)[source]

Main daemon function. Clean, allocates, initializes and starts all necessary resources to go in daemon mode.

Parameters:fake (bool) – use for test to do not launch runonly feature, like the stats reaper thread.
Returns:None
do_load_modules()[source]

Wrapper for calling load_and_init method of modules_manager attribute

Returns:None
do_loop_turn()[source]

Abstract method for deamon loop turn. It must be overridden by class inheriting from Daemon

Returns:None
do_mainloop()[source]

Main loop for alignak daemon (except scheduler)

Returns:None
do_stop()[source]
Execute the stop of this daemon:
  • Stop the http thread and join it
  • Close the http socket
  • Shutdown the manager
  • Stop and join all started “modules”
Returns:None
dump_memory()[source]

Try to dump memory Does not really work :/

Returns:None

TODO: Clean this

find_gid_from_name()[source]

Wrapper for getgrnam : get the uid of user attribute

Returns:Uid of user attribute
Return type:str | None
find_modules_path()[source]

Find the absolute path of the alignak module directory and returns it. If the directory do not exist, we must exit!

Returns:modules_dir path
Return type:str
find_uid_from_name()[source]

Wrapper for getpwnam : get the uid of user attribute

Returns:Uid of user attribute
Return type:str | None
get_header()[source]

Get the log file header

Returns:A string list containing project name, version, licence etc.
Return type:list
get_objects_from_from_queues()[source]

Get objects from “from” queues and add them.

Returns:True if we got some objects, False otherwise.
Return type:bool
get_retention_data()[source]

Basic function to get retention data, Maybe be overridden by subclasses to implement real get

Returns:A list of Alignak object (scheduling items)
Return type:list
get_socks_activity(socks, timeout)[source]

Global loop part : wait for socket to be ready

Parameters:
  • socks – a socket file descriptor list
  • timeout (int) – timeout to read from fd
Returns:

A list of socket file descriptor ready to read

Return type:

list

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': [],
  'version': __version__,
  'name': '',
  'modules':
              {'internal': {'name': "MYMODULE1", 'state': 'ok'},
              {'external': {'name': "MYMODULE2", 'state': 'stopped'},
             ]
}
Return type:dict
handle_requests(timeout, suppl_socks=None)[source]

Wait up to timeout to handle the requests. If suppl_socks is given it also looks for activity on that list of fd.

Parameters:
  • timeout (float) – timeout to wait for activity
  • suppl_socks (None | list) – list of fd to wait for activity

:return:Returns a 3-tuple: * If timeout: first arg is 0, second is [], third is possible system time change value * If not timeout (== some fd got activity):

  • first arg is elapsed time since wait,
  • second arg is sublist of suppl_socks that got activity.
  • third arg is possible system time change value, or 0 if no change
Return type:tuple
hook_point(hook_name)[source]

Used to call module function that may define a hook fonction for hook_name

Parameters:hook_name (str) – function name we may hook in module
Returns:None
http_daemon_thread()[source]

Main fonction of the http daemon thread will loop forever unless we stop the root daemon

Returns:None
load_config_file()[source]

Parse config file and ensure full path in variables

Returns:None
load_modules_manager()[source]

Instanciate Modulesmanager and load the SyncManager (multiprocessing)

Returns:None
look_for_early_exit()[source]

Stop the daemon if it is not enabled

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

parse_config_file()[source]

Parse self.config_file and get all properties in it. If some properties need a pythonization, we do it. Also put default value in the properties if some are missing in the config_file

Returns:None
print_header()[source]

Log headers generated in get_header()

Returns:None
static print_unrecoverable(trace)[source]

Log generic message when getting an unrecoverable error

Parameters:trace – stack trace of the Exception
Returns:None
properties = {'modules_dir': <alignak.property.PathProp object at 0x7f447d33e150>, 'server_cert': <alignak.property.StringProp object at 0x7f447d0db910>, 'workdir': <alignak.property.PathProp object at 0x7f447d33e110>, 'group': <alignak.property.StringProp object at 0x7f447d33e490>, 'ca_cert': <alignak.property.StringProp object at 0x7f447d0db8d0>, 'log_level': <alignak.property.LogLevelProp object at 0x7f447d0db990>, 'hard_ssl_name_check': <alignak.property.BoolProp object at 0x7f447d0db9d0>, 'host': <alignak.property.StringProp object at 0x7f447d33e310>, 'server_key': <alignak.property.StringProp object at 0x7f447d33e690>, 'spare': <alignak.property.BoolProp object at 0x7f447d0dba90>, 'user': <alignak.property.StringProp object at 0x7f447d33e450>, 'max_queue_size': <alignak.property.IntegerProp object at 0x7f447d0dbad0>, 'daemon_enabled': <alignak.property.BoolProp object at 0x7f447d0dba50>, 'use_ssl': <alignak.property.BoolProp object at 0x7f447d33e5d0>, 'use_local_log': <alignak.property.BoolProp object at 0x7f447d0db950>, 'idontcareaboutsecurity': <alignak.property.BoolProp object at 0x7f447d0dba10>, 'daemon_thread_pool_size': <alignak.property.IntegerProp object at 0x7f447d0dbb10>}
register_local_log()[source]

Open local log file for logging purpose

Returns:None
relative_paths_to_full(reference_path)[source]

Set a full path from a relative one with che config file as reference TODO: This should be done in pythonize method of Properties.

Parameters:reference_path (str) – reference path for reading full path
Returns:None
request_stop()[source]

Remove pid and stop daemon

Returns:None
restore_retention_data(data)[source]

Basic function to save retention data, Maybe be overridden by subclasses to implement real save

Returns:None
set_exit_handler()[source]

Set the signal handler to manage_signal (defined in this class) Only set handlers for signal.SIGTERM, signal.SIGINT, signal.SIGUSR1, signal.SIGUSR2

Returns:None
set_proctitle()[source]

Set the proctitle of the daemon

Returns:None
setup_communication_daemon()[source]

Setup HTTP server daemon to listen for incoming HTTP requests from other Alignak daemons

Returns:None

Remove the daemon’s pid file

Returns:None
wait_for_initial_conf(timeout=1.0)[source]

Wait conf from arbiter. Basically sleep 1.0 and check if new_conf is here

Parameters:timeout (int) – timeout to wait from socket read
Returns:None

TODO: Clean this

write_pid(pid=None)[source]

Write pid to pidfile

Parameters:pid (None | int) – pid of the process
Returns:None
exception alignak.daemon.InvalidPidFile[source]

Bases: exceptions.Exception

Exception raise when a pid file is invalid

alignak.daemon.get_all_groups()[source]

Wrapper for getgrall

Returns:all groups
Return type:list
alignak.daemon.get_cur_group()[source]

Wrapper for getgrgid

Returns:group name
Return type:str
alignak.daemon.get_cur_user()[source]

Wrapper for getpwuid

Returns:user name
Return type:str

alignak.daterange module

This module provide Daterange and Timerange classes used to create Timeperiod in Alignak

class alignak.daterange.AbstractDaterange[source]

Bases: object

AbstractDaterange class provides functions to deal with a range of dates It is subclassed for more granularity (weekday, month ...)

get_min_from_t(timestamp)[source]

Get next time from t where a timerange is valid (withing range)

Parameters:timestamp – base time to look for the next one
Returns:time where a timerange is valid
Return type:int
get_min_sec_from_morning()[source]

Get the first second from midnight where a timerange is effective

Returns:smallest amount of second from midnight of all timerange
Return type:int
get_min_sec_out_from_morning()[source]

Get the first second (from midnight) where we are out of a timerange

Returns:smallest seconds from midnight of all timerange where it is not effective
Return type:int
classmethod get_month_by_id(month_id)[source]

Get month name from month id

Parameters:month_id (int) – month id
Returns:month name
Return type:str
>>> Daterange.get_month_by_id(7)
'july'
classmethod get_month_id(month)[source]

Get month id from month name

Parameters:month (str) – month name
Returns:month id
Return type:int
>>> Daterange.get_month_id("july")
7
get_next_future_timerange_invalid(timestamp)[source]

Get next invalid time for timeranges

Parameters:timestamp (int) – time to check
Returns:next time when a timerange is not valid
Return type:None | int

TODO: Looks like this function is buggy, start time should not be included in returned values

get_next_future_timerange_valid(timestamp)[source]

Get the next valid timerange (next timerange start in timeranges attribute)

Parameters:timestamp (int) – base time
Returns:next time when a timerange is valid
Return type:None | int
get_next_invalid_day(timestamp)[source]

Get next day where timerange is not active

Parameters:timestamp (int) – time we compute from
Returns:timestamp of the next invalid day (midnight) in LOCAL time.
Return type:int | None
get_next_invalid_time_from_t(timestamp)[source]

Get next invalid time for time range

Parameters:timestamp (int) – time we compute from
Returns:timestamp of the next invalid time (LOCAL TIME)
Return type:int
get_next_valid_day(timestamp)[source]

Get next valid day for timerange

Parameters:timestamp (int) – time we compute from
Returns:timestamp of the next valid day (midnight) in LOCAL time.
Return type:int | None
get_next_valid_time_from_t(timestamp)[source]

Get next valid time for time range

Parameters:timestamp (int) – time we compute from
Returns:timestamp of the next valid time (LOCAL TIME)
Return type:int | None
get_start_and_end_time(ref=None)[source]

Generic function to get start time and end time

Parameters:ref (int) – time in seconds
Returns:None
classmethod get_weekday_by_id(weekday_id)[source]

Get weekday name from weekday id

Parameters:weekday_id (int) – weekday id
Returns:weekday name
Return type:int
>>> Daterange.get_weekday_by_id(5)
'saturday'
classmethod get_weekday_id(weekday)[source]

Get weekday id from weekday name

Parameters:weekday (str) – weekday name
Returns:weekday id
Return type:int
>>> Daterange.get_weekday_id("monday")
0
is_correct()[source]

Check if each timerange of this datarange is correct

Returns:True if timerange are correct, False otherwise
Return type:bool
is_time_day_invalid(timestamp)[source]

Check if t is out of start time and end time of the DateRange

Parameters:timestamp (int) – time to check
Returns:False if t in range, True otherwise
Return type:bool

TODO: Remove this function. Duplication

is_time_day_valid(timestamp)[source]

Check if t is within start time and end time of the DateRange

Parameters:timestamp (int) – time to check
Returns:True if t in range, False otherwise
Return type:bool
is_time_valid(timestamp)[source]

Check if time is valid for one of the timerange.

Parameters:timestamp (int) – time to check
Returns:True if one of the timerange is valid for t, False otherwise
Return type:bool
class alignak.daterange.CalendarDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: alignak.daterange.Daterange

CalendarDaterange is for calendar entry (YYYY-MM-DD - YYYY-MM-DD)

get_start_and_end_time(ref=None)[source]

Specific function to get start time and end time for CalendarDaterange

Parameters:ref (int) – time in seconds
Returns:tuple with start and end time
Return type:tuple
class alignak.daterange.Daterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: alignak.daterange.AbstractDaterange

Daterange subclasses AbstractDaterange and instantiates Timerange objects

months = {'march': 3, 'august': 8, 'september': 9, 'december': 12, 'june': 6, 'july': 7, 'november': 11, 'february': 2, 'october': 10, 'may': 5, 'january': 1, 'april': 4}
rev_months = {1: 'january', 2: 'february', 3: 'march', 4: 'april', 5: 'may', 6: 'june', 7: 'july', 8: 'august', 9: 'september', 10: 'october', 11: 'november', 12: 'december'}
rev_weekdays = {0: 'monday', 1: 'tuesday', 2: 'wednesday', 3: 'thursday', 4: 'friday', 5: 'saturday', 6: 'sunday'}
weekdays = {'monday': 0, 'tuesday': 1, 'friday': 4, 'wednesday': 2, 'thursday': 3, 'sunday': 6, 'saturday': 5}
class alignak.daterange.MonthDateDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: alignak.daterange.Daterange

MonthDateDaterange is for month and day entry (month DD - month DD)

get_start_and_end_time(ref=None)[source]

Specific function to get start time and end time for MonthDateDaterange

Parameters:ref (int) – time in seconds
Returns:tuple with start and end time
Return type:tuple
class alignak.daterange.MonthDayDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: alignak.daterange.Daterange

MonthDayDaterange is for month week day entry (day DD - DD)

get_start_and_end_time(ref=None)[source]

Specific function to get start time and end time for MonthDayDaterange

Parameters:ref (int) – time in seconds
Returns:tuple with start and end time
Return type:tuple
class alignak.daterange.MonthWeekDayDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: alignak.daterange.Daterange

MonthWeekDayDaterange is for month week day entry (weekday DD month - weekday DD month)

get_start_and_end_time(ref=None)[source]

Specific function to get start time and end time for MonthWeekDayDaterange

Parameters:ref (int | None) – time in seconds
Returns:tuple with start and end time
Return type:tuple
is_correct()[source]

Check if the Daterange is correct : weekdays are valid

Returns:True if weekdays are valid, False otherwise
Return type:bool
class alignak.daterange.StandardDaterange(day, other)[source]

Bases: alignak.daterange.AbstractDaterange

StandardDaterange is for standard entry (weekday - weekday)

get_start_and_end_time(ref=None)[source]

Specific function to get start time and end time for StandardDaterange

Parameters:ref (int) – time in seconds
Returns:tuple with start and end time
Return type:tuple
is_correct()[source]

Check if the Daterange is correct : weekdays are valid

Returns:True if weekdays are valid, False otherwise
Return type:bool
class alignak.daterange.Timerange(entry)[source]

Bases: object

Timerange class provides parsing facilities for time range declaration

get_first_sec_out_from_morning()[source]

Get the first second (from midnight) where we are out of the timerange

Returns:seconds from midnight where timerange is not effective
Return type:int
get_sec_from_morning()[source]

Get Timerange start time in seconds (from midnight)

Returns:amount of seconds from midnight
Return type:int
is_correct()[source]

Getter for is_valid attribute

Returns:True if Timerange is valid, False otherwise
Return type:bool
is_time_valid(timestamp)[source]

Check if time is valid for this Timerange

Parameters:timestamp (int) – time to check
Returns:True if time is valid (in interval), False otherwise
Return type:bool
class alignak.daterange.WeekDayDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: alignak.daterange.Daterange

WeekDayDaterange is for month week day entry (weekday offset - weekday offset)

get_start_and_end_time(ref=None)[source]

Specific function to get start time and end time for WeekDayDaterange

Parameters:ref (int) – time in seconds
Returns:tuple with start and end time
Return type:tuple
alignak.daterange.find_day_by_offset(year, month, offset)[source]

Get the month day based on date and offset

Parameters:
  • year (int) – date year
  • month (int) – date month
  • offset (int) – offset in day to compute (usually negative)
Returns:

day number in the month

Return type:

int

>>> find_day_by_offset(2015, 7, -1)
31
alignak.daterange.find_day_by_weekday_offset(year, month, weekday, offset)[source]

Get the day number based on a date and offset

Parameters:
  • year (int) – date year
  • month (int) – date month
  • weekday (int) – date week day
  • offset (int) – offset (-1 is last, 1 is first etc)
Returns:

day number in the month

Return type:

int

>>> find_day_by_weekday_offset(2010, 7, 1, -1)
27

alignak.db module

This module provide DB class which is a generic class to access relational databases

class alignak.db.DB(table_prefix='')[source]

Bases: object

DB is a generic class for SQL Database

create_insert_query(table, data)[source]

Create a INSERT query in table with all data of data (a dict)

Parameters:
  • table (str) – table of DB
  • data (dict) – dictionary of data to insert
Returns:

the query

Return type:

str

create_update_query(table, data, where_data)[source]

Create a update query of table with data, and use where data for the WHERE clause

Parameters:
  • table (str) – table of the DB
  • data (dict) – dictionary of data to update
  • where_data (dict) – dictionary of data for search
Returns:

the query

Return type:

str

fetchall()[source]

Get all entry

Returns:all entries
Return type:tuple | None
fetchone()[source]

Just get an entry

Returns:an entry
Return type:tuple | None
stringify(val)[source]

Get a unicode from a value

Parameters:val (str) – value to ‘unicode’
Returns:value in unicode
Return type:str

alignak.db_mysql module

alignak.db_oracle module

alignak.db_sqlite module

This module provide DBSqlite class to access SQLite databases

class alignak.db_sqlite.DBSqlite(db_path, table_prefix='')[source]

Bases: alignak.db.DB

DBSqlite is a sqlite access database class

connect_database()[source]

Create the database connection

Returns:None
execute_query(query)[source]

Just run the query

Parameters:query (str) – the query
Returns:None

alignak.dependencynode module

This module provides DependencyNode and DependencyNodeFactory used for parsing expression (business rules)

class alignak.dependencynode.DependencyNode[source]

Bases: object

DependencyNode is a node class for business_rule expression(s)

get_complex_and_node_state()[source]

Get state , handle AND aggregation

* Get the worst state. 2 or max of sons (3 <=> UNKNOWN < CRITICAL <=> 2)
* Revert if it's a not node
Returns:0, 1 or 2
Return type:int
get_complex_node_state()[source]

Get state, handle AND, OR, X of aggregation.

Returns:0, 1 or 2
Return type:int
get_complex_or_node_state()[source]

Get state , handle OR aggregation

* Get the best state (min of sons)
* Revert if it's a not node
Returns:0, 1 or 2
Return type:int
get_complex_xof_node_state()[source]

Get state , handle X of aggregation

* Count the number of OK, WARNING, CRITICAL
* Try too apply, in this order, Critical, Warning, OK rule
* Return the code for first match (2, 1, 0)
* If no rule apply, return OK for simple X of and worst state for multiple X of
Returns:0, 1 or 2
Return type:int

TODO: Looks like the last if does the opposite of what the comment says

get_reverse_state(state)[source]

Do a symmetry around 1 of the state

* 0 -> 2
* 1 -> 1
* 2 -> 0
* else -> else
Parameters:state (int) – state to reverse
Returns:Integer from 0 to 2 (usually)
Return type:int
get_simple_node_state()[source]

Get node state, simplest case

* Handle not value (revert) for host and service node
* Return 2 instead of 1 for host
Returns:0, 1 or 2
Return type:int

TODO: Why return 1 when not 0 instead of 2 ?

get_state()[source]

Get node state by looking recursively over sons and applying operand

Returns:Node state
Return type:int
is_valid()[source]

Check if all leaves are correct (no error)

Returns:True if correct, otherwise False
Return type:bool
list_all_elements()[source]

Get all host/service in our node and below

Returns:list of hosts/services
Return type:list
switch_zeros_of_values()[source]
If we are a of: rule, we can get some 0 in of_values,
if so, change them with NB sons instead
Returns:None
class alignak.dependencynode.DependencyNodeFactory(bound_item)[source]

Bases: object

DependencyNodeFactory provides dependency node parsing functions

eval_complex_cor_pattern(pattern, hosts, services, running=False)[source]

Parse and build recursively a tree of DependencyNode from a complex pattern

Parameters:
Returns:

root node of parsed tree

Return type:

alignak.dependencynode.DependencyNode

eval_cor_pattern(pattern, hosts, services, running=False)[source]

Parse and build recursively a tree of DependencyNode from pattern

Parameters:
Returns:

root node of parsed tree

Return type:

alignak.dependencynode.DependencyNode

eval_simple_cor_pattern(pattern, hosts, services, running=False)[source]

Parse and build recursively a tree of DependencyNode from a simple pattern

Parameters:
Returns:

root node of parsed tree

Return type:

alignak.dependencynode.DependencyNode

eval_xof_pattern(node, pattern)[source]

Parse a X of pattern * Set is_of_mul attribute * Set of_values attribute

Parameters:
  • node – node to edit
  • pattern (str) – line to match
Returns:

end of the line (without X of :)

Return type:

str

expand_expression(pattern, hosts, services, running=False)[source]

Expand a host or service expression into a dependency node tree using (host|service)group membership, regex, or labels as item selector.

Parameters:
Returns:

root node of parsed tree

Return type:

alignak.dependencynode.DependencyNode

find_object(pattern, hosts, services)[source]

Find object from pattern

Parameters:
Returns:

tuple with Host or Service object and error

Return type:

tuple

get_host_filters(expr)[source]

Generates host filter list corresponding to the expression

* '*' => any
* 'g' => group filter
* 'r' => regex name filter
* 'l' => bp rule label filter
* 't' => tag  filter
* '' => none filter
* No flag match => host name filter
Parameters:expr (str) – expression to parse
Returns:filter list
Return type:list
get_srv_host_filters(expr)[source]

Generates service filter list corresponding to the expression

* '*' => any
* 'g' => hostgroup filter
* 'r' => host regex name filter
* 'l' => host bp rule label filter
* 't' => tag  filter
* '' => none filter
* No flag match => host name filter
Parameters:expr (str) – expression to parse
Returns:filter list
Return type:list
get_srv_service_filters(expr)[source]

Generates service filter list corresponding to the expression

* '*' => any
* 'g' => servicegroup filter
* 'r' => service regex name filter
* 'l' => service bp rule label filter
* 't' => tag  filter
* '' => none filter
* No flag match => service name filter
Parameters:expr (str) – expression to parse
Returns:filter list
Return type:list
host_flags = 'grlt'
service_flags = 'grl'

alignak.dispatcher module

This is the class of the dispatcher. Its role is to dispatch configurations to other elements like schedulers, reactionner, pollers, receivers and brokers. It is responsible for high availability part. If an element dies and the element type has a spare, it sends the config of the dead one to the spare

class alignak.dispatcher.Dispatcher(conf, arbiter)[source]

Dispatcher is in charge of sending configuration to other daemon. It has to handle spare, realms, poller tags etc.

check_alive()[source]

Check all daemons state (alive or not) and send conf if necessary

Returns:None
check_bad_dispatch()[source]

Check if we have a bad dispatch For example : a spare started but the master was still alive We need ask the spare to wait a new conf

Returns:None
check_dispatch()[source]

Check if all active items are still alive

Returns:None

TODO: finish need conf

dispatch()[source]

Dispatch configuration to other daemons REF: doc/alignak-conf-dispatching.png (3)

Returns:None
get_scheduler_ordered_list(realm)[source]

Get sorted scheduler list for a specific realm

Parameters:realm (object) – realm we want scheduler from
Returns:sorted scheduler list
Return type:list[alignak.objects.schedulerlink.SchedulerLink]

alignak.downtime module

This modules provides Downtime class, used to implements downtime monitoring concept. See detailed concepts below

class alignak.downtime.Downtime(ref, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

Schedules downtime for a specified service. If the “fixed” argument is set to one (1), downtime will start and end at the times specified by the “start” and “end” arguments. Otherwise, downtime will begin between the “start” and “end” times and last for “duration” seconds. The “start” and “end” arguments are specified in time_t format (seconds since the UNIX epoch). The specified service downtime can be triggered by another downtime entry if the “trigger_id” is set to the ID of another scheduled downtime entry. Set the “trigger_id” argument to zero (0) if the downtime for the specified service should not be triggered by another downtime entry.

add_automatic_comment()[source]

Add comment on ref for downtime

Returns:None
cancel()[source]

Remove ref in scheduled downtime and raise downtime log entry (cancel)

Returns:[], always
Return type:list

TODO: res is useless

del_automatic_comment()[source]

Remove automatic comment on ref previously created

Returns:None
enter()[source]

Set ref in scheduled downtime and raise downtime log entry (start)

Returns:[], always
Return type:list

TODO: res is useless

exit()[source]

Remove ref in scheduled downtime and raise downtime log entry (exit)

Returns:[], always | None
Return type:list

TODO: res is useless

fill_data_brok_from(data, brok_type)[source]

Fill data with info of item by looking at brok_type in props of properties or running_properties

Parameters:
  • data – data to fill
  • brok_type (str) – type of brok
Returns:

None

TODO: Duplicate from Notification.fill_data_brok_from

get_initial_status_brok()[source]

Get a initial status brok

Returns:brok with wanted data
Return type:alignak.brok.Brok

TODO: Duplicate from Notification.fill_data_brok_from

id[source]

Getter for id, raise deprecation warning

Returns:self._id
in_scheduled_downtime()[source]

Getter for is_in_effect attribute

Returns:True if downtime is in effect, False otherwise
Return type:bool
properties = {'comment': <alignak.property.StringProp object at 0x7f447cd2b510>, 'entry_time': <alignak.property.IntegerProp object at 0x7f447cd2b310>, 'start_time': <alignak.property.IntegerProp object at 0x7f447cd2b390>, 'is_in_effect': <alignak.property.BoolProp object at 0x7f447cd2b550>, 'has_been_triggered': <alignak.property.BoolProp object at 0x7f447cd2b590>, 'trigger_id': <alignak.property.IntegerProp object at 0x7f447cd2b410>, 'duration': <alignak.property.IntegerProp object at 0x7f447cd2b3d0>, 'author': <alignak.property.StringProp object at 0x7f447cd2b4d0>, 'can_be_deleted': <alignak.property.BoolProp object at 0x7f447cd2b5d0>, 'activate_me': <alignak.property.StringProp object at 0x7f447cd2b2d0>, 'real_end_time': <alignak.property.IntegerProp object at 0x7f447cd2b490>, 'end_time': <alignak.property.IntegerProp object at 0x7f447cd2b450>, 'fixed': <alignak.property.BoolProp object at 0x7f447cd2b350>}
trigger_me(other_downtime)[source]

Wrapper to activate_me.append function Used to add another downtime to activate

Parameters:other_downtime – other downtime to activate/cancel
Returns:None

alignak.eventhandler module

This module provides EventHandler class, used when hosts or services reach a bad state.

class alignak.eventhandler.EventHandler(command, _id=None, ref=None, timeout=10, env={}, module_type='fork', reactionner_tag='None', is_snapshot=False)[source]

Bases: alignak.action.Action

Notification class, inherits from action class. Used to execute action when a host or a service is in a bad state

check_time
command
copy_shell()[source]

Get a copy o this event handler with minimal values (default, id, is snapshot)

Returns:new event handler
Return type:alignak.eventhandler.EventHandler
env
execution_time
exit_status
get_id()[source]

Getter to id attribute

Returns:event handler id
Return type:int

TODO: Duplicate from Notification.get_id

get_outputs(out, max_plugins_output_length)[source]

Setter of output attribute

Parameters:
  • out – new output
  • max_plugins_output_length – not use
Returns:

None

get_return_from(e_handler)[source]

Setter of the following attributes:

* exit_status
* output
* long_output
* check_time
* execution_time
* perf_data
Parameters:e_handler (alignak.eventhandler.EventHandler) – event handler to get data from
Returns:None
is_a
is_launchable(timestamp)[source]

Check if this event handler can be launched base on time

Parameters:timestamp (int) – time to compare
Returns:True if t >= self.t_to_go, False otherwise
Return type:bool

TODO: Duplicate from Notification.is_launchable

is_snapshot
long_output
module_type
my_type = 'eventhandler'
output
perf_data
properties = {'status': <alignak.property.StringProp object at 0x7f447ceb4d50>, 'timeout': <alignak.property.IntegerProp object at 0x7f447ce53210>, 'exit_status': <alignak.property.IntegerProp object at 0x7f447ceb4d90>, 'execution_time': <alignak.property.FloatProp object at 0x7f447ceb4e90>, 'worker': <alignak.property.StringProp object at 0x7f447ce44090>, 't_to_go': <alignak.property.FloatProp object at 0x7f447ceb4e10>, 'is_snapshot': <alignak.property.BoolProp object at 0x7f447ce53290>, 'reactionner_tag': <alignak.property.StringProp object at 0x7f447ceb4f50>, 'module_type': <alignak.property.StringProp object at 0x7f447ce44050>, 's_time': <alignak.property.FloatProp object at 0x7f447ceb4f10>, '_in_timeout': <alignak.property.BoolProp object at 0x7f447ceb4d10>, 'sched_id': <alignak.property.IntegerProp object at 0x7f447ce531d0>, 'check_time': <alignak.property.IntegerProp object at 0x7f447ceb4e50>, 'is_a': <alignak.property.StringProp object at 0x7f447ce530d0>, 'long_output': <alignak.property.StringProp object at 0x7f447ce53150>, 'command': <alignak.property.StringProp object at 0x7f447ce53250>, 'u_time': <alignak.property.FloatProp object at 0x7f447ceb4ed0>, 'env': <alignak.property.DictProp object at 0x7f447ceb4f90>, 'output': <alignak.property.StringProp object at 0x7f447ceb4dd0>, 'type': <alignak.property.StringProp object at 0x7f447ceb4cd0>, 'perf_data': <alignak.property.StringProp object at 0x7f447ce53190>}
reactionner_tag
s_time
sched_id
status
t_to_go
timeout
type
u_time
worker

alignak.external_command module

This module provides ExternalCommand and ExternalCommandManager classes Used to process command sent by users

class alignak.external_command.ExternalCommand(cmd_line)[source]

ExternalCommand class is only an object with a cmd_line attribute. All parsing and execution is done in manager

my_type = 'externalcommand'
class alignak.external_command.ExternalCommandManager(conf, mode)[source]

ExternalCommandManager class managed all external command sent to Alignak It basically parses arguments and execute the right function

acknowledge_host_problem(host, sticky, notify, persistent, author, comment)[source]

Acknowledge a host problem Format of the line that triggers function call:

ACKNOWLEDGE_HOST_PROBLEM;<host_name>;<sticky>;<notify>;<persistent>;<author>;<comment>

Parameters:
  • host (alignak.objects.host.Host) – host to acknowledge the problem
  • sticky (integer) – acknowledge will be always present is host return in UP state
  • notify (integer) – if to 1, send a notification
  • persistent (integer) – if 1, keep this acknowledge when Alignak restart
  • author (str) – name of the author or the acknowledge
  • comment (str) – comment (description) of the acknowledge
Returns:

None

TODO: add a better ACK management

acknowledge_host_problem_expire(host, sticky, notify, persistent, end_time, author, comment)[source]

Acknowledge a host problem with expire time for this acknowledgement Format of the line that triggers function call:

ACKNOWLEDGE_HOST_PROBLEM;<host_name>;<sticky>;<notify>;<persistent>;<end_time>; <author>;<comment>

Parameters:
  • host (alignak.objects.host.Host) – host to acknowledge the problem
  • sticky (integer) – acknowledge will be always present is host return in UP state
  • notify (integer) – if to 1, send a notification
  • persistent (integer) – if 1, keep this acknowledge when Alignak restart
  • end_time (int) – end (timeout) of this acknowledge in seconds(timestamp) (0 to never end)
  • author (str) – name of the author or the acknowledge
  • comment (str) – comment (description) of the acknowledge
Returns:

None

TODO: add a better ACK management

acknowledge_svc_problem(service, sticky, notify, persistent, author, comment)[source]

Acknowledge a service problem Format of the line that triggers function call:

ACKNOWLEDGE_SVC_PROBLEM;<host_name>;<service_description>;<sticky>;<notify>;<persistent>; <author>;<comment>

Parameters:
  • service (alignak.objects.service.Service) – service to acknowledge the problem
  • sticky (integer) – acknowledge will be always present is host return in UP state
  • notify (integer) – if to 1, send a notification
  • persistent (integer) – if 1, keep this acknowledge when Alignak restart
  • author (str) – name of the author or the acknowledge
  • comment (str) – comment (description) of the acknowledge
Returns:

None

acknowledge_svc_problem_expire(service, sticky, notify, persistent, end_time, author, comment)[source]

Acknowledge a service problem with expire time for this acknowledgement Format of the line that triggers function call:

ACKNOWLEDGE_SVC_PROBLEM;<host_name>;<service_description>;<sticky>;<notify>;<persistent>; <end_time>;<author>;<comment>

Parameters:
  • service (alignak.objects.service.Service) – service to acknowledge the problem
  • sticky (integer) – acknowledge will be always present is host return in UP state
  • notify (integer) – if to 1, send a notification
  • persistent (integer) – if 1, keep this acknowledge when Alignak restart
  • end_time (int) – end (timeout) of this acknowledge in seconds(timestamp) (0 to never end)
  • author (str) – name of the author or the acknowledge
  • comment (str) – comment (description) of the acknowledge
Returns:

None

add_host_comment(host, persistent, author, comment)[source]

Add a host comment Format of the line that triggers function call:

ADD_HOST_COMMENT;<host_name>;<persistent>;<author>;<comment>

Parameters:
  • host (alignak.objects.host.Host) – host to add the comment
  • persistent (bool) – is comment persistent (for reboot) or not
  • author (str) – author name
  • comment (str) – text comment
Returns:

None

add_simple_host_dependency(son, father)[source]

Add a host dependency between son and father Format of the line that triggers function call:

ADD_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>

Parameters:
Returns:

None

add_simple_poller(realm_name, poller_name, address, port)[source]

Add a poller Format of the line that triggers function call:

ADD_SIMPLE_POLLER;realm_name;poller_name;address;port

Parameters:
  • realm_name (str) – realm for the new poller
  • poller_name (str) – new poller name
  • address (str) – new poller address
  • port (int) – new poller port
Returns:

None

add_svc_comment(service, persistent, author, comment)[source]

Add a service comment Format of the line that triggers function call:

ADD_SVC_COMMENT;<host_name>;<service_description>;<persistent>;<author>;<comment>

Parameters:
Returns:

None

change_contact_host_notification_timeperiod(contact, notification_timeperiod)[source]

Change contact host notification timeperiod value Format of the line that triggers function call:

CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>

Parameters:
Returns:

None

change_contact_modattr(contact, value)[source]

Change contact modified attribute value Format of the line that triggers function call:

CHANGE_CONTACT_MODATTR;<contact_name>;<value>

Parameters:
Returns:

None

change_contact_modhattr(contact, value)[source]

Change contact modified host attribute value Format of the line that triggers function call:

CHANGE_CONTACT_MODHATTR;<contact_name>;<value>

Parameters:

:type value:str :return: None

change_contact_modsattr(contact, value)[source]

Change contact modified service attribute value Format of the line that triggers function call:

CHANGE_CONTACT_MODSATTR;<contact_name>;<value>

Parameters:
Returns:

None

change_contact_svc_notification_timeperiod(contact, notification_timeperiod)[source]

Change contact service notification timeperiod value Format of the line that triggers function call:

CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>

Parameters:
Returns:

None

change_custom_contact_var(contact, varname, varvalue)[source]

Change custom contact variable Format of the line that triggers function call:

CHANGE_CUSTOM_CONTACT_VAR;<contact_name>;<varname>;<varvalue>

Parameters:
Returns:

None

change_custom_host_var(host, varname, varvalue)[source]

Change custom host variable Format of the line that triggers function call:

CHANGE_CUSTOM_HOST_VAR;<host_name>;<varname>;<varvalue>

Parameters:
Returns:

None

change_custom_svc_var(service, varname, varvalue)[source]

Change custom service variable Format of the line that triggers function call:

CHANGE_CUSTOM_SVC_VAR;<host_name>;<service_description>;<varname>;<varvalue>

Parameters:
Returns:

None

change_global_host_event_handler(event_handler_command)[source]

DOES NOTHING (should change global host event handler) Format of the line that triggers function call:

CHANGE_GLOBAL_HOST_EVENT_HANDLER;<event_handler_command>

Parameters:event_handler_command – new event handler
Returns:None

TODO: DICT_MODATTR[“MODATTR_EVENT_HANDLER_COMMAND”].value

change_global_svc_event_handler(event_handler_command)[source]

DOES NOTHING (should change global service event handler) Format of the line that triggers function call:

CHANGE_GLOBAL_SVC_EVENT_HANDLER;<event_handler_command>

Parameters:event_handler_command – new event handler
Returns:None

TODO: DICT_MODATTR[“MODATTR_EVENT_HANDLER_COMMAND”].value

change_host_check_command(host, check_command)[source]

Modify host check command Format of the line that triggers function call:

CHANGE_HOST_CHECK_COMMAND;<host_name>;<check_command>

Parameters:
Returns:

None

change_host_check_timeperiod(host, timeperiod)[source]

Modify host check timeperiod Format of the line that triggers function call:

CHANGE_HOST_CHECK_TIMEPERIOD;<host_name>;<timeperiod>

Parameters:
Returns:

None

change_host_event_handler(host, event_handler_command)[source]

Modify host event handler Format of the line that triggers function call:

CHANGE_HOST_EVENT_HANDLER;<host_name>;<event_handler_command>

Parameters:
Returns:

None

change_host_modattr(host, value)[source]

Change host modified attributes Format of the line that triggers function call:

CHANGE_HOST_MODATTR;<host_name>;<value>

Parameters:
Returns:

None

change_max_host_check_attempts(host, check_attempts)[source]

Modify max host check attempt Format of the line that triggers function call:

CHANGE_MAX_HOST_CHECK_ATTEMPTS;<host_name>;<check_attempts>

Parameters:
Returns:

None

change_max_svc_check_attempts(service, check_attempts)[source]

Modify max service check attempt Format of the line that triggers function call:

CHANGE_MAX_SVC_CHECK_ATTEMPTS;<host_name>;<service_description>;<check_attempts>

Parameters:
Returns:

None

change_normal_host_check_interval(host, check_interval)[source]

Modify host check interval Format of the line that triggers function call:

CHANGE_NORMAL_HOST_CHECK_INTERVAL;<host_name>;<check_interval>

Parameters:
Returns:

None

change_normal_svc_check_interval(service, check_interval)[source]

Modify service check interval Format of the line that triggers function call:

CHANGE_NORMAL_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>

Parameters:
Returns:

None

change_retry_host_check_interval(host, check_interval)[source]

Modify host retry interval Format of the line that triggers function call:

CHANGE_RETRY_HOST_CHECK_INTERVAL;<host_name>;<check_interval>

Parameters:
Returns:

None

change_retry_svc_check_interval(service, check_interval)[source]

Modify service retry interval Format of the line that triggers function call:

CHANGE_RETRY_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>

Parameters:
Returns:

None

change_svc_check_command(service, check_command)[source]

Modify service check command Format of the line that triggers function call:

CHANGE_SVC_CHECK_COMMAND;<host_name>;<service_description>;<check_command>

Parameters:
Returns:

None

change_svc_check_timeperiod(service, check_timeperiod)[source]

Modify service check timeperiod Format of the line that triggers function call:

CHANGE_SVC_CHECK_TIMEPERIOD;<host_name>;<service_description>;<check_timeperiod>

Parameters:
Returns:

None

change_svc_event_handler(service, event_handler_command)[source]

Modify service event handler Format of the line that triggers function call:

CHANGE_SVC_EVENT_HANDLER;<host_name>;<service_description>;<event_handler_command>

Parameters:
Returns:

None

change_svc_modattr(service, value)[source]

Change service modified attributes Format of the line that triggers function call:

CHANGE_SVC_MODATTR;<host_name>;<service_description>;<value>

Parameters:
Returns:

None

change_svc_notification_timeperiod(service, notification_timeperiod)[source]

Change service notification timeperiod Format of the line that triggers function call:

CHANGE_SVC_NOTIFICATION_TIMEPERIOD;<host_name>;<service_description>; <notification_timeperiod>

Parameters:
Returns:

None

commands = {'change_contact_svc_notification_timeperiod': {'global': True, 'args': ['contact', 'time_period']}, 'send_custom_svc_notification': {'global': False, 'args': ['service', 'to_int', 'author', None]}, 'reload_config': {'global': True, 'internal': True, 'args': []}, 'delay_svc_notification': {'global': False, 'args': ['service', 'to_int']}, 'start_obsessing_over_svc_checks': {'global': True, 'args': []}, 'enable_svc_check': {'global': False, 'args': ['service']}, 'change_normal_host_check_interval': {'global': False, 'args': ['host', 'to_int']}, 'set_host_notification_number': {'global': False, 'args': ['host', 'to_int']}, 'change_svc_check_command': {'global': False, 'args': ['service', 'command']}, 'stop_obsessing_over_host': {'global': False, 'args': ['host']}, 'schedule_host_downtime': {'global': False, 'args': ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]}, 'disable_passive_host_checks': {'global': False, 'args': ['host']}, 'acknowledge_host_problem_expire': {'global': False, 'args': ['host', 'to_int', 'to_bool', 'to_bool', 'to_int', 'author', None]}, 'schedule_svc_check': {'global': False, 'args': ['service', 'to_int']}, 'enable_service_freshness_checks': {'global': True, 'args': []}, 'enable_contact_svc_notifications': {'global': True, 'args': ['contact']}, 'disable_svc_check': {'global': False, 'args': ['service']}, 'disable_hostgroup_host_checks': {'global': True, 'args': ['host_group']}, 'schedule_host_svc_checks': {'global': False, 'args': ['host', 'to_int']}, 'remove_svc_acknowledgement': {'global': False, 'args': ['service']}, 'schedule_and_propagate_host_downtime': {'global': False, 'args': ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]}, 'process_service_output': {'global': False, 'args': ['service', None]}, 'stop_executing_host_checks': {'global': True, 'args': []}, 'schedule_host_check': {'global': False, 'args': ['host', 'to_int']}, 'change_max_host_check_attempts': {'global': False, 'args': ['host', 'to_int']}, 'enable_svc_notifications': {'global': False, 'args': ['service']}, 'enable_svc_event_handler': {'global': False, 'args': ['service']}, 'disable_contact_svc_notifications': {'global': True, 'args': ['contact']}, 'launch_svc_event_handler': {'global': False, 'args': ['service']}, 'disable_hostgroup_svc_notifications': {'global': True, 'args': ['host_group']}, 'start_obsessing_over_host_checks': {'global': True, 'args': []}, 'disable_host_svc_checks': {'global': False, 'args': ['host']}, 'del_all_svc_downtimes': {'global': False, 'args': ['service']}, 'disable_notifications': {'global': True, 'args': []}, 'stop_accepting_passive_svc_checks': {'global': True, 'args': []}, 'change_contact_modhattr': {'global': True, 'args': ['contact', None]}, 'process_host_output': {'global': False, 'args': ['host', None]}, 'restart_program': {'global': True, 'internal': True, 'args': []}, 'change_global_svc_event_handler': {'global': True, 'args': ['command']}, 'enable_failure_prediction': {'global': True, 'args': []}, 'enable_host_freshness_checks': {'global': True, 'args': []}, 'del_contact_downtime': {'global': True, 'args': ['to_int']}, 'schedule_forced_host_svc_checks': {'global': False, 'args': ['host', 'to_int']}, 'schedule_hostgroup_host_downtime': {'global': True, 'args': ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]}, 'change_host_check_timeperiod': {'global': False, 'args': ['host', 'time_period']}, 'start_obsessing_over_svc': {'global': False, 'args': ['service']}, 'del_host_dependency': {'global': False, 'args': ['host', 'host']}, 'disable_hostgroup_host_notifications': {'global': True, 'args': ['host_group']}, 'disable_contactgroup_host_notifications': {'global': True, 'args': ['contact_group']}, 'enable_servicegroup_passive_svc_checks': {'global': True, 'args': ['service_group']}, 'disable_host_notifications': {'global': False, 'args': ['host']}, 'send_custom_host_notification': {'global': False, 'args': ['host', 'to_int', 'author', None]}, 'enable_notifications': {'global': True, 'args': []}, 'enable_all_notifications_beyond_host': {'global': False, 'args': ['host']}, 'enable_servicegroup_passive_host_checks': {'global': True, 'args': ['service_group']}, 'add_simple_poller': {'global': True, 'internal': True, 'args': [None, None, None, None]}, 'schedule_forced_host_check': {'global': False, 'args': ['host', 'to_int']}, 'enable_performance_data': {'global': True, 'args': []}, 'disable_service_flap_detection': {'global': False, 'args': ['service']}, 'enable_servicegroup_host_notifications': {'global': True, 'args': ['service_group']}, 'process_service_check_result': {'global': False, 'args': ['service', 'to_int', None]}, 'stop_executing_svc_checks': {'global': True, 'args': []}, 'del_host_downtime': {'global': True, 'args': ['to_int']}, 'schedule_hostgroup_svc_downtime': {'global': True, 'args': ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]}, 'del_all_host_comments': {'global': False, 'args': ['host']}, 'change_svc_event_handler': {'global': False, 'args': ['service', 'command']}, 'del_svc_downtime': {'global': True, 'args': ['to_int']}, 'enable_hostgroup_host_notifications': {'global': True, 'args': ['host_group']}, 'disable_servicegroup_host_checks': {'global': True, 'args': ['service_group']}, 'enable_servicegroup_svc_checks': {'global': True, 'args': ['service_group']}, 'process_file': {'global': True, 'args': [None, 'to_bool']}, 'process_host_check_result': {'global': False, 'args': ['host', 'to_int', None]}, 'acknowledge_svc_problem': {'global': False, 'args': ['service', 'to_int', 'to_bool', 'to_bool', 'author', None]}, 'change_contact_modsattr': {'global': True, 'args': ['contact', None]}, 'enable_hostgroup_svc_notifications': {'global': True, 'args': ['host_group']}, 'disable_host_svc_notifications': {'global': False, 'args': ['host']}, 'change_max_svc_check_attempts': {'global': False, 'args': ['service', 'to_int']}, 'enable_event_handlers': {'global': True, 'args': []}, 'change_svc_modattr': {'global': False, 'args': ['service', 'to_int']}, 'enable_contact_host_notifications': {'global': True, 'args': ['contact']}, 'change_svc_notification_timeperiod': {'global': False, 'args': ['service', 'time_period']}, 'enable_servicegroup_svc_notifications': {'global': True, 'args': ['service_group']}, 'schedule_host_svc_downtime': {'global': False, 'args': ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]}, 'stop_obsessing_over_svc_checks': {'global': True, 'args': []}, 'enable_servicegroup_host_checks': {'global': True, 'args': ['service_group']}, 'schedule_forced_svc_check': {'global': False, 'args': ['service', 'to_int']}, 'stop_obsessing_over_host_checks': {'global': True, 'args': []}, 'add_simple_host_dependency': {'global': False, 'args': ['host', 'host']}, 'enable_host_notifications': {'global': False, 'args': ['host']}, 'enable_host_event_handler': {'global': False, 'args': ['host']}, 'add_host_comment': {'global': False, 'args': ['host', 'to_bool', 'author', None]}, 'start_obsessing_over_host': {'global': False, 'args': ['host']}, 'disable_svc_event_handler': {'global': False, 'args': ['service']}, 'change_custom_host_var': {'global': False, 'args': ['host', None, None]}, 'del_all_svc_comments': {'global': False, 'args': ['service']}, 'disable_host_flap_detection': {'global': False, 'args': ['host']}, 'disable_servicegroup_passive_svc_checks': {'global': True, 'args': ['service_group']}, 'enable_contactgroup_host_notifications': {'global': True, 'args': ['contact_group']}, 'stop_obsessing_over_svc': {'global': False, 'args': ['service']}, 'disable_svc_flap_detection': {'global': False, 'args': ['service']}, 'disable_servicegroup_passive_host_checks': {'global': True, 'args': ['service_group']}, 'disable_servicegroup_svc_notifications': {'global': True, 'args': ['service_group']}, 'add_svc_comment': {'global': False, 'args': ['service', 'to_bool', 'author', None]}, 'disable_flap_detection': {'global': True, 'args': []}, 'enable_passive_svc_checks': {'global': False, 'args': ['service']}, 'disable_hostgroup_svc_checks': {'global': True, 'args': ['host_group']}, 'disable_contact_host_notifications': {'global': True, 'args': ['contact']}, 'shutdown_program': {'global': True, 'args': []}, 'read_state_information': {'global': True, 'args': []}, 'change_host_modattr': {'global': False, 'args': ['host', 'to_int']}, 'change_retry_host_check_interval': {'global': False, 'args': ['host', 'to_int']}, 'disable_svc_notifications': {'global': False, 'args': ['service']}, 'acknowledge_host_problem': {'global': False, 'args': ['host', 'to_int', 'to_bool', 'to_bool', 'author', None]}, 'disable_servicegroup_host_notifications': {'global': True, 'args': ['service_group']}, 'disable_contactgroup_svc_notifications': {'global': True, 'args': ['contact_group']}, 'disable_servicegroup_svc_checks': {'global': True, 'args': ['service_group']}, 'change_contact_host_notification_timeperiod': {'global': True, 'args': ['contact', 'time_period']}, 'schedule_svc_downtime': {'global': False, 'args': ['service', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]}, 'remove_host_acknowledgement': {'global': False, 'args': ['host']}, 'enable_hostgroup_svc_checks': {'global': True, 'args': ['host_group']}, 'disable_event_handlers': {'global': True, 'args': []}, 'disable_host_event_handler': {'global': False, 'args': ['host']}, 'disable_passive_svc_checks': {'global': False, 'args': ['service']}, 'enable_host_check': {'global': False, 'args': ['host']}, 'start_accepting_passive_host_checks': {'global': True, 'args': []}, 'enable_passive_host_checks': {'global': False, 'args': ['host']}, 'enable_hostgroup_host_checks': {'global': True, 'args': ['host_group']}, 'change_host_event_handler': {'global': False, 'args': ['host', 'command']}, 'start_accepting_passive_svc_checks': {'global': True, 'args': []}, 'disable_host_freshness_checks': {'global': True, 'args': []}, 'delay_host_notification': {'global': False, 'args': ['host', 'to_int']}, 'change_normal_svc_check_interval': {'global': False, 'args': ['service', 'to_int']}, 'schedule_contact_downtime': {'global': True, 'args': ['contact', 'to_int', 'to_int', 'author', None]}, 'disable_hostgroup_passive_host_checks': {'global': True, 'args': ['host_group']}, 'enable_contactgroup_svc_notifications': {'global': True, 'args': ['contact_group']}, 'acknowledge_svc_problem_expire': {'global': False, 'args': ['service', 'to_int', 'to_bool', 'to_bool', 'to_int', 'author', None]}, 'del_all_host_downtimes': {'global': False, 'args': ['host']}, 'enable_host_flap_detection': {'global': False, 'args': ['host']}, 'change_contact_modattr': {'global': True, 'args': ['contact', None]}, 'enable_flap_detection': {'global': True, 'args': []}, 'schedule_servicegroup_host_downtime': {'global': True, 'args': ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]}, 'schedule_and_propagate_triggered_host_downtime': {'global': False, 'args': ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]}, 'disable_all_notifications_beyond_host': {'global': False, 'args': ['host']}, 'enable_host_svc_checks': {'global': False, 'args': ['host']}, 'start_executing_svc_checks': {'global': True, 'args': []}, 'enable_host_svc_notifications': {'global': False, 'args': ['host']}, 'change_host_check_command': {'global': False, 'args': ['host', 'command']}, 'change_custom_contact_var': {'global': True, 'args': ['contact', None, None]}, 'set_svc_notification_number': {'global': False, 'args': ['service', 'to_int']}, 'disable_host_and_child_notifications': {'global': False, 'args': ['host']}, 'disable_failure_prediction': {'global': True, 'args': []}, 'disable_host_check': {'global': False, 'args': ['host']}, 'disable_performance_data': {'global': True, 'args': []}, 'enable_svc_flap_detection': {'global': False, 'args': ['service']}, 'save_state_information': {'global': True, 'args': []}, 'disable_hostgroup_passive_svc_checks': {'global': True, 'args': ['host_group']}, 'change_svc_check_timeperiod': {'global': False, 'args': ['service', 'time_period']}, 'change_global_host_event_handler': {'global': True, 'args': ['command']}, 'del_svc_comment': {'global': True, 'args': ['to_int']}, 'launch_host_event_handler': {'global': False, 'args': ['host']}, 'enable_hostgroup_passive_host_checks': {'global': True, 'args': ['host_group']}, 'change_retry_svc_check_interval': {'global': False, 'args': ['service', 'to_int']}, 'change_custom_svc_var': {'global': False, 'args': ['service', None, None]}, 'stop_accepting_passive_host_checks': {'global': True, 'args': []}, 'enable_host_and_child_notifications': {'global': False, 'args': ['host']}, 'start_executing_host_checks': {'global': True, 'args': []}, 'del_host_comment': {'global': True, 'args': ['to_int']}, 'schedule_servicegroup_svc_downtime': {'global': True, 'args': ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]}, 'disable_service_freshness_checks': {'global': True, 'args': []}, 'enable_hostgroup_passive_svc_checks': {'global': True, 'args': ['host_group']}}
del_all_host_comments(host)[source]

Delete all host comments Format of the line that triggers function call:

DEL_ALL_HOST_COMMENTS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
del_all_host_downtimes(host)[source]

Delete all host downtimes Format of the line that triggers function call:

DEL_ALL_HOST_DOWNTIMES;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
del_all_svc_comments(service)[source]

Delete all service comments Format of the line that triggers function call:

DEL_ALL_SVC_COMMENTS;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
del_all_svc_downtimes(service)[source]

Delete all service downtime Format of the line that triggers function call:

DEL_ALL_SVC_DOWNTIMES;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
del_contact_downtime(downtime_id)[source]

Delete a contact downtime Format of the line that triggers function call:

DEL_CONTACT_DOWNTIME;<downtime_id>

Parameters:downtime_id (int) – downtime id to delete
Returns:None
del_host_comment(comment_id)[source]

Delete a host comment Format of the line that triggers function call:

DEL_HOST_COMMENT;<comment_id>

Parameters:comment_id (int) – comment id to delete
Returns:None
del_host_dependency(son, father)[source]

Delete a host dependency between son and father Format of the line that triggers function call:

DEL_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>

Parameters:
Returns:

None

del_host_downtime(downtime_id)[source]

Delete a host downtime Format of the line that triggers function call:

DEL_HOST_DOWNTIME;<downtime_id>

Parameters:downtime_id (int) – downtime id to delete
Returns:None
del_svc_comment(comment_id)[source]

Delete a service comment Format of the line that triggers function call:

DEL_SVC_COMMENT;<comment_id>

Parameters:comment_id (int) – comment id to delete
Returns:None
del_svc_downtime(downtime_id)[source]

Delete a service downtime Format of the line that triggers function call:

DEL_SVC_DOWNTIME;<downtime_id>

Parameters:downtime_id (int) – downtime id to delete
Returns:None
delay_host_notification(host, notification_time)[source]

Modify host first notification delay Format of the line that triggers function call:

DELAY_HOST_NOTIFICATION;<host_name>;<notification_time>

Parameters:
Returns:

None

delay_svc_notification(service, notification_time)[source]

Modify service first notification delay Format of the line that triggers function call:

DELAY_SVC_NOTIFICATION;<host_name>;<service_description>;<notification_time>

Parameters:
Returns:

None

disable_all_notifications_beyond_host(host)[source]

DOES NOTHING (should disable notification beyond a host) Format of the line that triggers function call:

DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None

TODO: Implement it

disable_contact_host_notifications(contact)[source]

Disable host notifications for a contact Format of the line that triggers function call:

DISABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>

Parameters:contact (alignak.objects.contact.Contact) – contact to disable
Returns:None
disable_contact_svc_notifications(contact)[source]

Disable service notifications for a contact Format of the line that triggers function call:

DISABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>

Parameters:contact (alignak.objects.contact.Contact) – contact to disable
Returns:None
disable_contactgroup_host_notifications(contactgroup)[source]

Disable host notifications for a contactgroup Format of the line that triggers function call:

DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>

Parameters:contactgroup (alignak.objects.contactgroup.Contactgroup) – contactgroup to disable
Returns:None
disable_contactgroup_svc_notifications(contactgroup)[source]

Disable service notifications for a contactgroup Format of the line that triggers function call:

DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>

Parameters:contactgroup (alignak.objects.contactgroup.Contactgroup) – contactgroup to disable
Returns:None
disable_event_handlers()[source]

Disable event handlers (globally) Format of the line that triggers function call:

DISABLE_EVENT_HANDLERS

Returns:None
disable_failure_prediction()[source]

Disable failure prediction (globally) Format of the line that triggers function call:

DISABLE_FAILURE_PREDICTION

Returns:None
disable_flap_detection()[source]

Disable flap detection (globally) Format of the line that triggers function call:

DISABLE_FLAP_DETECTION

Returns:None
disable_host_and_child_notifications(host)[source]

DOES NOTHING (Should disable host notifications and its child) Format of the line that triggers function call:

DISABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
disable_host_check(host)[source]

Disable checks for a host Format of the line that triggers function call:

DISABLE_HOST_CHECK;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
disable_host_event_handler(host)[source]

Disable event handlers for a host Format of the line that triggers function call:

DISABLE_HOST_EVENT_HANDLER;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
disable_host_flap_detection(host)[source]

Disable flap detection for a host Format of the line that triggers function call:

DISABLE_HOST_FLAP_DETECTION;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
disable_host_freshness_checks()[source]

Disable freshness checks (globally) Format of the line that triggers function call:

DISABLE_HOST_FRESHNESS_CHECKS

Returns:None
disable_host_notifications(host)[source]

Disable notifications for a host Format of the line that triggers function call:

DISABLE_HOST_NOTIFICATIONS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
disable_host_svc_checks(host)[source]

Disable service checks for a host Format of the line that triggers function call:

DISABLE_HOST_SVC_CHECKS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
disable_host_svc_notifications(host)[source]

Disable services notifications for a host Format of the line that triggers function call:

DISABLE_HOST_SVC_NOTIFICATIONS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
disable_hostgroup_host_checks(hostgroup)[source]

Disable host checks for a hostgroup Format of the line that triggers function call:

DISABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to disable
Returns:None
disable_hostgroup_host_notifications(hostgroup)[source]

Disable host notifications for a hostgroup Format of the line that triggers function call:

DISABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to disable
Returns:None
disable_hostgroup_passive_host_checks(hostgroup)[source]

Disable host passive checks for a hostgroup Format of the line that triggers function call:

DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to disable
Returns:None
disable_hostgroup_passive_svc_checks(hostgroup)[source]

Disable service passive checks for a hostgroup Format of the line that triggers function call:

DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to disable
Returns:None
disable_hostgroup_svc_checks(hostgroup)[source]

Disable service checks for a hostgroup Format of the line that triggers function call:

DISABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to disable
Returns:None
disable_hostgroup_svc_notifications(hostgroup)[source]

Disable service notifications for a hostgroup Format of the line that triggers function call:

DISABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to disable
Returns:None
disable_notifications()[source]

Disable notifications (globally) Format of the line that triggers function call:

DISABLE_NOTIFICATIONS

Returns:None
disable_passive_host_checks(host)[source]

Disable passive checks for a host Format of the line that triggers function call:

DISABLE_PASSIVE_HOST_CHECKS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
disable_passive_svc_checks(service)[source]

Disable passive checks for a service Format of the line that triggers function call:

DISABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
disable_performance_data()[source]

Disable performance data processing (globally) Format of the line that triggers function call:

DISABLE_PERFORMANCE_DATA

Returns:None
disable_service_flap_detection(service)[source]

Disable flap detection for a service Format of the line that triggers function call:

DISABLE_SERVICE_FLAP_DETECTION;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
disable_service_freshness_checks()[source]

Disable service freshness checks (globally) Format of the line that triggers function call:

DISABLE_SERVICE_FRESHNESS_CHECKS

Returns:None
disable_servicegroup_host_checks(servicegroup)[source]

Disable host checks for a servicegroup Format of the line that triggers function call:

DISABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to disable
Returns:None
disable_servicegroup_host_notifications(servicegroup)[source]

Disable host notifications for a servicegroup Format of the line that triggers function call:

DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to disable
Returns:None
disable_servicegroup_passive_host_checks(servicegroup)[source]

Disable passive host checks for a servicegroup Format of the line that triggers function call:

DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to disable
Returns:None
disable_servicegroup_passive_svc_checks(servicegroup)[source]

Disable passive service checks for a servicegroup Format of the line that triggers function call:

DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to disable
Returns:None
disable_servicegroup_svc_checks(servicegroup)[source]

Disable service checks for a servicegroup Format of the line that triggers function call:

DISABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to disable
Returns:None
disable_servicegroup_svc_notifications(servicegroup)[source]

Disable service notifications for a servicegroup Format of the line that triggers function call:

DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to disable
Returns:None
disable_svc_check(service)[source]

Disable checks for a service Format of the line that triggers function call:

DISABLE_SVC_CHECK;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
disable_svc_event_handler(service)[source]

Disable event handlers for a service Format of the line that triggers function call:

DISABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
disable_svc_flap_detection(service)[source]

Disable flap detection for a service Format of the line that triggers function call:

DISABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
disable_svc_notifications(service)[source]

Disable notifications for a service Format of the line that triggers function call:

DISABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
dispatch_global_command(command)[source]

Send command to scheduler, it’s a global one

Parameters:command (alignak.external_command.ExternalCommand) – command to send
Returns:None
enable_all_notifications_beyond_host(host)[source]

DOES NOTHING (should enable notification beyond a host) Format of the line that triggers function call:

ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None

TODO: Implement it

enable_contact_host_notifications(contact)[source]

Enable host notifications for a contact Format of the line that triggers function call:

ENABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>

Parameters:contact (alignak.objects.contact.Contact) – contact to enable
Returns:None
enable_contact_svc_notifications(contact)[source]

Enable service notifications for a contact Format of the line that triggers function call:

DISABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>

Parameters:contact (alignak.objects.contact.Contact) – contact to enable
Returns:None
enable_contactgroup_host_notifications(contactgroup)[source]

Enable host notifications for a contactgroup Format of the line that triggers function call:

ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>

Parameters:contactgroup (alignak.objects.contactgroup.Contactgroup) – contactgroup to enable
Returns:None
enable_contactgroup_svc_notifications(contactgroup)[source]

Enable service notifications for a contactgroup Format of the line that triggers function call:

ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>

Parameters:contactgroup (alignak.objects.contactgroup.Contactgroup) – contactgroup to enable
Returns:None
enable_event_handlers()[source]

Enable event handlers (globally) Format of the line that triggers function call:

ENABLE_EVENT_HANDLERS

Returns:None
enable_failure_prediction()[source]

Enable failure prediction (globally) Format of the line that triggers function call:

ENABLE_FAILURE_PREDICTION

Returns:None
enable_flap_detection()[source]

Enable flap detection (globally) Format of the line that triggers function call:

ENABLE_FLAP_DETECTION

Returns:None
enable_host_and_child_notifications(host)[source]

DOES NOTHING (Should enable host notifications and its child) Format of the line that triggers function call:

ENABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
enable_host_check(host)[source]

Enable checks for a host Format of the line that triggers function call:

ENABLE_HOST_CHECK;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
enable_host_event_handler(host)[source]

Enable event handlers for a host Format of the line that triggers function call:

ENABLE_HOST_EVENT_HANDLER;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
enable_host_flap_detection(host)[source]

Enable flap detection for a host Format of the line that triggers function call:

ENABLE_HOST_FLAP_DETECTION;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
enable_host_freshness_checks()[source]

Enable freshness checks (globally) Format of the line that triggers function call:

ENABLE_HOST_FRESHNESS_CHECKS

Returns:None
enable_host_notifications(host)[source]

Enable notifications for a host Format of the line that triggers function call:

ENABLE_HOST_NOTIFICATIONS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
enable_host_svc_checks(host)[source]

Enable service checks for a host Format of the line that triggers function call:

ENABLE_HOST_SVC_CHECKS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
enable_host_svc_notifications(host)[source]

Enable services notifications for a host Format of the line that triggers function call:

ENABLE_HOST_SVC_NOTIFICATIONS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
enable_hostgroup_host_checks(hostgroup)[source]

Enable host checks for a hostgroup Format of the line that triggers function call:

ENABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to enable
Returns:None
enable_hostgroup_host_notifications(hostgroup)[source]

Enable host notifications for a hostgroup Format of the line that triggers function call:

ENABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to enable
Returns:None
enable_hostgroup_passive_host_checks(hostgroup)[source]

Enable host passive checks for a hostgroup Format of the line that triggers function call:

ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to enable
Returns:None
enable_hostgroup_passive_svc_checks(hostgroup)[source]

Enable service passive checks for a hostgroup Format of the line that triggers function call:

ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to enable
Returns:None
enable_hostgroup_svc_checks(hostgroup)[source]

Enable service checks for a hostgroup Format of the line that triggers function call:

ENABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to enable
Returns:None
enable_hostgroup_svc_notifications(hostgroup)[source]

Enable service notifications for a hostgroup Format of the line that triggers function call:

ENABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>

Parameters:hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to enable
Returns:None
enable_notifications()[source]

Enable notifications (globally) Format of the line that triggers function call:

ENABLE_NOTIFICATIONS

Returns:None
enable_passive_host_checks(host)[source]

Enable passive checks for a host Format of the line that triggers function call:

ENABLE_PASSIVE_HOST_CHECKS;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
enable_passive_svc_checks(service)[source]

Enable passive checks for a service Format of the line that triggers function call:

ENABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
enable_performance_data()[source]

Enable performance data processing (globally) Format of the line that triggers function call:

ENABLE_PERFORMANCE_DATA

Returns:None
enable_service_freshness_checks()[source]

Enable service freshness checks (globally) Format of the line that triggers function call:

ENABLE_SERVICE_FRESHNESS_CHECKS

Returns:None
enable_servicegroup_host_checks(servicegroup)[source]

Enable host checks for a servicegroup Format of the line that triggers function call:

ENABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to enable
Returns:None
enable_servicegroup_host_notifications(servicegroup)[source]

Enable host notifications for a servicegroup Format of the line that triggers function call:

ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to enable
Returns:None
enable_servicegroup_passive_host_checks(servicegroup)[source]

Enable passive host checks for a servicegroup Format of the line that triggers function call:

ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to enable
Returns:None
enable_servicegroup_passive_svc_checks(servicegroup)[source]

Enable passive service checks for a servicegroup Format of the line that triggers function call:

ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to enable
Returns:None
enable_servicegroup_svc_checks(servicegroup)[source]

Enable service checks for a servicegroup Format of the line that triggers function call:

ENABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to enable
Returns:None
enable_servicegroup_svc_notifications(servicegroup)[source]

Enable service notifications for a servicegroup Format of the line that triggers function call:

ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>

Parameters:servicegroup (alignak.objects.servicegroup.Servicegroup) – servicegroup to enable
Returns:None
enable_svc_check(service)[source]

Enable checks for a service Format of the line that triggers function call:

ENABLE_SVC_CHECK;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
enable_svc_event_handler(service)[source]

Enable event handlers for a service Format of the line that triggers function call:

ENABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
enable_svc_flap_detection(service)[source]

Enable flap detection for a service Format of the line that triggers function call:

ENABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
enable_svc_notifications(service)[source]

Enable notifications for a service Format of the line that triggers function call:

ENABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
get()[source]

Get external commands from fifo

Returns:external commands
Return type:list[alignak.external_command.ExternalCommand]
get_command_and_args(command, extcmd=None)[source]

Parse command and get args

Parameters:
  • command (str) – command line to parse
  • extcmd (None | object) – external command object (used to dispatch)
Returns:

Dict containing command and arg

{‘global’: False, ‘c_name’: c_name, ‘args’: args}

Return type:dict | None
static get_unknown_check_result_brok(cmd_line)[source]

Create unknown check result brok and fill it with command data

Parameters:cmd_line (str) – command line to extract data
Returns:unknown check result brok
Return type:alignak.objects.brok.Brok
launch_host_event_handler(host)[source]

Launch event handler for a service Format of the line that triggers function call:

LAUNCH_HOST_EVENT_HANDLER;<host_name>

Parameters:host (alignak.objects.host.Host) – host to execute the event handler
Returns:None
launch_svc_event_handler(service)[source]

Launch event handler for a service Format of the line that triggers function call:

LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to execute the event handler
Returns:None
load_arbiter(arbiter)[source]

Setter for arbiter attribute

Parameters:arbiter (object) – arbiter to set
Returns:None
load_receiver(receiver)[source]

Setter for receiver attribute

Parameters:receiver (object) – receiver to set
Returns:None
load_scheduler(scheduler)[source]

Setter for scheduler attribute

Parameters:scheduler (object) – scheduler to set
Returns:None
open()[source]

Create if necessary and open a pipe (Won’t work under Windows)

Returns:pipe file descriptor
Return type:file
process_file(file_name, delete)[source]

DOES NOTHING (should process a file) Format of the line that triggers function call:

PROCESS_FILE;<file_name>;<delete>

Parameters:
  • file_name (str) – file to process
  • delete – delete after processing
Returns:

None

process_host_check_result(host, status_code, plugin_output)[source]

Process host check result Format of the line that triggers function call:

PROCESS_HOST_CHECK_RESULT;<host_name>;<status_code>;<plugin_output>

Parameters:
Returns:

None

TODO: say that check is PASSIVE

process_host_output(host, plugin_output)[source]

Process host output Format of the line that triggers function call:

PROCESS_HOST_OUTPUT;<host_name>;<plugin_output>

Parameters:
Returns:

None

process_service_check_result(service, return_code, plugin_output)[source]

Process service check result Format of the line that triggers function call:

PROCESS_SERVICE_CHECK_RESULT;<host_name>;<service_description>;<return_code>;<plugin_output>

Parameters:
Returns:

None

process_service_output(service, plugin_output)[source]

Process service output Format of the line that triggers function call:

PROCESS_SERVICE_CHECK_RESULT;<host_name>;<service_description>;<plugin_output>

Parameters:
Returns:

None

read_state_information()[source]

DOES NOTHING (What it is supposed to do?) Format of the line that triggers function call:

READ_STATE_INFORMATION

Returns:None
reload_config()[source]

Reload Alignak configuration Format of the line that triggers function call:

RELOAD_CONFIG

Returns:None
remove_host_acknowledgement(host)[source]

Remove an acknowledgment on a host Format of the line that triggers function call:

REMOVE_HOST_ACKNOWLEDGEMENT;<host_name>

Parameters:host (alignak.objects.host.Host) – host to edit
Returns:None
remove_svc_acknowledgement(service)[source]

Remove an acknowledgment on a service Format of the line that triggers function call:

REMOVE_SVC_ACKNOWLEDGEMENT;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to edit
Returns:None
resolve_command(excmd)[source]

Parse command and dispatch it (to sched for example) if necessary If the command is not global it will be executed.

Parameters:excmd (alignak.external_command.ExternalCommand) – external command to handle
Returns:None
restart_program()[source]

Restart Alignak Format of the line that triggers function call:

RESTART_PROGRAM

Returns:None
save_state_information()[source]

DOES NOTHING (What it is supposed to do?) Format of the line that triggers function call:

SAVE_STATE_INFORMATION

Returns:None
schedule_and_propagate_host_downtime(host, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

DOES NOTHING (Should create host downtime and start it?) Format of the line that triggers function call:

SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>; <fixed>;<trigger_id>;<duration>;<author>;<comment>

Returns:None
schedule_and_propagate_triggered_host_downtime(host, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

DOES NOTHING (Should create triggered host downtime and start it?) Format of the line that triggers function call:

SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>; <trigger_id>;<duration>;<author>;<comment>

Returns:None
schedule_contact_downtime(contact, start_time, end_time, author, comment)[source]

Schedule contact downtime Format of the line that triggers function call:

SCHEDULE_CONTACT_DOWNTIME;<contact_name>;<start_time>;<end_time>;<author>;<comment>

Parameters:
  • contact (alignak.objects.contact.Contact) – contact to put in downtime
  • start_time (int) – downtime start time
  • end_time (int) – downtime end time
  • author (str) – downtime author
  • comment (str) – text comment
Returns:

None

schedule_forced_host_check(host, check_time)[source]

Schedule a forced check on a host Format of the line that triggers function call:

SCHEDULE_FORCED_HOST_CHECK;<host_name>;<check_time>

Parameters:
  • host (alignak.object.host.Host) – host to check
  • check_time (int) – time to check
Returns:

None

schedule_forced_host_svc_checks(host, check_time)[source]

Schedule a forced check on all services of a host Format of the line that triggers function call:

SCHEDULE_FORCED_HOST_SVC_CHECKS;<host_name>;<check_time>

Parameters:
  • host (alignak.object.host.Host) – host to check
  • check_time (int) – time to check
Returns:

None

schedule_forced_svc_check(service, check_time)[source]

Schedule a forced check on a service Format of the line that triggers function call:

SCHEDULE_FORCED_SVC_CHECK;<host_name>;<service_description>;<check_time>

Parameters:
  • service (alignak.object.service.Service) – service to check
  • check_time (int) – time to check
Returns:

None

schedule_host_check(host, check_time)[source]

Schedule a check on a host Format of the line that triggers function call:

SCHEDULE_HOST_CHECK;<host_name>;<check_time>

Parameters:
  • host (alignak.object.host.Host) – host to check
  • check_time – time to check
Returns:

None

schedule_host_downtime(host, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

Schedule a host downtime Format of the line that triggers function call:

SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>; <trigger_id>;<duration>;<author>;<comment>

Parameters:
  • host (alignak.object.host.Host) – host to schedule downtime
  • start_time – downtime start time
  • end_time – downtime end time
  • fixed (bool) – is downtime fixed
  • trigger_id (int) – downtime id that triggered this one
  • duration (int) – downtime duration
  • author (str) – downtime author
  • comment (str) – downtime comment
Returns:

None

schedule_host_svc_checks(host, check_time)[source]

Schedule a check on all services of a host Format of the line that triggers function call:

SCHEDULE_HOST_SVC_CHECKS;<host_name>;<check_time>

Parameters:
  • host (alignak.object.host.Host) – host to check
  • check_time – time to check
Returns:

None

schedule_host_svc_downtime(host, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

Schedule a service downtime for each service of a host Format of the line that triggers function call:

SCHEDULE_HOST_SVC_DOWNTIME;<host_name>;<start_time>;<end_time>; <fixed>;<trigger_id>;<duration>;<author>;<comment>

Parameters:
  • host (alignak.object.host.Host) – host to schedule downtime
  • start_time – downtime start time
  • end_time – downtime end time
  • fixed (bool) – is downtime fixed
  • trigger_id (int) – downtime id that triggered this one
  • duration (int) – downtime duration
  • author (str) – downtime author
  • comment (str) – downtime comment
Returns:

None

schedule_hostgroup_host_downtime(hostgroup, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

Schedule a downtime for each host of a hostgroup Format of the line that triggers function call:

SCHEDULE_HOSTGROUP_HOST_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>; <fixed>;<trigger_id>;<duration>;<author>;<comment>

Parameters:
  • hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to schedule
  • start_time – downtime start time
  • end_time – downtime end time
  • fixed – is downtime fixed
  • trigger_id (int) – downtime id that triggered this one
  • duration (int) – downtime duration
  • author (str) – downtime author
  • comment (str) – downtime comment
Returns:

None

schedule_hostgroup_svc_downtime(hostgroup, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

Schedule a downtime for each service of each host of a hostgroup Format of the line that triggers function call:

SCHEDULE_HOSTGROUP_SVC_DOWNTIME;;<hostgroup_name>;<start_time>;<end_time>;<fixed>; <trigger_id>;<duration>;<author>;<comment>

Parameters:
  • hostgroup (alignak.objects.hostgroup.Hostgroup) – hostgroup to schedule
  • start_time – downtime start time
  • end_time – downtime end time
  • fixed – is downtime fixed
  • trigger_id (int) – downtime id that triggered this one
  • duration (int) – downtime duration
  • author (str) – downtime author
  • comment (str) – downtime comment
Returns:

None

schedule_servicegroup_host_downtime(servicegroup, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

Schedule a host downtime for each host of services in a servicegroup Format of the line that triggers function call:

SCHEDULE_SERVICEGROUP_HOST_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>; <trigger_id>;<duration>;<author>;<comment>

Parameters:
  • servicegroup (alignak.object.servicegroup.Servicegroup) – servicegroup to schedule downtime
  • start_time – downtime start time
  • end_time – downtime end time
  • fixed (bool) – is downtime fixed
  • trigger_id (int) – downtime id that triggered this one
  • duration (int) – downtime duration
  • author (str) – downtime author
  • comment (str) – downtime comment
Returns:

None

schedule_servicegroup_svc_downtime(servicegroup, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

Schedule a service downtime for each service of a servicegroup Format of the line that triggers function call:

SCHEDULE_SERVICEGROUP_SVC_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>; <fixed>;<trigger_id>;<duration>;<author>;<comment>

Parameters:
  • servicegroup (alignak.object.servicegroup.Servicegroup) – servicegroup to schedule downtime
  • start_time – downtime start time
  • end_time – downtime end time
  • fixed (bool) – is downtime fixed
  • trigger_id (int) – downtime id that triggered this one
  • duration (int) – downtime duration
  • author (str) – downtime author
  • comment (str) – downtime comment
Returns:

None

schedule_svc_check(service, check_time)[source]

Schedule a check on a service Format of the line that triggers function call:

SCHEDULE_SVC_CHECK;<host_name>;<service_description>;<check_time>

Parameters:
  • service (alignak.object.service.Service) – service to check
  • check_time – time to check
Returns:

None

schedule_svc_downtime(service, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]

Schedule a service downtime Format of the line that triggers function call:

SCHEDULE_SVC_DOWNTIME;<host_name>;<service_description><start_time>;<end_time>; <fixed>;<trigger_id>;<duration>;<author>;<comment>

Parameters:
  • service (alignak.object.service.Service) – service to check
  • start_time – downtime start time
  • end_time – downtime end time
  • fixed (bool) – is downtime fixed
  • trigger_id (int) – downtime id that triggered this one
  • duration (int) – downtime duration
  • author (str) – downtime author
  • comment (str) – downtime comment
Returns:

None

search_host_and_dispatch(host_name, command, extcmd)[source]

Try to dispatch a command for a specific host (so specific scheduler) because this command is related to a host (change notification interval for example)

Parameters:
Returns:

None

send_custom_host_notification(host, options, author, comment)[source]

DOES NOTHING (Should send a custom notification) Format of the line that triggers function call:

SEND_CUSTOM_HOST_NOTIFICATION;<host_name>;<options>;<author>;<comment>

Parameters:
  • host (alignak.object.host.Host) – host to send notif for
  • options – notification options
  • author (str) – notification author
  • comment (str) – notification text
Returns:

None

send_custom_svc_notification(service, options, author, comment)[source]

DOES NOTHING (Should send a custom notification) Format of the line that triggers function call:

SEND_CUSTOM_SVC_NOTIFICATION;<host_name>;<service_description>;<options>;<author>;<comment>>

Parameters:
  • service (alignak.object.service.Service) – service to send notif for
  • options – notification options
  • author (str) – notification author
  • comment (str) – notification text
Returns:

None

set_host_notification_number(host, notification_number)[source]

DOES NOTHING (Should set host notification number) Format of the line that triggers function call:

SET_HOST_NOTIFICATION_NUMBER;<host_name>;<notification_number>

Parameters:
  • host (alignak.object.host.Host) – host to edit
  • notification_number – new value to set
Returns:

None

set_svc_notification_number(service, notification_number)[source]

DOES NOTHING (Should set host notification number) Format of the line that triggers function call:

SET_SVC_NOTIFICATION_NUMBER;<host_name>;<service_description>;<notification_number>

Parameters:
  • service (alignak.object.service.Service) – service to edit
  • notification_number – new value to set
Returns:

None

shutdown_program()[source]

DOES NOTHING (Should shutdown Alignak) Format of the line that triggers function call:

SHUTDOWN_PROGRAM

Returns:None
start_accepting_passive_host_checks()[source]

Enable passive host check submission (globally) Format of the line that triggers function call:

START_ACCEPTING_PASSIVE_HOST_CHECKS

Returns:None
start_accepting_passive_svc_checks()[source]

Enable passive service check submission (globally) Format of the line that triggers function call:

START_ACCEPTING_PASSIVE_SVC_CHECKS

Returns:None
start_executing_host_checks()[source]

Enable host check execution (globally) Format of the line that triggers function call:

START_EXECUTING_HOST_CHECKS

Returns:None
start_executing_svc_checks()[source]

Enable service check execution (globally) Format of the line that triggers function call:

START_EXECUTING_SVC_CHECKS

Returns:None
start_obsessing_over_host(host)[source]

Enable obsessing over host for a host Format of the line that triggers function call:

START_OBSESSING_OVER_HOST;<host_name>

Parameters:host (alignak.objects.host.Host) – host to obsess over
Returns:None
start_obsessing_over_host_checks()[source]

Enable obssessing over host check (globally) Format of the line that triggers function call:

START_OBSESSING_OVER_HOST_CHECKS

Returns:None
start_obsessing_over_svc(service)[source]

Enable obssessing over service for a service Format of the line that triggers function call:

START_OBSESSING_OVER_SVC;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to obssess over
Returns:None
start_obsessing_over_svc_checks()[source]

Enable obssessing over service check (globally) Format of the line that triggers function call:

START_OBSESSING_OVER_SVC_CHECKS

Returns:None
stop_accepting_passive_host_checks()[source]

Disable passive host check submission (globally) Format of the line that triggers function call:

STOP_ACCEPTING_PASSIVE_HOST_CHECKS

Returns:None
stop_accepting_passive_svc_checks()[source]

Disable passive service check submission (globally) Format of the line that triggers function call:

STOP_ACCEPTING_PASSIVE_SVC_CHECKS

Returns:None
stop_executing_host_checks()[source]

Disable host check execution (globally) Format of the line that triggers function call:

STOP_EXECUTING_HOST_CHECKS

Returns:None
stop_executing_svc_checks()[source]

Disable service check execution (globally) Format of the line that triggers function call:

STOP_EXECUTING_SVC_CHECKS

Returns:None
stop_obsessing_over_host(host)[source]

Disable obsessing over host for a host Format of the line that triggers function call:

STOP_OBSESSING_OVER_HOST;<host_name>

Parameters:host (alignak.objects.host.Host) – host to obsess over
Returns:None
stop_obsessing_over_host_checks()[source]

Disable obssessing over host check (globally) Format of the line that triggers function call:

STOP_OBSESSING_OVER_HOST_CHECKS

Returns:None
stop_obsessing_over_svc(service)[source]

Disable obssessing over service for a service Format of the line that triggers function call:

STOP_OBSESSING_OVER_SVC;<host_name>;<service_description>

Parameters:service (alignak.objects.service.Service) – service to obssess over
Returns:None
stop_obsessing_over_svc_checks()[source]

Disable obssessing over service check (globally) Format of the line that triggers function call:

STOP_OBSESSING_OVER_SVC_CHECKS

Returns:None

alignak.graph module

This modules provide Graph class. Used to check for loop into dependencies

class alignak.graph.Graph[source]

Graph is a class to make graph things like DFS checks or accessibility Why use an atomic bomb when a little hammer is enough? Graph are oriented.

add_edge(from_node, to_node)[source]

Add edge between two node The edge is oriented

Parameters:
  • from_node (object) – node where edge starts
  • to_node (object) – node where edge ends
Returns:

None

add_node(node)[source]

Create the node key into the mode dict with [] value

Parameters:node (object) – node to add
Returns:None
add_nodes(nodes)[source]

Add several nodes into the nodes dict

Parameters:nodes (object) – nodes to add
Returns:None
dfs_get_all_childs(root)[source]

Recursively get all sons of this node

Parameters:root – node to get sons
Returns:sons
Return type:list

Main algorithm to look for loop. It tags nodes and find ones stucked in loop.

  • Init all nodes with DFS_UNCHECKED value
  • DFS_TEMPORARY_CHECKED means we found it once
  • DFS_OK : this node (and all sons) are fine
  • DFS_NEAR_LOOP : One froblem was found in of of the son
  • DFS_LOOP_INSIDE : This node is part of a loop
Parameters:root – Root of the dependency tree
Returns:None
get_accessibility_packs()[source]

Get accessibility packs of the graph: in one pack element are related in a way. Between packs, there is no relation at all. TODO: Make it work for directional graph too Because for now, edge must be father->son AND son->father

Returns:packs of nodes
Return type:list
loop_check()[source]

Check if we have a loop in the graph

Returns:Nodes in loop
Return type:list

alignak.load module

This module provide a simple abstraction for load computation in satellite

class alignak.load.Load(mins=1, initial_value=0)[source]

This class is for having a easy Load calculation without having to send value at regular interval (but it’s more efficient if you do this :) ) and without having a list or other stuff. It’s just an object, an update and a get You can define mins: the average for mins minutes. The val is the initial value. It’s better if it’s 0 but you can choose.

get_load()[source]

Get actual load. val attribute accessor

Returns:the load value
Return type:int
update_load(new_val, forced_interval=None)[source]

Update load with the new value

Parameters:
  • new_val (int) – value used to compute new load
  • forced_interval (bool) – boolean indicating if we force the interval for the value
Returns:

None

alignak.log module

This module provide logging facilities for Alignak. There is a custom log handler that create broks for every log emited with level < debug

class alignak.log.BrokHandler(broker)[source]

Bases: logging.Handler

This log handler is forwarding log messages as broks to the broker.

Only messages of level higher than DEBUG are send to other satellite to not risk overloading them.

emit(record)[source]
class alignak.log.ColorStreamHandler(stream=None)[source]

Bases: logging.StreamHandler

This log handler provides colored logs when logs are emitted to a tty.

emit(record)[source]
class alignak.log.Log(name='Alignak', level=0, log_set=False)[source]

Bases: logging.Logger

Alignak logger class, wrapping access to Python logging standard library. See : https://docs.python.org/2/howto/logging.html#logging-flow for more detail about how log are handled

debug(*args, **kwargs)[source]
error(*args, **kwargs)[source]
info(*args, **kwargs)[source]
load_obj(obj, name_=None)[source]

We load the object where we will put log broks with the ‘add’ method

Parameters:
  • obj (object) – object instance
  • name (str | None) – name of object
Returns:

None

register_local_log(path, level=None, purge_buffer=True)[source]

The alignak logging wrapper can write to a local file if needed and return the file descriptor so we can avoid to close it.

Add logging to a local log-file.

The file will be rotated once a day

Parameters:
  • path (str) – path of log
  • level (None | int) – level of log
  • purge_buffer (bool) – True if want purge the buffer, otherwise False
Returns:

setLevel(level)[source]

Set level of logger and handlers. The logger need the lowest level (see link above)

Parameters:level (int) – logger/handler level
Returns:None
set_human_format(human=True)[source]

Set the output as human format.

If the optional parameter human is False, the timestamps format will be reset to the default format.

Parameters:human (bool) – True if want timestamp in human format, otherwise False
Returns:None
warning(*args, **kwargs)[source]
alignak.log.naglog_result(level, result, *args)[source]

Function use for old Nag compatibility. We to set format properly for this call only.

Dirty Hack to keep the old format, we should have another logger and use one for Alignak logs and another for monitoring data

alignak.macroresolver module

This class resolve Macro in commands by looking at the macros list in Class of elements. It give a property that call be callable or not. It not callable, it’s a simple property and replace the macro with the value If callable, it’s a method that is called to get the value. for example, to get the number of service in a host, you call a method to get the len(host.services)

class alignak.macroresolver.MacroResolver[source]

Bases: alignak.borg.Borg

MacroResolver class is used to resolve macros (in command call). See above for details

get_env_macros(data)[source]

Get all environment macros from data For each object in data

* Fetch all macros in object.__class__.macros
* Fetch all customs macros in o.custom
Parameters:data – data to get macro
Returns:dict with macro name as key and macro value as value
Return type:dict
init(conf)[source]

Init macroresolver instance with conf. Must be called once.

Parameters:conf – conf to load
Returns:None
macros = {'TOTALSERVICESCRITICALUNHANDLED': '_get_total_services_critical_unhandled', 'PROCESSSTARTTIME': '_get_process_start_time', 'SHORTDATETIME': '_get_short_date_time', 'TOTALHOSTPROBLEMSUNHANDLED': '_get_total_host_problems_unhandled', 'TOTALSERVICESWARNINGUNHANDLED': '_get_total_services_warning_unhandled', 'TOTALSERVICEPROBLEMSUNHANDLED': '_get_total_service_problems_unhandled', 'DATE': '_get_date', 'TOTALHOSTSUP': '_get_total_hosts_up', 'TOTALSERVICESCRITICAL': '_get_total_services_critical', 'TOTALHOSTSUNREACHABLEUNHANDLED': '_get_total_hosts_unreachable_unhandled', 'TIMET': '_get_timet', 'TOTALHOSTSUNREACHABLE': '_get_total_hosts_unreachable', 'TOTALSERVICESUNKNOWN': '_get_total_services_unknown', 'TOTALHOSTSDOWNUNHANDLED': '_get_total_hosts_unhandled', 'TOTALSERVICESUNKNOWNUNHANDLED': '_get_total_services_unknown_unhandled', 'EVENTSTARTTIME': '_get_events_start_time', 'TOTALSERVICESOK': '_get_total_service_ok', 'TOTALSERVICEPROBLEMS': '_get_total_service_problems', 'TOTALHOSTSDOWN': '_get_total_hosts_down', 'TOTALHOSTPROBLEMS': '_get_total_host_problems', 'LONGDATETIME': '_get_long_date_time', 'TIME': '_get_time', 'TOTALSERVICESWARNING': '_get_total_services_warning'}
my_type = 'macroresolver'
output_macros = ['HOSTOUTPUT', 'HOSTPERFDATA', 'HOSTACKAUTHOR', 'HOSTACKCOMMENT', 'SERVICEOUTPUT', 'SERVICEPERFDATA', 'SERVICEACKAUTHOR', 'SERVICEACKCOMMENT']
resolve_command(com, data)[source]

Resolve command macros with data

Parameters:
  • com (object) – check / event handler or command call object
  • data – objects list, use to look for a specific macro
Returns:

command line with ‘$MACRO$’ replaced with values

Return type:

str

resolve_simple_macros_in_string(c_line, data, args=None)[source]

Replace macro in the command line with the real value

Parameters:
  • c_line (str) – command line to modify
  • data – objects list, use to look for a specific macro
  • args – args given to the command line, used to get “ARGN” macros.
Returns:

command line with ‘$MACRO$’ replaced with values

Return type:

str

alignak.message module

This module provides Message class. Used for communication between daemon process (with queues)

class alignak.message.Message(_id, _type, data=None, source=None)[source]

This is a simple message class for communications between actionners and workers

get_data()[source]

Getter of _data attribute

Returns:Message data
Return type:str
get_from()[source]

Getter of _from attribute

Returns:Message from (worker name)
Return type:str
get_type()[source]

Getter of _type attribute

Returns:Message type
Return type:str
my_type = 'message'
str()[source]

String representation of message

Returns:“Message from %d (%s), Type: %s Data: %s” (from, source, type, data)
Return type:str

TODO: Rename this __str__

alignak.modulesctx module

This module provides ModulesContext class that allow Alignak module to load other module. This will become deprecated with namespace in Alignak and keep for backward compatibility with Shinken.

class alignak.modulesctx.ModulesContext[source]

Bases: object

ModulesContext class is used to load modules in Alignak from modules_dir defined in configuration

get_module(mod_name)[source]

Get and load a module

Parameters:mod_name (str) – module name to get
Returns:module
Return type:object
get_modulesdir()[source]

Getter for modulesdir attribute

Returns:folder of modules
Return type:str
set_modulesdir(modulesdir)[source]

Setter for modulesdir attribute

Parameters:modulesdir (srt) – value to set
Returns:None

alignak.modulesmanager module

This module provides ModulesManager class. Used to load modules in Alignak

class alignak.modulesmanager.ModulesManager(modules_type, modules_path, modules)[source]

Bases: object

This class is use to manage modules and call callback

check_alive_instances()[source]

Check alive isntances. If not, log error and try to restart it

Returns:None
clear_instances(insts=None)[source]

Request to “remove” the given instances list or all if not provided

Parameters:insts – instances to remove (all if None)
Returns:None
get_external_from_queues()[source]

Get a list of queue from external instances

Returns:queue list
Return type:list
get_external_instances(phase=None)[source]

Get a list of external instances (in a specific phase)

Parameters:phase – phase to filter (never used)
Returns:external instances list
Return type:list
get_external_to_queues()[source]

Get a list of queue to external instances

Returns:queue list
Return type:list
get_instances()[source]

Create, init and then returns the list of module instances that the caller needs. If an instance can’t be created or init’ed then only log is done. That instance is skipped. The previous modules instance(s), if any, are all cleaned.

Arbiter call this method with start_external=False

Returns:module instances list
Return type:list
get_internal_instances(phase=None)[source]

Get a list of internal instances (in a specific phase)

Parameters:phase – phase to filter (never used)
Returns:internal instances list
Return type:list
load()[source]

Try to import the requested modules ; put the imported modules in self.imported_modules. The previous imported modules, if any, are cleaned before.

Returns:None
load_and_init()[source]

Import, instanciate & “init” the modules we have been requested

Returns:None
load_manager(manager)[source]

Setter for manager attribute

Parameters:manager (str) – value to set
Returns:None
remove_instance(inst)[source]

Request to cleanly remove the given instance. If instance is external also shutdown it cleanly

Parameters:inst (object) – instance to remove
Returns:None
set_max_queue_size(max_queue_size)[source]

Setter for max_queue_size attribute

Parameters:max_queue_size (int) – value to set
Returns:None
set_modules(modules)[source]

Setter for modules and allowed_type attributes Allowed type attribute is set based on module type in modules arg

Parameters:modules – value to set to module
Returns:None
set_to_restart(inst)[source]

Put an instance to the restart queue

Parameters:inst (object) – instance to restart
Returns:None
start_external_instances(late_start=False)[source]

Launch external instances that are load correctly

Parameters:late_start (bool) – If late_start, don’t look for last_init_try
Returns:None
stop_all()[source]

Stop all module instances

Returns:None
classmethod try_best_load(name, package=None)[source]

Try to load module in the bast way possible (using importlib)

Parameters:
  • name (str) – module name to load
  • package – package name to load module from
Returns:

None | module

Return type:

try_instance_init(inst, late_start=False)[source]

Try to “init” the given module instance.

Parameters:
  • inst (object) – instance to init
  • late_start (bool) – If late_start, don’t look for last_init_try
Returns:

True on successful init. False if instance init method raised any Exception.

Return type:

bool

classmethod try_load(mod_name, mod_dir=None)[source]

Try in three different ways to load a module

Parameters:
  • mod_name (str) – module name to load
  • mod_dir (str | None) – module directory where module is
Returns:

module

Return type:

object

try_to_restart_deads()[source]

Try to reinit and restart dead instances

Returns:None
classmethod try_very_bad_load(mod_dir)[source]

Try to load module in a bad way (Inserting mod_dir to sys.path) then try to import module (module.py file) in this directory with importlib

Parameters:mod_dir (str) – module directory to load
Returns:None
alignak.modulesmanager.uniform_module_type(mod_name)[source]

Replace _ by - in string

Parameters:mod_name – string to edit
Returns:module name with - instead of _

alignak.notification module

This module provides Notification class. Used to define monitoring notifications (email, contacts..)

class alignak.notification.Notification(_type='PROBLEM', status='scheduled', command='UNSET', command_call=None, ref=None, contact=None, t_to_go=0.0, contact_name='', host_name='', service_description='', reason_type=1, state=0, ack_author='', ack_data='', escalated=False, contacts_notified=0, start_time=0, end_time=0, notification_type=0, _id=None, notif_nb=1, timeout=10, env={}, module_type='fork', reactionner_tag='None', enable_environment_macros=False)[source]

Bases: alignak.action.Action

Notification class, inherits from action class. Used to notify contacts and execute notification command defined in configuration

ack_author
ack_data
already_start_escalations
check_time
command
command_call
contact
contact_name
contacts_notified
copy_shell()[source]

Get a copy o this notification with minimal values (default + id)

Returns:new notification
Return type:alignak.notification.Notification
creation_time
enable_environment_macros
end_time
env
escalated
execution_time
exit_status
fill_data_brok_from(data, brok_type)[source]

Fill data with info of item by looking at brok_type in props of properties or running_properties

Parameters:
  • data – data to fill
  • brok_type – type of brok
Returns:

brok with wanted data

Return type:

alignak.brok.Brok

get_id()[source]

Getter to id attribute

Returns:notification id
Return type:int
get_initial_status_brok()[source]

Get a initial status brok

Returns:brok with wanted data
Return type:alignak.brok.Brok
get_return_from(notif)[source]

Setter of exit_status and execution_time attributes

Parameters:notif (alignak.notification.Notification) – notification to get data from
Returns:None
host_name
is_a
is_administrative()[source]

Check if this notification is “administrative”

Returns:True in type not in (‘PROBLEM’, ‘RECOVERY’), False otherwise
Return type:bool
is_launchable(timestamp)[source]

Check if this notification can be launched base on time

Parameters:timestamp (int) – time to compare
Returns:True if timestamp >= self.t_to_go, False otherwise
Return type:bool
macros = {'NOTIFICATIONAUTHORNAME': 'author_name', 'HOSTNOTIFICATIONNUMBER': 'notif_nb', 'NOTIFICATIONAUTHORALIAS': 'author_alias', 'NOTIFICATIONRECIPIENTS': 'recipients', 'HOSTNOTIFICATIONID': '_id', 'NOTIFICATIONAUTHOR': 'author', 'NOTIFICATIONISESCALATED': 'escalated', 'NOTIFICATIONTYPE': 'type', 'SERVICENOTIFICATIONNUMBER': 'notif_nb', 'NOTIFICATIONCOMMENT': 'comment', 'SERVICENOTIFICATIONID': '_id'}
module_type
my_type = 'notification'
notif_nb
notification_type
output
properties = {'reason_type': <alignak.property.IntegerProp object at 0x7f447ce44990>, 'exit_status': <alignak.property.IntegerProp object at 0x7f447ceb4d90>, 'creation_time': <alignak.property.FloatProp object at 0x7f447ce44d50>, 'command_call': <alignak.property.StringProp object at 0x7f447ce44b50>, 'reactionner_tag': <alignak.property.StringProp object at 0x7f447ceb4f50>, 's_time': <alignak.property.FloatProp object at 0x7f447ceb4f10>, 'notification_type': <alignak.property.IntegerProp object at 0x7f447ce44810>, 'contact_name': <alignak.property.StringProp object at 0x7f447ce448d0>, 'end_time': <alignak.property.IntegerProp object at 0x7f447ce44890>, 'ack_data': <alignak.property.StringProp object at 0x7f447ce44a90>, 'check_time': <alignak.property.IntegerProp object at 0x7f447ceb4e50>, 'contacts_notified': <alignak.property.IntegerProp object at 0x7f447ce44b10>, 'escalated': <alignak.property.BoolProp object at 0x7f447ce44ad0>, 'state': <alignak.property.IntegerProp object at 0x7f447ce449d0>, 'u_time': <alignak.property.FloatProp object at 0x7f447ceb4ed0>, 'env': <alignak.property.DictProp object at 0x7f447ceb4f90>, 'notif_nb': <alignak.property.IntegerProp object at 0x7f447ce44bd0>, 'type': <alignak.property.StringProp object at 0x7f447ceb4cd0>, 'ack_author': <alignak.property.StringProp object at 0x7f447ce44a50>, 'status': <alignak.property.StringProp object at 0x7f447ce44c10>, 'execution_time': <alignak.property.FloatProp object at 0x7f447ceb4e90>, 'start_time': <alignak.property.IntegerProp object at 0x7f447ce44850>, 'worker': <alignak.property.StringProp object at 0x7f447ce44090>, 't_to_go': <alignak.property.FloatProp object at 0x7f447ceb4e10>, 'module_type': <alignak.property.StringProp object at 0x7f447ce44d10>, '_in_timeout': <alignak.property.BoolProp object at 0x7f447ceb4d10>, 'sched_id': <alignak.property.IntegerProp object at 0x7f447ce44c90>, 'service_description': <alignak.property.StringProp object at 0x7f447ce44950>, 'enable_environment_macros': <alignak.property.BoolProp object at 0x7f447ce44d90>, 'is_a': <alignak.property.StringProp object at 0x7f447ce44790>, 'contact': <alignak.property.StringProp object at 0x7f447ce44b90>, 'command': <alignak.property.StringProp object at 0x7f447ce44c50>, 'host_name': <alignak.property.StringProp object at 0x7f447ce44910>, 'timeout': <alignak.property.IntegerProp object at 0x7f447ce44cd0>, 'output': <alignak.property.StringProp object at 0x7f447ce44a10>, 'already_start_escalations': <alignak.property.StringProp object at 0x7f447ce44dd0>}
reactionner_tag
reason_type
s_time
sched_id
service_description
start_time
state
status
t_to_go
timeout
type
u_time
worker

alignak.property module

This module provides property classes. It is used during configuration parsing to ensure attribute type in objects. Each class implements a pythonize method that cast data into the wanted type.

class alignak.property.UnusedProp(text=None)[source]

Bases: alignak.property.Property

A unused Property. These are typically used by Nagios but no longer useful/used by Alignak.

This is just to warn the user that the option he uses is no more used in Alignak.

class alignak.property.BoolProp(default=<object object at 0x7f447ea6e670>, class_inherit=None, unmanaged=False, _help='', no_slots=False, fill_brok=None, conf_send_preparation=None, brok_transformation=None, retention=False, retention_preparation=None, to_send=False, override=False, managed=True, split_on_coma=True, keep_empty=False, merging='uniq')[source]

Bases: alignak.property.Property

A Boolean Property.

Boolean values are currently case insensitively defined as 0, false, no, off for False, and 1, true, yes, on for True).

static pythonize(val)[source]

Convert value into a boolean

Parameters:val – value to convert
Returns:boolean corresponding to value
{‘1’: True, ‘yes’: True, ‘true’: True, ‘on’: True,
‘0’: False, ‘no’: False, ‘false’: False, ‘off’: False}
Return type:bool
class alignak.property.IntegerProp(default=<object object at 0x7f447ea6e670>, class_inherit=None, unmanaged=False, _help='', no_slots=False, fill_brok=None, conf_send_preparation=None, brok_transformation=None, retention=False, retention_preparation=None, to_send=False, override=False, managed=True, split_on_coma=True, keep_empty=False, merging='uniq')[source]

Bases: alignak.property.Property

Integer property

pythonize(val)[source]

Convert value into an integer:

* If value is a list, try to take the last element
* Then call float(int(val))
Parameters:val – value to convert
Returns:integer corresponding to value
Return type:int
class alignak.property.FloatProp(default=<object object at 0x7f447ea6e670>, class_inherit=None, unmanaged=False, _help='', no_slots=False, fill_brok=None, conf_send_preparation=None, brok_transformation=None, retention=False, retention_preparation=None, to_send=False, override=False, managed=True, split_on_coma=True, keep_empty=False, merging='uniq')[source]

Bases: alignak.property.Property

Float property

pythonize(val)[source]

Convert value into a float:

* If value is a list, try to take the last element
* Then call float(val)
Parameters:val – value to convert
Returns:float corresponding to value
Return type:float
class alignak.property.CharProp(default=<object object at 0x7f447ea6e670>, class_inherit=None, unmanaged=False, _help='', no_slots=False, fill_brok=None, conf_send_preparation=None, brok_transformation=None, retention=False, retention_preparation=None, to_send=False, override=False, managed=True, split_on_coma=True, keep_empty=False, merging='uniq')[source]

Bases: alignak.property.Property

One character string property

pythonize(val)[source]

Convert value into a char

* If value is a list try, to take the last element
* Then take the first char of val (first elem)
Parameters:val – value to convert
Returns:char corresponding to value
Return type:str
class alignak.property.StringProp(default=<object object at 0x7f447ea6e670>, class_inherit=None, unmanaged=False, _help='', no_slots=False, fill_brok=None, conf_send_preparation=None, brok_transformation=None, retention=False, retention_preparation=None, to_send=False, override=False, managed=True, split_on_coma=True, keep_empty=False, merging='uniq')[source]

Bases: alignak.property.Property

String property

pythonize(val)[source]

Convert value into a string:

* If value is a list, try to take the last element
Parameters:val – value to convert
Returns:str corresponding to value
Return type:str
class alignak.property.ListProp(default=<object object at 0x7f447ea6e670>, class_inherit=None, unmanaged=False, _help='', no_slots=False, fill_brok=None, conf_send_preparation=None, brok_transformation=None, retention=False, retention_preparation=None, to_send=False, override=False, managed=True, split_on_coma=True, keep_empty=False, merging='uniq')[source]

Bases: alignak.property.Property

List property

pythonize(val)[source]

Convert value into a list:

* split value (or each element if value is a list) on coma char
* strip split values
Parameters:val – value to convert
Returns:list corresponding to value
Return type:list

alignak.satellite module

This class is an interface for Reactionner and Poller daemons A Reactionner listens to a port for the configuration from the Arbiter The conf contains the schedulers where actionners will gather actions.

The Reactionner keeps on listening to the Arbiter (one a timeout)

If Arbiter wants it to have a new conf, the satellite forgets the previous
Schedulers (and actions into) and takes the new ones.
class alignak.satellite.BaseSatellite(name, config_file, is_daemon, do_replace, debug, debug_file)[source]

Bases: alignak.daemon.Daemon

Base Satellite class. Subclassed by Alignak (scheduler), Broker and Satellite

do_loop_turn()[source]

Abstract method for satellite loop turn. It must be overridden by class inheriting from Daemon

Returns:None
get_external_commands()[source]

Get the external commands

Returns:External commands list
Return type:list
watch_for_new_conf(timeout)[source]

Triggered by Arbiter get to make the satellite wait new conf Timeout is short is (1.0 or 0)

Parameters:timeout (float) – timeout to wait
Returns:None

TODO: Clean this, handle return a tuple and it is not used

what_i_managed()[source]

Get the managed configuration by this satellite

Returns:a dict of scheduler id as key and push_flavor as values
Return type:dict
exception alignak.satellite.NotWorkerMod[source]

Bases: exceptions.Exception

Class to tell that we are facing a non worker module but a standard one

class alignak.satellite.Satellite(name, config_file, is_daemon, do_replace, debug, debug_file)[source]

Bases: alignak.satellite.BaseSatellite

Satellite class. Subclassed by Receiver, Reactionner and Poller

add(elt)[source]

Add an object to the satellite one Handles brok and externalcommand

Parameters:elt (object) – object to add
Returns:None
add_actions(lst, sched_id)[source]

Add a list of actions to the satellite queues

Parameters:
  • lst (list) – Action list
  • sched_id (int) – sheduler id to assign to
Returns:

None

adjust_worker_number_by_load()[source]

Try to create the minimum workers specified in the configuration

Returns:None
assign_to_a_queue(action)[source]

Take an action and put it to action queue

Parameters:action (alignak.action.Action) – action to put
Returns:None
check_and_del_zombie_workers()[source]

Check if worker are fine and kill them if not. Dispatch the actions in the worker to another one

Returns:None
clean_previous_run()[source]

Clean variables from previous configuration, such as schedulers, broks and external commands

Returns:None
create_and_launch_worker(module_name='fork', mortal=True, _Satellite__warned=set([]))[source]
Create and launch a new worker, and put it into self.workers
It can be mortal or not
Parameters:
  • module_name (str) – the module name related to the worker default is “fork” for no module
  • mortal (bool) – make the Worker mortal or not. Default True
  • __warned (set) – Remember the module we warned about. This param is a tuple and as it is only init once (the default value) we use this python behavior that make this set grows with module_name not found on previous call
Returns:

None

do_get_new_actions()[source]

Get new actions from schedulers Create a Message and put into the module queue REF: doc/alignak-action-queues.png (1)

Returns:None
do_loop_turn()[source]

Satellite main loop:

* Setup new conf if necessary
* Watch for new conf
* Check and delete zombies actions / modules
* Get returns from queues
* Adjust worker number
* Get new actions
Returns:None
do_manage_returns()[source]

Manage the checks and then send a HTTP request to schedulers (POST /put_results) REF: doc/alignak-action-queues.png (6)

Returns:None
do_post_daemon_init()[source]

Do this satellite (poller or reactionner) post “daemonize” init

Returns:None
do_pynag_con_init(s_id)[source]

Initialize a connection with scheduler having ‘_id’ Return the new connection to the scheduler if it succeeded,

else: any error OR sched is inactive: return None.

NB: if sched is inactive then None is directly returned.

Parameters:s_id (int) – scheduler s_id to connect to
Returns:scheduler connection object or None
Return type:alignak.http.client.HTTPClient
do_stop()[source]

Stop all workers modules and sockets

Returns:None
get_broks()[source]

Get brok list from satellite

Returns:A copy of the Brok list
Return type:list
get_new_actions()[source]

Wrapper function for do_get_new_actions For stats purpose

Returns:None

TODO: Use a decorator

get_return_for_passive(sched_id)[source]

Get returns of passive actions for a specific scheduler

Parameters:sched_id (int) – scheduler id
Returns:Action list
Return type:list
get_returns_queue_item()[source]

Wrapper for returns_queue.get method. Return an queue element

Returns:queue Message
Return type:alignak.message.Message
get_returns_queue_len()[source]

Wrapper for returns_queue.qsize method. Return queue length

Returns:queue length
Return type:int
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,
  'type': _type,
  'passive': self.passive,
  'modules':
              {'internal': {'name': "MYMODULE1", 'state': 'ok'},
              {'external': {'name': "MYMODULE2", 'state': 'stopped'},
             ]
}
Return type:dict
main()[source]

Main satellite function. Do init and then mainloop

Returns:None
manage_action_return(action)[source]

Manage action return from Workers We just put them into the corresponding sched and we clean unused properties like sched_id

Parameters:action (alignak.action.Action) – the action to manage
Returns:None
manage_returns()[source]

Wrapper function of do_manage_returns()

Returns:None

TODO: Use a decorator for stat

pynag_con_init(_id)[source]

Wrapped function for do_pynag_con_init

Parameters:_id (int) – scheduler _id to connect to
Returns:scheduler connection object or None
Return type:alignak.http.client.HTTPClient
setup_new_conf()[source]

Setup new conf received from Arbiter

Returns:None

alignak.scheduler module

This module provides Scheduler class. It is used to schedule checks, create broks for monitoring event, handle downtime, problems / acknowledgment etc. The major part of monitoring “intelligence” is in this module.

class alignak.scheduler.Scheduler(scheduler_daemon)[source]

Bases: object

Scheduler class. Mostly handle scheduling items (host service) to schedule check raise alert, enter downtime etc.

add(elt)[source]

Generic function to add objects into scheduler internal lists:

Brok -> self.broks Check -> self.checks Notification -> self.actions Downtime -> self.downtimes ContactDowntime -> self.contact_downtimes

Parameters:elt – element to add
Returns:None
add_brok(brok, bname=None)[source]

Add a brok into brokers list It can be for a specific one, all brokers or none (startup)

Parameters:
Returns:

None

add_check(check)[source]

Add a check into checks list

Parameters:check (alignak.check.Check) – check to add
Returns:None
add_comment(comment)[source]

Add a comment into comments list

Parameters:comment (alignak.comment.Comment) – comment to add
Returns:None
add_contactdowntime(contact_dt)[source]

Add a contact downtime into contact_downtimes list

Parameters:contact_dt (alignak.contactdowntime.ContactDowntime) – contact downtime to add
Returns:None
add_downtime(downtime)[source]

Add a downtime into downtimes list

Parameters:downtime (alignak.downtime.Downtime) – downtime to add
Returns:None
add_eventhandler(action)[source]

Add a event handler into actions list

Parameters:action (alignak.eventhandler.EventHandler) – event handler to add
Returns:None
add_externalcommand(ext_cmd)[source]

Resolve external command

Parameters:ext_cmd – extermal command to run
Returns:None
add_notification(notif)[source]

Add a notification into actions list

Parameters:notif (alignak.notification.Notification) – notification to add
Returns:None
check_for_expire_acknowledge()[source]

Iter over host and service and check if any acknowledgement has expired

Returns:None
check_freshness()[source]

Iter over all hosts and services to check freshness

Returns:None
check_orphaned()[source]

Check for orphaned checks/actions:

* status == 'inpoller' and t_to_go < now - time_to_orphanage (300 by default)

if so raise a logger warning

Returns:None
clean_caches()[source]

Clean timperiods caches

Returns:None
clean_queues()[source]

Reduces internal list size to max allowed

  • checks and broks : 5 * length of hosts + services
  • actions : 5 * length of hosts + services + contacts
Returns:None
consume_results()[source]

Handle results waiting in waiting_results list. Check ref will call consume result and update their status

Returns:None
del_comment(c_id)[source]

Delete a comment

Parameters:c_id (int) – comment id to delete
Returns:None
del_contact_downtime(dt_id)[source]

Delete a contact downtime

Parameters:dt_id (int) – contact downtime id to delete
Returns:None
del_downtime(dt_id)[source]

Delete a downtime

Parameters:dt_id (int) – downtime id to delete
Returns:None
delete_zombie_actions()[source]

Remove actions that have a zombie status (usually timeouts)

Returns:None
delete_zombie_checks()[source]

Remove checks that have a zombie status (usually timeouts)

Returns:None
die()[source]

Set must_run attribute to False

Returns:None
dump_config()[source]

Dump scheduler config into a dump (temp) file

Returns:None
dump_objects()[source]

Dump scheduler objects into a dump (temp) file

Returns:None
fill_initial_broks(bname, with_logs=False)[source]

Create initial broks for a specific broker

Parameters:
  • bname (str) – broker name
  • with_logs (bool) – tell if we write a log line for hosts/services initial states
Returns:

None

get_actions_from_passives_satellites()[source]

Get actions/checks results from passive poller/reactionners

Returns:None
get_and_register_check_result_brok(item)[source]

Get a check result brok for item and add it

Parameters:item (alignak.objects.schedulingitem.SchedulingItem) – item to get brok from
Returns:None
get_and_register_program_status_brok()[source]

Create and add a program_status brok

Returns:None
get_and_register_status_brok(item)[source]

Get a update status brok for item and add it

Parameters:item (alignak.objects.item.Item) – item to get brok from
Returns:None
get_and_register_update_program_status_brok()[source]

Create and add a update_program_status brok

Returns:None
get_broks(bname)[source]

Send broks to a specific broker

Parameters:bname (str) – broker name to send broks
Returns:list of brok for this broker
Return type:list[alignak.brok.Brok]
get_checks_status_counts(checks=None)[source]

Compute the counts of the different checks status and return it as a defaultdict(int) with the keys being the different statutes and the value being the count of the checks in that status.

Checks:None or the checks you want to count their statuses. If None then self.checks is used.
Parameters:checks (None | dict) – NoneType | dict
Returns:
Return type:defaultdict(int)

Get poller link or reactionner link depending on the wanted type

Parameters:s_type (str) – type we want
Returns:links wanted
Return type:alignak.objects.pollerlink.PollerLinks | alignak.objects.reactionnerlink.ReactionnerLinks | None
get_new_actions()[source]

Call ‘get_new_actions’ hook point Iter over all hosts and services to add new actions in internal lists

Returns:None
get_new_broks()[source]

Iter over all hosts and services to add new broks in internal lists

Returns:None
get_objects_from_from_queues()[source]

Same behavior than Daemon.get_objects_from_from_queues().

Returns:
Return type:
get_program_status_brok()[source]

Create a program status brok

Returns:Brok with program status data
Return type:alignak.brok.Brok

TODO: GET REAL VALUES

get_retention_data()[source]

Get all host and service data in order to store it after The module is in charge of that

Returns:dict containing host and service data
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': ['scheduler.%s.checks.%s %d %d', 'scheduler.%s.%s.queue %d %d',
              'scheduler.%s.%s %d %d', 'scheduler.%s.latency.min %f %d',
              'scheduler.%s.latency.avg %f %d', 'scheduler.%s.latency.max %f %d'],
  'version': __version__,
  'name': instance_name,
  'type': 'scheduler',
  'modules': [
              {'internal': {'name': "MYMODULE1", 'state': 'ok'},
              {'external': {'name': "MYMODULE2", 'state': 'stopped'},
             ]
  'latency':  {'avg': lat_avg, 'min': lat_min, 'max': lat_max}
  'host': len(self.hosts),
  'services': len(self.services),
  'commands': [{'cmd': c, 'u_time': u_time, 's_time': s_time}, ...] (10 first)
}
Return type:dict
get_to_run_checks(do_checks=False, do_actions=False, poller_tags=['None'], reactionner_tags=['None'], worker_name='none', module_types=['fork'])[source]

Get actions/checks for reactionner/poller Called by poller to get checks Can get checks and actions (notifications and co)

Parameters:
  • do_checks (bool) – do we get checks ?
  • do_actions (bool) – do we get actions ?
  • poller_tags (list) – poller tags to filter
  • reactionner_tags (list) – reactionner tags to filter
  • worker_name (str) – worker name to fill check/action (to remember it)
  • module_types (list) – module type to filter
Returns:

Check/Action list with poller/reactionner tags matching and module type matching

Return type:

list

hook_point(hook_name)[source]

Generic function to call modules methods if such method is avalaible

Parameters:hook_name (str) – function name to call

:return:None TODO: find a way to merge this and the version in daemon.py

is_connection_try_too_close(elt)[source]

Check if last connection was too early for element

Parameters:elt – element to check
Returns:True if now - last_connection < 5, False otherwise
Return type:bool
iter_hosts_and_services()[source]

Create an iterator for hosts and services

Returns:None
load_conf(conf)[source]

Load configuration received from Arbiter

Parameters:conf (alignak.objects.config.Config) – configuration to laod
Returns:None
load_external_command(ecm)[source]

Setter for external_command attribute

Parameters:ecm (alignak.external_command.ExternalCommandManager) – new value
Returns:None
load_satellites(pollers, reactionners)[source]

Setter for pollers and reactionners attributes

Parameters:
  • pollers – pollers value to set
  • reactionners – reactionners value to set
Returns:

None

manage_internal_checks()[source]

Run internal checks

Returns:None
push_actions_to_passives_satellites()[source]

Send actions/checks to passive poller/reactionners

Returns:None
put_results(action)[source]

Get result from pollers/reactionners (actives ones)

Parameters:action – check / action / eventhandler to handle
Returns:None
pynag_con_init(s_id, s_type='poller')[source]

Init or reinit connection to a poller or reactionner Used for passive daemons

Parameters:
  • s_id (int) – daemon s_id to connect to
  • s_type (str) – daemon type to connect to
Returns:

None

reset()[source]

Reset scheduler:

* Remove waiting results
* Clear check, actions, downtimes, comments, broks lists
Returns:None
reset_topology_change_flag()[source]

Set topology_change attribute to False in all hosts and services

Returns:None
restore_retention_data(data)[source]

Restore retention data

Data coming from retention will override data coming from configuration It is kinda confusing when you modify an attribute (external command) and it get saved by retention

Parameters:data
Returns:None
retention_load()[source]

Call hook point ‘load_retention’. Retention modules will read retention (from file, db etc)

Parameters:forced (bool) – if update forced?
Returns:None
run()[source]

Main scheduler function:

* Load retention
* Call 'pre_scheduler_mod_start' hook point
* Start modules
* Schedule first checks
* Init connection with pollers/reactionners
* Run main loop
  • Do recurrent works
  • Push/Get actions to passive satellites
  • Update stats
  • Call ‘scheduler_tick’ hook point
  • Save retention (on quit)
Returns:None
run_external_command(command)[source]

Run a single external command

Parameters:command (str) – command line to run
Returns:None
run_external_commands(cmds)[source]

Run external commands Arbiter/Receiver sent

Parameters:cmds (list) – commands to run
Returns:None
scatter_master_notifications()[source]

Generate children notifications from master notifications Also update notification number Master notification are not launched by reactionners, only children ones

Returns:None
schedule()[source]

Iter over all hosts and services and call schedule method (schedule next check)

Returns:None
send_broks_to_modules()[source]

Put broks into module queues Only broks without sent_to_sched_externals to True are sent Only modules that ask for broks will get some

Returns:None
update_business_values()[source]

Iter over host and service and update business_impact

Returns:None
update_downtimes_and_comments()[source]

Iter over all hosts and services:

* Update downtime status (start / stop) regarding maintenance period
* Register new comments in comments list
Returns:None
update_recurrent_works_tick(f_name, new_tick)[source]

Modify the tick value for a recurrent work A tick is an amount of loop of the scheduler before executing the recurrent work

Parameters:
  • f_name (str) – recurrent work name
  • new_tick (str) – new value
Returns:

None

update_retention_file(forced=False)[source]

Call hook point ‘save_retention’. Retention modules will write back retention (to file, db etc)

Parameters:forced (bool) – if update forced?
Returns:None

alignak.shinken_import_hook module

This module provides a Finder class for python modules. It is used to keep compatibility with Shinken modules to be able to import them.

It basically replace shinken package by alignak one

class alignak.shinken_import_hook.Finder[source]

Bases: object

Finder class to import and load module

see : https://docs.python.org/2/glossary.html#term-finder
https://docs.python.org/2/library/sys.html#sys.meta_path
find_module(fullname, path=None)[source]

Find module based on the fullname and path given

Parameters:
  • fullname (str) – module full name
  • path (str) – path to find (not used, only for signature)
Returns:

module | None

Return type:

object

load_module(name)[source]

Load module

Parameters:name (str) – module to load
Returns:module
Return type:object

alignak.stats module

This module provide export of Alignak metrics in a statsd format

class alignak.stats.Stats[source]

Bases: object

Stats class to export data into a statsd format

incr(key, value)[source]

Increments a key with value

Parameters:
  • key (str) – key to edit
  • value – value to add
Returns:

None

launch_reaper_thread()[source]

Launch thread that collects data

Returns:None
load_statsd()[source]

Create socket connection to statsd host

Returns:None
reaper()[source]

Get data from daemon and send it to the statsd daemon

Returns:None
register(app, name, _type, api_key='', secret='', http_proxy='', statsd_host='localhost', statsd_port=8125, statsd_prefix='alignak', statsd_enabled=False)[source]

Init statsd instance with real values

Parameters:
  • app (alignak.daemon.Daemon) – application (arbiter, scheduler..)
  • name (str) – daemon name
  • _type – daemon type
  • api_key (str) – api_key to post data
  • secret (str) – secret to post data
  • http_proxy (str) – proxy http if necessary
  • statsd_host (str) – host to post data
  • statsd_port (int) – port to post data
  • statsd_prefix (str) – prefix to add to metric
  • statsd_enabled (bool) – bool to enable statsd
Returns:

None

alignak.stats.pad(data)[source]

Add data to fit BLOCK_SIZE

Parameters:data – initial data
Returns:data padded to fit BLOCK_SIZE
alignak.stats.unpad(padded)[source]

Unpad data based on last char

Parameters:padded – padded data
Returns:unpadded data

alignak.trigger_functions module

This module provide a set of function for triggers Basically used to handle perfdata, exit status and output

alignak.trigger_functions.allperfs(obj_ref)[source]

Get all perfdatas from a service or a host

Parameters:obj_ref (object) –
Returns:dictionary with perfdatas
Return type:dict
alignak.trigger_functions.critical(obj, output)[source]

Set a service in CRITICAL state

Parameters:
  • obj (object) – object
  • output
Returns:

None

alignak.trigger_functions.declared(function)[source]

Decorator to add function in trigger environment

Parameters:function (types.FunctionType) – function to add to trigger environment

:return : the function itself only update TRIGGER_FUNCTIONS variable

alignak.trigger_functions.down(obj, output)[source]

Set a host in DOWN state

Parameters:
  • obj (object) – object
  • output
Returns:

None

alignak.trigger_functions.get_custom(obj_ref, cname, default=None)[source]

Get custom variable from a service or a host

Parameters:
  • obj_ref (object) –
  • cname (str) –
  • default
Returns:

Return type:

alignak.trigger_functions.get_object(ref)[source]

Retrive object (service/host) from name

Parameters:ref
Returns:
Return type:
alignak.trigger_functions.get_objects(ref)[source]
TODO: check this description
Retrive objects (service/host) from names
Parameters:ref
Returns:list of object (service/host)
Return type:list
alignak.trigger_functions.ok(obj, output)[source]

Set a service in OK state

Parameters:
  • obj (object) – object
  • output
Returns:

None

alignak.trigger_functions.perf(obj_ref, metric_name)[source]

Get perf data from a service

Parameters:
Returns:

None

alignak.trigger_functions.perfs(objs_ref, metric_name)[source]
TODO: check this description
Get perfdatas from multiple services/hosts
Parameters:
  • objs_ref (object) –
  • metric_name (str) –
Returns:

list of metrics

Return type:

list

alignak.trigger_functions.set_value(obj_ref, output=None, perfdata=None, return_code=None)[source]

Set output, state and perfdata to a service or host

Parameters:
  • obj_ref (object) –
  • output (None | str) –
  • perfdata (None | str) –
  • return_code (None | int) –
Returns:

None

alignak.trigger_functions.unknown(obj, output)[source]

Set a service in UNKNOWN state

Parameters:
  • obj (object) – object
  • output
Returns:

None

alignak.trigger_functions.up(obj, output)[source]

Set a host in UP state

Parameters:
  • obj (object) – object
  • output
Returns:

None

alignak.trigger_functions.warning(obj, output)[source]

Set a service in WARNING state

Parameters:
  • obj (object) – object
  • output
Returns:

None

alignak.util module

This module provide a lot of utility functions. You can find functions for time management, type management (pythonization), macros solving, sorting, parsing, file handling, filters.

exception alignak.util.KeyValueSyntaxError[source]

Bases: exceptions.ValueError

Syntax error on a duplicate_foreach value

alignak.util.alive_then_spare_then_deads(x00, y00)[source]

Compare two satellite link based on alive attribute then spare attribute

Parameters:
  • x00 – first link to compare
  • y00 – second link to compare
Returns:

x00 > y00 (1) if x00 alive and not y00 or both alive but x00 not spare x00 == y00 (0) if both alive and spare x00 < y00 (-1) else

Return type:

int

TODO: Rework it

alignak.util.expand_ranges(value)[source]
Parameters:value (str) – The value to be “expanded”.
Returns:A generator to yield the different resulting values from expanding the eventual ranges present in the input value.
>>> tuple(expand_ranges("Item [1-3] - Bla"))
('Item 1 - Bla', 'Item 2 - Bla', 'Item 3 - Bla')
>>> tuple(expand_ranges("X[1-10/2]Y"))
('X1Y', 'X3Y', 'X5Y', 'X7Y', 'X9Y')
>>> tuple(expand_ranges("[1-6/2] [1-3]"))
('1 1', '1 2', '1 3', '3 1', '3 2', '3 3', '5 1', '5 2', '5 3')
alignak.util.expand_with_macros(ref, value)[source]
Expand the value with macros from the
host/service ref before brok it
Parameters:
  • ref – host or service
  • value – value to expand macro
Returns:

value with macro replaced

Return type:

alignak.util.expect_file_dirs(root, path)[source]

We got a file like /tmp/toto/toto2/bob.png And we want to be sure the dir /tmp/toto/toto2/ will really exists so we can copy it. Try to make if needed

Parameters:
  • root (str) – root directory
  • path (str) – path to verify
Returns:

True on success, False otherwise

Return type:

bool

alignak.util.filter_any(name)[source]

Filter for host Filter nothing

Parameters:name (str) – name to filter
Returns:Filter
Return type:bool
alignak.util.filter_host_by_bp_rule_label(label)[source]

Filter for host Filter on label

Parameters:label (str) – label to filter
Returns:Filter
Return type:bool
alignak.util.filter_host_by_group(group)[source]

Filter for host Filter on group

Parameters:group (str) – group name to filter
Returns:Filter
Return type:bool
alignak.util.filter_host_by_name(name)[source]

Filter for host Filter on name

Parameters:name (str) – name to filter
Returns:Filter
Return type:bool
alignak.util.filter_host_by_regex(regex)[source]

Filter for host Filter on regex

Parameters:regex (str) – regex to filter
Returns:Filter
Return type:bool
alignak.util.filter_host_by_tag(tpl)[source]

Filter for host Filter on tag

Parameters:tpl (str) – tag to filter
Returns:Filter
Return type:bool
alignak.util.filter_none(name)[source]

Filter for host Filter all

Parameters:name (str) – name to filter
Returns:Filter
Return type:bool
alignak.util.filter_service_by_bp_rule_label(label)[source]

Filter for service Filter on label

Parameters:label (str) – label to filter
Returns:Filter
Return type:bool
alignak.util.filter_service_by_host_bp_rule_label(label)[source]

Filter for service Filter on label

Parameters:label (str) – label to filter
Returns:Filter
Return type:bool
alignak.util.filter_service_by_host_name(host_name)[source]

Filter for service Filter on host_name

Parameters:host_name (str) – host_name to filter
Returns:Filter
Return type:bool
alignak.util.filter_service_by_host_tag_name(tpl)[source]

Filter for service Filter on tag

Parameters:tpl (str) – tag to filter
Returns:Filter
Return type:bool
alignak.util.filter_service_by_hostgroup_name(group)[source]

Filter for service Filter on hostgroup

Parameters:group (str) – hostgroup to filter
Returns:Filter
Return type:bool
alignak.util.filter_service_by_name(name)[source]

Filter for service Filter on name

Parameters:name (str) – name to filter
Returns:Filter
Return type:bool
alignak.util.filter_service_by_regex_host_name(regex)[source]

Filter for service Filter on regex host_name

Parameters:regex (str) – regex to filter
Returns:Filter
Return type:bool
alignak.util.filter_service_by_regex_name(regex)[source]

Filter for service Filter on regex

Parameters:regex (str) – regex to filter
Returns:Filter
Return type:bool
alignak.util.filter_service_by_servicegroup_name(group)[source]

Filter for service Filter on group

Parameters:group (str) – group to filter
Returns:Filter
Return type:bool
alignak.util.format_t_into_dhms_format(timestamp)[source]

Convert an amount of second into day, hour, min and sec

Parameters:timestamp (int) – seconds
Returns:‘Ad Bh Cm Ds’
Return type:str
>>> format_t_into_dhms_format(456189)
'5d 6h 43m 9s'
>>> format_t_into_dhms_format(3600)
'0d 1h 0m 0s'
alignak.util.from_bool_to_int(boolean)[source]

Convert a bool to a int representation

Parameters:boolean (bool) – bool to convert
Returns:if boolean 1 ,else 0
Return type:int
alignak.util.from_bool_to_string(boolean)[source]

Convert a bool to a string representation

Parameters:boolean (bool) – bool to convert
Returns:if boolean ‘1’ ,else ‘0’
Return type:str
alignak.util.from_float_to_int(val)[source]

Convert float to int

Parameters:val (float) – value to convert
Returns:int(val)
Return type:int
alignak.util.from_list_to_split(val)[source]

Convert list into a comma separated string

Parameters:val – value to convert
Returns:comma separated string
Return type:str
alignak.util.generate_key_value_sequences(entry, default_value)[source]

Parse a key value config entry (used in duplicate foreach)

If we have a key that look like [X-Y] we will expand it into Y-X+1 keys

Parameters:
  • entry (str) – The config line to be parsed.
  • default_value (str) – The default value to be used when none is available.
Returns:

a generator yielding dicts with ‘KEY’ & ‘VALUE’ & ‘VALUE1’ keys, with eventual others ‘VALUEx’ (x 1 -> N) keys.

>>> rsp = list(generate_key_value_sequences("var$(/var)$,root $(/)$"))
>>> import pprint
>>> pprint.pprint(rsp)
[{'KEY': 'var', 'VALUE': '/var', 'VALUE1': '/var'},
 {'KEY': 'root', 'VALUE': '/', 'VALUE1': '/'}]
alignak.util.get_customs_keys(dic)[source]

Get a list of keys of the custom dict without the first char

Used for macros (_name key)

Parameters:dic (dict) – dict to parse
Returns:list of keys
Return type:list
alignak.util.get_customs_values(dic)[source]

Wrapper for values() method

Parameters:dic (dict) – dict
Returns:dic.values
Return type:

TODO: Remove it?

alignak.util.get_day(timestamp)[source]

Get timestamp of the beginning of the day (local) given by timestamp

Parameters:timestamp (int) – time to get day from
Returns:timestamp
Return type:int

TODO: Missing timezone

alignak.util.get_end_of_day(year, month_id, day)[source]

Get the timestamp of the end (local) of a specific day

Parameters:
  • year (int) – date year
  • month_id (int) – date month (int)
  • day (int) – date day
Returns:

timestamp

Return type:

int

TODO: Missing timezone

alignak.util.get_obj_full_name(obj)[source]

Wrapepr to call obj.get_full_name or obj.get_name

Parameters:obj (object) – object name
Returns:object name
Return type:str
alignak.util.get_obj_name(obj)[source]

Get object name (call get_name) if not a string

Parameters:obj (object) – obj we wan the name
Returns:object name
Return type:str
alignak.util.get_obj_name_two_args_and_void(obj, value)[source]

Get value name (call get_name) if not a string

Parameters:
  • obj (object) – Not used
  • value – value to name
Returns:

value name

Return type:

str

alignak.util.get_sec_from_morning(timestamp)[source]

Get the numbers of seconds elapsed since the beginning of the day (local) given by timestamp

Parameters:timestamp (int) – time to get amount of second from
Returns:timestamp
Return type:int

TODO: Missing timezone

alignak.util.get_start_of_day(year, month_id, day)[source]

Get the timestamp of the beginning (local) of a specific day

Parameters:
  • year (int) – date year
  • month_id (int) – date month (int)
  • day (int) – date day
Returns:

timestamp

Return type:

float

TODO: Missing timezone

alignak.util.get_wday(timestamp)[source]

Get week day from date

Parameters:timestamp (int) – timestamp date
Returns:weekday (0-6)
Return type:int

TODO: Missing timezone

alignak.util.is_complex_expr(expr)[source]

Check if expression in complex

Parameters:expr (str) – expression to parse
Returns:True if ‘(‘, ‘)’, ‘&’, ‘|’, ‘!’ or ‘*’ are in expr
Return type:bool
alignak.util.jsonify_r(obj)[source]

Convert an object into json (recursively on attribute)

Parameters:obj (object) – obj to jsonify
Returns:json representation of obj
Return type:dict
alignak.util.list_split(val, split_on_coma=True)[source]

Try to split a each member of a list with comma separator. If we don’t have to split just return val

Parameters:
  • val – value to split
  • split_on_coma (bool) –
Returns:

list with splitted member on comma

Return type:

list

>>> list_split(['a,b,c'], False)
['a,b,c']
>>> list_split(['a,b,c'])
['a', 'b', 'c']
>>> list_split('')
[]
alignak.util.nighty_five_percent(table)[source]

From a tab, get the avg, min, max for the tab values, but not the lower ones and higher ones that are too distinct than major ones

Parameters:table – list of value to compute
Returns:tuple containing average, min and max value
Return type:tuple
alignak.util.print_date(timestamp)[source]

Get date (local) in asc format from timestamp

example : ‘Thu Jan 1 01:00:00 1970’ (for timestamp=0 in a EUW server)

Parameters:timestamp – timestamp

:type timestamp; int :return: formatted time :rtype: int TODO: Missing timezone

alignak.util.safe_print(*args)[source]

Try to print strings, but if there is an utf8 error, go in simple ascii mode (Like if the terminal do not have en_US.UTF8 as LANG for example)

Parameters:args – args to print
Returns:None
alignak.util.scheduler_no_spare_first(x00, y00)[source]

Compare two satellite link based on spare attribute(scheduler usually)

Parameters:
  • x00 – first link to compare
  • y00 – second link to compare
Returns:

x00 > y00 (1) if x00.spare and not y00.spare, x00 == y00 (0) if both spare, x00 < y00 (-1) else

Return type:

int

alignak.util.sort_by_ids(x00, y00)[source]

Compare x00, y00 base on their id

Parameters:
  • x00 (int) – first elem to compare
  • y00 (int) – second elem to compare
Returns:

x00 > y00 (1) if x00._id > y00._id, x00 == y00 (0) if id equals, x00 < y00 (-1) else

Return type:

int

alignak.util.split_semicolon(line, maxsplit=None)[source]

Split a line on semicolons characters but not on the escaped semicolons

Parameters:
  • line (str) – line to split
  • maxsplit – maximum of split to dot

:type maxsplitL int :return: splitted line :rtype: list

>>> split_semicolon('a,b;c;;g')
['a,b', 'c', '', 'g']
>>> split_semicolon('a,b;c;;g', 2)
['a,b', 'c', ';g']
>>> split_semicolon(r'a,b;c\;;g', 2)
['a,b', 'c;', 'g']
alignak.util.strip_and_uniq(tab)[source]

Strip every element of a list and keep unique values

Parameters:tab (list) – list to strip
Returns:stripped list with unique values
Return type:list
alignak.util.to_best_int_float(val)[source]

Get best type for value between int and float

Parameters:val – value
Returns:int(float(val)) if int(float(val)) == float(val), else float(val)
Return type:int | float
>>> to_best_int_float("20.1")
20.1
>>> to_best_int_float("20.0")
20
>>> to_best_int_float("20")
20
alignak.util.to_bool(val)[source]

Convert value to bool

Parameters:val – value to convert
Returns:True if val == ‘1’ or val == ‘on’ or val == ‘true’ or val == ‘True’, else False
Return type:bool
alignak.util.to_char(val)[source]

Get first character of val (or raise Exception)

Parameters:val – value we get head
Returns:val[0]
Return type:str
alignak.util.to_float(val)[source]

Convert val to float (or raise Exception)

Parameters:val – value to convert
Returns:float(val)
Return type:float
alignak.util.to_hostnames_list(ref, tab)[source]

Convert Host list into a list of host_name

Parameters:
  • ref – Not used
  • tab (list[alignak.objects.host.Host]) – Host list
Returns:

host_name list

Return type:

list

alignak.util.to_int(val)[source]

Convert val to int (or raise Exception)

Parameters:val – value to convert
Returns:int(float(val))
Return type:int
alignak.util.to_list_of_names(ref, tab)[source]

Convert list into a list of element name

Parameters:
  • ref – Not used
  • tab (list) – list to parse
Returns:

list of names

Return type:

list

alignak.util.to_list_string_of_names(ref, tab)[source]

Convert list into a comma separated list of element name

Parameters:
  • ref – Not used
  • tab (list) – list to parse
Returns:

comma separated string of names

Return type:

str

alignak.util.to_name_if_possible(ref, value)[source]

Try to get value name (call get_name method)

Parameters:
  • ref – Not used
  • value (str) – value to name
Returns:

name or ‘’

Return type:

str

alignak.util.to_split(val, split_on_coma=True)[source]

Try to split a string with comma separator. If val is already a list return it If we don’t have to split just return [val] If split gives only [‘’] empty it

Parameters:
  • val – value to split
  • split_on_coma (bool) –
Returns:

splitted value on comma

Return type:

list

>>> to_split('a,b,c')
['a', 'b', 'c']
>>> to_split('a,b,c', False)
['a,b,c']
>>> to_split(['a,b,c'])
['a,b,c']
>>> to_split('')
[]
alignak.util.to_svc_hst_distinct_lists(ref, tab)[source]

create a dict with 2 lists:

* services: all services of the tab
* hosts: all hosts of the tab
Parameters:
  • ref – Not used
  • tab (list) – list of Host and Service
Returns:

dict with hosts and services names

Return type:

dict

alignak.util.unique_value(val)[source]

Get last elem of val if it is a list Else return val Used in parsing, if we set several time a parameter we only take the last one

Parameters:val – val to edit
Returns:single value
Return type:str

TODO: Raise erro/warning instead of silently removing something

alignak.version module

This module provide Alignak current version

alignak.worker module

This module provide Worker class. It is used to spawn new processes in Poller and Reactionner

class alignak.worker.Worker(_id, slave_q, returns_queue, processes_by_worker, mortal=True, timeout=300, max_plugins_output_length=8192, target=None, loaded_into='unknown', http_daemon=None)[source]

This class is used for poller and reactionner to work. The worker is a process launch by theses process and read Message in a Queue (self.s) (slave) They launch the Check and then send the result in the Queue self.m (master) they can die if they do not do anything (param timeout)

add_idletime(time)[source]

Increment idletime

Parameters:time (int) – time to increment in seconds
Returns:None
check_for_system_time_change()[source]

Check if our system time change. If so, change our

Returns:0 if the difference < 900, difference else
Return type:int
do_work(slave_q, returns_queue, control_q)[source]

Main function of the worker. * Get checks * Launch new checks * Manage finished checks

Parameters:
  • slave_q (Queue.Queue) – Global Queue Master->Slave
  • returns_queue (Queue.Queue) – queue managed by manager
  • control_q (Queue.Queue) – Control Queue for the worker
Returns:

None

get_new_checks()[source]

Get new checks if less than nb_checks_max If no new checks got and no check in queue, sleep for 1 sec REF: doc/alignak-action-queues.png (3)

Returns:None
is_alive()[source]

Wrapper for calling is_alive method of the process attribute

Returns:A boolean indicating if the process is alive
Return type:bool
is_killable()[source]

Determine whether a process is killable :

  • process is mortal
  • idletime > timeout
Returns:a boolean indicating if it is killable
Return type:bool
is_mortal()[source]

Accessor to _mortal attribute

Returns:A boolean indicating if the worker is mortal or not.
Return type:bool
join(timeout=None)[source]
Wrapper for calling join method of the process attribute
Parameters:timeout (int) – time to wait for the process to terminate
Returns:None
launch_new_checks()[source]

Launch checks that are in status REF: doc/alignak-action-queues.png (4)

Returns:None
manage_finished_checks()[source]

Check the status of checks if done, return message finished :) REF: doc/alignak-action-queues.png (5)

Returns:None
reset_idle()[source]

Reset idletime (set to 0)

Returns:None
send_message(msg)[source]

Wrapper for calling put method of the _control_q attribute

Parameters:msg (str) – the message to put in queue
Returns:None
set_proctitle()[source]

Set the proctitle of this worker for readability purpose

Returns:None
set_zombie()[source]

Set the process as zombie (mortal to False)

:return:None

start()[source]

Start the worker. Wrapper for calling start method of the process attribute

Returns:None
terminate()[source]

Wrapper for calling terminate method of the process attribute Also close queues (input and output) and terminate queues thread

Returns:None
work(slave_q, returns_queue, control_q)[source]

Wrapper function for work in order to catch the exception to see the real work, look at do_work

Parameters:
  • slave_q (Queue.Queue) – Global Queue Master->Slave
  • returns_queue (Queue.Queue) – queue managed by manager
  • control_q (Queue.Queue) – Control Queue for the worker
Returns:

None

Module contents

Init of Alignak, basically only import version and shinken_hook. This file has to be as small as possible in order to namespace to work.