This module is used for common variables in Alignak. Previously some of those variables were linked to a specific class which made no sense.
This module provides CustomModule class. Used to customize a module namespace
Bases: module
Custom module that can be used to customize a module namespace,
example usage:
>>> import sys
>>> assert __name__ == 'custom_module' # required for the import after
>>> class MyCustomModule(CustomModule):
... count = 0
... @property
... def an_attribute(self):
... self.count += 1
... return "hey ! I'm a module attribute but also a property !"
>>> sys.modules[__name__] = MyCustomModule(__name__, globals())
# then, in another module: >>> import custom_module >>> assert custom_module.count == 0 >>> custom_module.an_attribute “hey ! I’m a module attribute but also a property !” >>> assert custom_module.count == 1
datamanager module provide DataManager class : a simple class providing accessor to various Alignak object” Used by module such as Livestatus and Webui
Bases: object
DataManager provide a set of accessor to Alignak objects (host, services) through a regenerator object.
Get all host and all service in a single list
| Returns: | A list containing all host and service |
|---|---|
| Return type: | list |
Get all non managed impacts
| Returns: | A list of host and service |
|---|---|
| Return type: | list |
Get hosts and services with:
| Parameters: | |
|---|---|
| Returns: | A list of host and service |
| Return type: | list |
Get the dependencies tree of a specific host or service up to a specific dept Tree only include non OK state_id
| Parameters: |
|
|---|---|
| Returns: | A dict with the following structure |
{ 'node': obj,
'fathers': [
{'node': Host_Object1, fathers: [...]},
{'node': Host_Object2, fathers: [...]},
]
}
| Return type: | dict |
|---|
Get a specific contact
| Parameters: | name (str) – A contact name |
|---|---|
| Returns: | the Contact object with contact_name=name |
| Return type: | alignak.objects.contact.Contact |
Get a specific contact group
| Parameters: | name (str) – A contactgroup name |
|---|---|
| Returns: | the Contact object with contactgroup_name=name |
| Return type: | alignak.objects.contactgroup.Contactgroup |
Get a specific host from Alignak
| Parameters: | hname (str) – A host name (a casual string) |
|---|---|
| Returns: | the Host object with host_name=hname |
| Return type: | alignak.objects.host.Host |
Get hosts tags sorted by names, and zero size in the end
| Returns: | list of hosts tags |
|---|---|
| Return type: | list |
Get a specific host group
| Parameters: | name (str) – A hostgroup name |
|---|---|
| Returns: | the Contact object with hostgroup_name=name |
| Return type: | alignak.objects.hostgroup.Hostgroup |
Get hostgroups sorted by names, and zero size in the end if selected one, put it in the first place
| Parameters: | selected (str) – A hostgroup name |
|---|---|
| Returns: | A sorted hostgroup list |
| Return type: | list |
Get hosts tagged with a specific tag
| Parameters: | name (str) – A tag name |
|---|---|
| Returns: | Hosts list with tag in host tags |
| Return type: | alignak.objects.host.Host |
Get hosts and services with : * business impact > 2 * 0 <= my_own_business_impact <= 2
| Returns: | list of host and services |
|---|---|
| Return type: | list |
Get hosts and services with : * not OK state * business impact > 2 * is_impact flag true
| Returns: | list of host and services |
|---|---|
| Return type: | list |
Get the number of hosts and services with: * business impact > 2 * is_impact flag true * state_id equals 1 or 2 (warning or critical state) Used for aggregation
| Returns: | An integer representing the number of hosts and services fulfilling the above condition :rtype: int |
|---|
Get the number of problems (host or service) including acknowledged ones for a specific user
| Parameters: | user (str) – A contact (Ui user maybe) |
|---|---|
| Returns: | A list of host and service with acknowledged problem for contact=user |
| Return type: | list |
Get the number of hosts and services (sum)
| Returns: | An integer representing the number of items |
|---|---|
| Return type: | int |
Get the number of impacts (host or service)
| Returns: | An integer representing the number of impact items |
|---|---|
| Return type: | int |
Get the number of problems (host or service)
| Returns: | An integer representing the number of non acknowledged problems |
|---|---|
| Return type: | int |
Get the worst state of all hosts and services with: * is_impact flag true * state_id equals 1 or 2 (warning or critical state) Used for aggregation
| Returns: | An integer between 0 and 2 |
|---|---|
| Return type: | int |
Get the worst state of all hosts and service with: * business impact > 2 * is_impact flag true * state_id equals 1 or 2 (warning or critical state) Used for aggregation
| Returns: | An integer between 0 and 2 |
|---|---|
| Return type: | int |
Get the percentage of hosts with : * is_impact flag false * not OK state
| Returns: | An integer representing the percentage of hosts fulfilling the above condition |
|---|---|
| Return type: | int |
Get the percentage of services with : * is_impact flag false * not OK state
| Returns: | An integer representing the percentage of services fulfilling the above condition |
|---|---|
| Return type: | int |
Get all problems with the most recent before
| Returns: | A list of host and service |
|---|---|
| Return type: | list |
Get program start time
| Returns: | Timestamp representing start time |
|---|---|
| Return type: | int | None |
Get a specific realm, but this will return None always
| Parameters: | name (str) – A realm name |
|---|---|
| Returns: | the Realm object with realm_name=name (that’s not true) |
| Return type: | alignak.objects.realm.Realm | None |
TODO: Remove this
| Parameters: | |
|---|---|
| Returns: | the Service object with host_name=hname and service_description=sdec |
| Return type: | alignak.objects.service.Service |
Get services tags sorted by names, and zero size in the end
| Returns: | list of services tags |
|---|---|
| Return type: | list |
Get a specific service group
| Parameters: | name (str) – A servicegroup name |
|---|---|
| Returns: | the Contact object with servicegroup_name=name |
| Return type: | alignak.objects.servicegroup.Servicegroup |
Get all servicegroups
| Returns: | List of all servicegroups |
|---|---|
| Return type: | list |
Get the list of services with : * a state_id != 0 (not OK state) * linked to the same host for a given service.
| Parameters: | obj (alignak.objects.schedulingitem.SchedulingItem) – service we want to get non OK services linked to its host |
|---|---|
| Returns: | A service list with state_id != 0 |
| Return type: | list |
Set the regenerator attribute
| Parameters: | regenerator (alignak.misc.regenerator.Regenerator) – regenerator object |
|---|---|
| Returns: | None |
Helper functions for some filtering, like for user based
This module lists provide facilities to parse log type Broks. The supported event are listed in the event_type variable
This module provide classes to handle performance data from monitoring plugin output
Class providing a small abstraction for one metric of a Perfdatas class
Class providing performance data extracted from a check output
Wrapper for Util.to_best_int_float Basically cast into float or int and compare value If they are equal then there is no coma so return integer
| Parameters: | val – value to cast |
|---|---|
| Returns: | value casted into int, float or None |
| Return type: | int | float | NoneType |
This module provide Regenerator class used in several Alignak modules to manage and regenerate objects
Bases: object
Class for a Regenerator. It gets broks, and “regenerate” real objects from them
Link all data (objects) in a specific instance
| Parameters: | inst_id (int) – Instance id from a config object |
|---|---|
| Returns: | None |
This can be used by derived classes to compare the data in the brok with the object which will be updated by these data. For example, it is possible to find out in this method whether the state of a host or service has changed.
Replace the command_name by the command object in obj.prop
| Parameters: |
|
|---|---|
| Returns: | None |
Replace the timeperiod_name by the timeperiod object in obj.prop
| Parameters: |
|
|---|---|
| Returns: | None |
Replace the timeperiod_name by the timeperiod object in obj.prop
| Parameters: |
|
|---|---|
| Returns: | None |
Replace the command_name by the command object in obj.prop
| Parameters: |
|
|---|---|
| Returns: | None |
Replace the contact_name by the contact object in obj.prop
| Parameters: |
|
|---|---|
| Returns: | None |
Replace the dict with host and service name by the host or service object in obj.prop
| Parameters: |
|
|---|---|
| Returns: | None |
Replace the host_name by the host object in obj.prop
| Parameters: |
|
|---|---|
| Returns: | None |
Load an external queue for sending messages Basically a from_q setter method.
| Parameters: | from_q (multiprocessing.Queue or Queue.Queue) – queue to set |
|---|---|
| Returns: | None |
Load data from a scheduler
| Parameters: | sched (alignak.scheduler.Scheduler) – the scheduler obj |
|---|---|
| Returns: | None |
Look for a manager function for a brok, and call it
| Parameters: | brok (object) – |
|---|---|
| Returns: | |
| Return type: |
Manage host_check_result brok : Update host object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_timeperiod_status brok : Same as manage_host_check_result_brok
| Returns: | None |
|---|
Manage initial_broker_status brok : Update broker object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_broks_done brok : Call all_done_linking with the instance_id in the brok
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_command_status brok : Update command object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_contact_status brok : Update contact object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_contactgroup_status brok : Update contactgroup object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_host_status brok : Update host object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_hostgroup_status brok : Update hostgroup object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_poller_status brok : Update poller object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_reactionner_status brok : Update reactionner object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_receiver_status brok : Update receiver object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_scheduler_status brok : Update scheduler object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_service_status brok : Update service object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_servicegroup_status brok : Update servicegroup object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage initial_timeperiod_status brok : Update timeperiod object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage program_status brok : Reset objects for the given config id
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new config |
|---|---|
| Returns: | None |
Manage service_check_result brok : Update service object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage service_next_schedule brok : Same as manage_service_check_result_brok A service check update have just arrived, we UPDATE data info with this
| Returns: | None |
|---|
Manage update_broker_status brok : Update broker object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage update_host_status brok : Update host object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage update_poller_status brok : Update poller object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage update_program_status brok : Update config object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage update_reactionner_status brok : Update reactionner object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage update_receiver_status brok : Update receiver object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage update_scheduler_status brok : Update scheduler object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Manage update_service_status brok : Update service object
| Parameters: | brok (alignak.objects.brok.Brok) – Brok containing new data |
|---|---|
| Returns: | None |
Helper functions for some sorting
Sort host and service by impact then state then name
| Parameters: |
|
|---|---|
| Returns: |
|
| Return type: | int |
Sort host and service by last_state_change
| Parameters: |
|
|---|---|
| Returns: |
|
| Return type: | int |
Sort host and service by state then impact then name
| Parameters: |
|
|---|---|
| Returns: |
|
| Return type: | int |
Init of alignak.misc, nothing to do here.