shinken Package

Diagrams

Simple Acknowledge class diagram :

Inheritance diagram of shinken.acknowledge.Acknowledge

Simple Action class diagram :

Inheritance diagram of shinken.action.__Action, shinken.action.Action, shinken.eventhandler.EventHandler, shinken.notification.Notification, shinken.check.Check

Simple AutoSlots class diagram :

Inheritance diagram of shinken.autoslots.AutoSlots, shinken.singleton.Singleton

Simple BaseModule class diagram :

Inheritance diagram of shinken.basemodule.BaseModule

Simple Borg class diagram :

Inheritance diagram of shinken.borg.Borg, shinken.macroresolver.MacroResolver

Simple Brok class diagram :

Inheritance diagram of shinken.brok.Brok

Simple CherryPyBackend class diagram :

Simple Comment class diagram :

Inheritance diagram of shinken.comment.Comment

Simple ComplexExpressionFactory class diagram :

Inheritance diagram of shinken.complexexpression.ComplexExpressionFactory

Simple ComplexExpressionNode class diagram :

Inheritance diagram of shinken.complexexpression.ComplexExpressionNode

Simple ContactDowntime class diagram :

Inheritance diagram of shinken.contactdowntime.ContactDowntime

Simple Daemon class diagram :

Simple Daterange class diagram :

Inheritance diagram of shinken.daterange.Daterange, shinken.daterange.CalendarDaterange, shinken.daterange.StandardDaterange, shinken.daterange.MonthWeekDayDaterange, shinken.daterange.MonthDateDaterange, shinken.daterange.WeekDayDaterange, shinken.daterange.MonthDayDaterange

Simple DB class diagram :

Inheritance diagram of shinken.db.DB, shinken.db_oracle.DBOracle, shinken.db_mysql.DBMysql, shinken.db_sqlite.DBSqlite

Simple declared class diagram :

Inheritance diagram of shinken.trigger_functions.declared

Simple DependencyNode class diagram :

Inheritance diagram of shinken.dependencynode.DependencyNode

Simple DependencyNodeFactory class diagram :

Inheritance diagram of shinken.dependencynode.DependencyNodeFactory

Simple Dispatcher class diagram :

Inheritance diagram of shinken.dispatcher.Dispatcher

Simple Downtime class diagram :

Inheritance diagram of shinken.downtime.Downtime

Simple DummyCommandCall class diagram :

Inheritance diagram of shinken.commandcall.DummyCommandCall, shinken.commandcall.CommandCall

Simple ExternalCommand class diagram :

Simple ExternalCommandManager class diagram :

Simple Graph class diagram :

Inheritance diagram of shinken.graph.Graph

Simple HTTPClient class diagram :

Simple HTTPDaemon class diagram :

Simple Load class diagram :

Inheritance diagram of shinken.load.Load

Simple Log class diagram :

Inheritance diagram of shinken.log.Log

Simple memoized class diagram :

Inheritance diagram of shinken.memoized.memoized

Simple Message class diagram :

Inheritance diagram of shinken.message.Message

Simple ModulesContext class diagram :

Inheritance diagram of shinken.modulesctx.ModulesContext

Simple ModulesManager class diagram :

Inheritance diagram of shinken.modulesmanager.ModulesManager

Simple ModulePhases class diagram :

Inheritance diagram of shinken.basemodule.ModulePhases

Simple Property class diagram :

Inheritance diagram of shinken.property.Property, shinken.property.UnusedProp, shinken.property.BoolProp, shinken.property.IntegerProp, shinken.property.FloatProp, shinken.property.CharProp, shinken.property.StringProp, shinken.property.PathProp, shinken.property.ConfigPathProp, shinken.property.ListProp, shinken.property.LogLevelProp, shinken.property.DictProp, shinken.property.AddrProp

Simple SatelliteLink class diagram :

Simple Scheduler class diagram :

Simple SortedDict class diagram :

Inheritance diagram of shinken.sorteddict.SortedDict

Simple Timerange class diagram :

Inheritance diagram of shinken.daterange.Timerange

Simple Worker class diagram :

Inheritance diagram of shinken.worker.Worker

Simple WSGIREFBackend class diagram :

Package

shinken Package

acknowledge Module

class shinken.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.

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

action Module

class shinken.action.Action[source]

Bases: shinken.action.__Action

execute__(force_shell=False)[source]
kill__()[source]
shinken.action.no_block_read(output)[source]

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 shinken.autoslots.AutoSlots[source]

Bases: type

basemodule Module

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

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

Bases: object

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

  • load additional configuration objects.
  • recurrently save hosts/services status/perfdata informations in different format.
  • ...
clear_queues(manager)[source]

Release the resources associated to the queues of this instance

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 shinken daemon process and this module process. But clear queues if they were already set before recreating new one.

do_loop_turn()[source]

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

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

get_name()[source]
has(prop)[source]

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

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.

manage_brok(brok)[source]

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

manage_signal(sig, frame)[source]
set_exit_handler(sigs=None)
set_loaded_into(daemon_name)[source]
set_proctitle(name)[source]
set_signal_handler(sigs=None)[source]
start(http_daemon=None)[source]
stop_process()[source]

Request the module process to stop and release it

want_brok(b)[source]
work()

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

class shinken.basemodule.ModulePhases[source]

TODO: Add some comment about this class for the doc

CONFIGURATION = 1
LATE_CONFIGURATION = 2
RETENTION = 8
RUNNING = 4

bin Module

This file is to be imported by every Shinken service component: Arbiter, Scheduler, etc. It just checks for the main requirement of Shinken.

borg Module

class shinken.borg.Borg[source]

Bases: object

Here is the new-style Borg (not much more complex then the “old-style”)

brok Module

class shinken.brok.Brok(type, data)[source]

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

id = 0
my_type = 'brok'
prepare()[source]

check Module

class shinken.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: shinken.action.Action

ODO: Add some comment about this class for the doc

copy_shell()[source]

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

get_id()[source]
get_return_from(c)[source]
is_dependent()[source]
is_launchable(t)[source]
my_type = 'check'
properties = {'check_type': <shinken.property.IntegerProp object at 0x7f91b713d550>, 'exit_status': <shinken.property.IntegerProp object at 0x7f91b713d210>, 'reactionner_tag': <shinken.property.StringProp object at 0x7f91b713d5d0>, 's_time': <shinken.property.FloatProp object at 0x7f91b713d4d0>, 'check_time': <shinken.property.IntegerProp object at 0x7f91b713d410>, 'long_output': <shinken.property.StringProp object at 0x7f91b713d2d0>, 'state': <shinken.property.IntegerProp object at 0x7f91b713d250>, 'internal': <shinken.property.BoolProp object at 0x7f91b713d650>, 'u_time': <shinken.property.FloatProp object at 0x7f91b713d490>, 'env': <shinken.property.StringProp object at 0x7f91b713d610>, 'ref': <shinken.property.IntegerProp object at 0x7f91b713d310>, 'from_trigger': <shinken.property.BoolProp object at 0x7f91b713d710>, 'status': <shinken.property.StringProp object at 0x7f91b713d1d0>, 'execution_time': <shinken.property.FloatProp object at 0x7f91b713d450>, 'worker': <shinken.property.StringProp object at 0x7f91b713d6d0>, 't_to_go': <shinken.property.IntegerProp object at 0x7f91b713d350>, 'module_type': <shinken.property.StringProp object at 0x7f91b713d690>, 'dep_check': <shinken.property.StringProp object at 0x7f91b713d3d0>, '_in_timeout': <shinken.property.BoolProp object at 0x7f91b713d190>, 'type': <shinken.property.StringProp object at 0x7f91b713d150>, 'depend_on': <shinken.property.StringProp object at 0x7f91b713d390>, 'is_a': <shinken.property.StringProp object at 0x7f91b713d0d0>, 'poller_tag': <shinken.property.StringProp object at 0x7f91b713d590>, 'output': <shinken.property.StringProp object at 0x7f91b713d290>, 'perf_data': <shinken.property.StringProp object at 0x7f91b713d510>}
set_type_active()[source]
set_type_passive()[source]

commandcall Module

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

Bases: shinken.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

get_name()[source]
id = 0
is_valid()[source]
late_linkify_with_command(commands)[source]
module_type
my_type = 'CommandCall'
poller_tag
properties = {'poller_tag': <shinken.property.StringProp object at 0x7f91b73ee550>, 'reactionner_tag': <shinken.property.StringProp object at 0x7f91b73fb210>, 'valid': <shinken.property.BoolProp object at 0x7f91b73fbc50>, 'call': <shinken.property.StringProp object at 0x7f91b7afd510>, 'enable_environment_macros': <shinken.property.BoolProp object at 0x7f91b6e1c310>, 'timeout': <shinken.property.IntegerProp object at 0x7f91b7409f90>, 'late_relink_done': <shinken.property.BoolProp object at 0x7f91b6e1c6d0>, 'command': <shinken.property.StringProp object at 0x7f91b73ee950>, 'args': <shinken.property.StringProp object at 0x7f91b73fbbd0>, 'module_type': <shinken.property.StringProp object at 0x7f91b73fb090>}
reactionner_tag
timeout
valid
class shinken.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 :)

comment Module

class shinken.comment.Comment(ref, persistent, author, comment, comment_type, entry_type, source, expires, expire_time)[source]
id = 1
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}

complexexpression Module

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

Bases: object

eval_cor_pattern(pattern)[source]
find_object(pattern)[source]
class shinken.complexexpression.ComplexExpressionNode[source]

Bases: object

is_valid()[source]
resolve_elements()[source]

contactdowntime Module

class shinken.contactdowntime.ContactDowntime(ref, start_time, end_time, author, comment)[source]
cancel()[source]
check_activation()[source]
enter()[source]
exit()[source]
id = 1
in_scheduled_downtime()[source]
properties = {'comment': None, 'author': None, 'start_time': None, 'is_in_effect': None, 'end_time': None, 'can_be_deleted': None}

daemon Module

daterange Module

class shinken.daterange.CalendarDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: shinken.daterange.Daterange

get_start_and_end_time(ref=None)[source]
class shinken.daterange.Daterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]
get_min_from_t(t)[source]
get_min_sec_from_morning()[source]
get_min_sec_out_from_morning()[source]
classmethod get_month_by_id(id)[source]
classmethod get_month_id(month)[source]
get_next_future_timerange_invalid(t)[source]
get_next_future_timerange_valid(t)[source]
get_next_invalid_day(t)[source]
get_next_invalid_time_from_t(t)[source]
get_next_valid_day(t)[source]
get_next_valid_time_from_t(t)[source]
get_start_and_end_time(ref=None)[source]
classmethod get_weekday_by_id(id)[source]
classmethod get_weekday_id(weekday)[source]
is_correct()[source]
is_time_day_invalid(t)[source]
is_time_day_valid(t)[source]
is_time_valid(t)[source]
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}
weekdays = {'monday': 0, 'tuesday': 1, 'friday': 4, 'wednesday': 2, 'thursday': 3, 'sunday': 6, 'saturday': 5}
class shinken.daterange.MonthDateDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: shinken.daterange.Daterange

get_start_and_end_time(ref=None)[source]
class shinken.daterange.MonthDayDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: shinken.daterange.Daterange

get_start_and_end_time(ref=None)[source]
class shinken.daterange.MonthWeekDayDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: shinken.daterange.Daterange

get_start_and_end_time(ref=None)[source]
is_correct()[source]
class shinken.daterange.StandardDaterange(day, other)[source]

Bases: shinken.daterange.Daterange

get_start_and_end_time(ref=None)[source]
is_correct()[source]
class shinken.daterange.Timerange(entry)[source]
get_first_sec_out_from_morning()[source]
get_sec_from_morning()[source]
is_correct()[source]
is_time_valid(t)[source]
class shinken.daterange.WeekDayDaterange(syear, smon, smday, swday, swday_offset, eyear, emon, emday, ewday, ewday_offset, skip_interval, other)[source]

Bases: shinken.daterange.Daterange

get_start_and_end_time(ref=None)[source]
shinken.daterange.find_day_by_offset(year, month, offset)[source]
shinken.daterange.find_day_by_weekday_offset(year, month, weekday, offset)[source]

db Module

class shinken.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)

create_update_query(table, data, where_data)[source]

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

fetchall()[source]

Get all entry

fetchone()[source]

Just get an entry

stringify(val)[source]

Get a unicode from a value

db_mysql Module

class shinken.db_mysql.DBMysql(host, user, password, database, character_set, table_prefix='', port=3306)[source]

Bases: shinken.db.DB

DBMysql is a MySQL access database class

connect_database()[source]

Create the database connection TODO: finish (begin :) ) error catch and conf parameters... Import to catch exception

execute_query(query, do_debug=False)[source]

Just run the query TODO: finish catch

db_oracle Module

class shinken.db_oracle.DBOracle(user, password, database, table_prefix='')[source]

Bases: shinken.db.DB

Manage connection and query execution against Oracle databases.

connect_database()[source]

Create the database connection TODO: finish (begin :) ) error catch and conf parameters...

execute_query(query)[source]

Execute a query against an Oracle database.

db_sqlite Module

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

Bases: shinken.db.DB

DBSqlite is a sqlite access database class

connect_database()[source]

Create the database connection

execute_query(query)[source]

Just run the query

dependencynode Module

class shinken.dependencynode.DependencyNode[source]

Bases: object

get_complex_and_node_state()[source]
get_complex_node_state()[source]
get_complex_or_node_state()[source]
get_complex_xof_node_state()[source]
get_reverse_state(state)[source]
get_simple_node_state()[source]
get_state()[source]
is_valid()[source]
list_all_elements()[source]
switch_zeros_of_values()[source]
class shinken.dependencynode.DependencyNodeFactory(bound_item)[source]

Bases: object

eval_complex_cor_pattern(pattern, hosts, services, running=False)[source]
eval_cor_pattern(pattern, hosts, services, running=False)[source]
eval_simple_cor_pattern(pattern, hosts, services, running=False)[source]
eval_xof_pattern(node, pattern)[source]
expand_expression(pattern, hosts, services, running=False)[source]
find_object(pattern, hosts, services)[source]
get_host_filters(expr)[source]
get_srv_host_filters(expr)[source]
get_srv_service_filters(expr)[source]
host_flags = 'grlt'
service_flags = 'grl'

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 shinken.dispatcher.Dispatcher(conf, arbiter)[source]
check_alive()[source]
check_bad_dispatch()[source]
check_dispatch()[source]
dispatch()[source]
get_scheduler_ordered_list(r)[source]

downtime Module

class shinken.downtime.Downtime(ref, start_time, end_time, fixed, trigger_id, duration, author, comment)[source]
add_automatic_comment()[source]
cancel()[source]
del_automatic_comment()[source]
enter()[source]
exit()[source]
fill_data_brok_from(data, brok_type)[source]
get_initial_status_brok()[source]
id = 1
in_scheduled_downtime()[source]
properties = {'comment': <shinken.property.StringProp object at 0x7f91b780f750>, 'entry_time': <shinken.property.IntegerProp object at 0x7f91b780f550>, 'start_time': <shinken.property.IntegerProp object at 0x7f91b780f5d0>, 'is_in_effect': <shinken.property.BoolProp object at 0x7f91b780f790>, 'has_been_triggered': <shinken.property.BoolProp object at 0x7f91b780f7d0>, 'trigger_id': <shinken.property.IntegerProp object at 0x7f91b780f650>, 'duration': <shinken.property.IntegerProp object at 0x7f91b780f610>, 'author': <shinken.property.StringProp object at 0x7f91b780f710>, 'can_be_deleted': <shinken.property.BoolProp object at 0x7f91b780f810>, 'activate_me': <shinken.property.StringProp object at 0x7f91b780f4d0>, 'real_end_time': <shinken.property.IntegerProp object at 0x7f91b780f6d0>, 'end_time': <shinken.property.IntegerProp object at 0x7f91b780f690>, 'fixed': <shinken.property.BoolProp object at 0x7f91b780f590>}
trigger_me(other_downtime)[source]

easter Module

shinken.easter.dark()[source]
.-.

|_:_|

/(_Y_)

( /M/ )

‘. _.’-/’-‘-‘._
‘: _/.–’[[[[]’–._
‘: /_’ : |::”| : ‘.\
‘: // ./ |oUU| .’ :
‘: _:’..’ \_|___|_/ : :|
‘:. .’ |_[___]_| :.’:
[::\ | : | | : ; : \
‘-‘ /’.| |.’ .;.’ | |_ ‘-‘ : | | .: : | | | | ‘. : | / :. .; |

/ | | :__/ : \

| | : | | ||

/ : : |: / |__| /|

snd | : : :_/_| /’._\ ‘–|_
/___.-/_|-‘
‘-‘
shinken.easter.episode_iv()[source]
shinken.easter.get_coffee()[source]
(
) (
___...(——-)-....___

.-“” ) ( “”-.

.-‘``’|-._ ) _.-|

/ .–.| “”—...........—”“ |

/ / | | | | | |

| |
| |
``| | _/ / /

(__/ /

_..—”“` /`“”—.._

.-‘ / ‘-.

: `-.__ __.-‘ : : ) “”—...—”” ( :

‘._ “–...___...–” _.’
jgs “”–..__ __..–”“/
‘._ “’”—-.....______.....—-“’” _.’
“”–..,,_____ _____,,..–”“
“’”—-“’”
shinken.easter.myip()[source]
shinken.easter.naheulbeuk()[source]
shinken.easter.perdu()[source]

eventhandler Module

class shinken.eventhandler.EventHandler(command, id=None, ref=None, timeout=10, env={}, module_type='fork', reactionner_tag='None')[source]

Bases: shinken.action.Action

check_time
command
copy_shell()[source]
env
execution_time
exit_status
get_id()[source]
get_outputs(out, max_plugins_output_length)[source]
get_return_from(e)[source]
is_a
is_launchable(t)[source]
long_output
module_type
my_type = 'eventhandler'
output
perf_data
properties = {'status': <shinken.property.StringProp object at 0x7f91b7b0d950>, 'module_type': <shinken.property.StringProp object at 0x7f91b7b0dcd0>, 'check_time': <shinken.property.IntegerProp object at 0x7f91b7b0dc90>, 'exit_status': <shinken.property.StringProp object at 0x7f91b7b0d990>, 'execution_time': <shinken.property.FloatProp object at 0x7f91b7b0dad0>, 's_time': <shinken.property.FloatProp object at 0x7f91b7b0db50>, 'worker': <shinken.property.StringProp object at 0x7f91b7b0dd10>, 'timeout': <shinken.property.IntegerProp object at 0x7f91b7b0dc50>, 't_to_go': <shinken.property.StringProp object at 0x7f91b7b0da50>, 'is_a': <shinken.property.StringProp object at 0x7f91b7a0f710>, 'long_output': <shinken.property.StringProp object at 0x7f91b7b0da10>, 'reactionner_tag': <shinken.property.StringProp object at 0x7f91b7b0dd50>, 'command': <shinken.property.StringProp object at 0x7f91b7b0da90>, 'u_time': <shinken.property.FloatProp object at 0x7f91b7b0db10>, 'env': <shinken.property.StringProp object at 0x7f91b7b0db90>, 'output': <shinken.property.StringProp object at 0x7f91b7b0d9d0>, '_in_timeout': <shinken.property.StringProp object at 0x7f91b7b0d910>, 'sched_id': <shinken.property.IntegerProp object at 0x7f91b7b0dc10>, 'type': <shinken.property.StringProp object at 0x7f91b7b0d8d0>, 'perf_data': <shinken.property.StringProp object at 0x7f91b7b0dbd0>}
reactionner_tag
s_time
sched_id
status
t_to_go
timeout
type
u_time
worker

external_command Module

graph Module

class shinken.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?

add_edge(from_node, to_node)[source]
add_node(node)[source]
add_nodes(nodes)[source]
dfs_get_all_childs(root)[source]
get_accessibility_packs()[source]
loop_check()[source]

http_client Module

http_daemon Module

load Module

class shinken.load.Load(m=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 m: the average for m minutes. The val is the initial value. It’s better if it’s 0 but you can choose.

get_load()[source]
update_load(new_val, forced_interval=None)[source]

log Module

class shinken.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 shinken.log.ColorStreamHandler(stream=None)[source]

Bases: logging.StreamHandler

emit(record)[source]
class shinken.log.Log(name='Shinken', level=0)[source]

Bases: logging.Logger

Shinken 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

load_obj(object, name_=None)[source]

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

register_local_log(path, level=None)[source]

The shinken 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

setLevel(level)[source]

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

set_human_format(on=True)[source]

Set the output as human format.

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

shinken.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 Shinken logs and another for monitoring data

macroresolver Module

class shinken.macroresolver.MacroResolver[source]

Bases: shinken.borg.Borg

Please Add a Docstring to describe the class here

get_env_macros(data)[source]
init(conf)[source]
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'
resolve_command(com, data)[source]
resolve_simple_macros_in_string(c_line, data, args=None)[source]

memoized Module

class shinken.memoized.memoized(func)[source]

Bases: object

Decorator that caches a function’s return value each time it is called. If called later with the same arguments, the cached value is returned, and not re-evaluated.

message Module

class shinken.message.Message(id, type, data=None, source=None)[source]

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

get_data()[source]
get_from()[source]
get_type()[source]
my_type = 'message'
str()[source]

modulesctx Module

class shinken.modulesctx.ModulesContext[source]

Bases: object

get_module(name)[source]
get_modulesdir()[source]
set_modulesdir(modulesdir)[source]

modulesmanager Module

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

Bases: object

This class is use to manage modules and call callback

check_alive_instances()[source]
clear_instances(insts=None)[source]
get_external_from_queues()[source]
get_external_instances(phase=None)[source]
get_external_to_queues()[source]
get_instances()[source]
get_internal_instances(phase=None)[source]
load()[source]
load_and_init()[source]
load_manager(manager)[source]
remove_instance(inst)[source]
set_max_queue_size(max_queue_size)[source]
set_modules(modules)[source]
set_to_restart(inst)[source]
start_external_instances(late_start=False)[source]
stop_all()[source]
try_instance_init(inst, late_start=False)[source]
try_to_restart_deads()[source]
shinken.modulesmanager.uniform_module_type(s)[source]

notification Module

class shinken.notification.Notification(type='PROBLEM', status='scheduled', command='UNSET', command_call=None, ref=None, contact=None, t_to_go=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=0)[source]

Bases: shinken.action.Action

Please Add a Docstring to describe the class here

ack_author
ack_data
already_start_escalations
check_time
command
command_call
contact
contact_name
contacts_notified
copy_shell()[source]
creation_time
enable_environment_macros
end_time
env
escalated
execution_time
exit_status
fill_data_brok_from(data, brok_type)[source]
get_id()[source]
get_initial_status_brok()[source]
get_return_from(n)[source]
host_name
is_a
is_administrative()[source]
is_launchable(t)[source]
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': <shinken.property.StringProp object at 0x7f91b73f4610>, 'status': <shinken.property.StringProp object at 0x7f91b73f4a10>, 'u_time': <shinken.property.FloatProp object at 0x7f91b73f48d0>, 'ack_data': <shinken.property.StringProp object at 0x7f91b73f4710>, 'execution_time': <shinken.property.FloatProp object at 0x7f91b73f4890>, 'creation_time': <shinken.property.IntegerProp object at 0x7f91b73f4c50>, 'start_time': <shinken.property.StringProp object at 0x7f91b73f44d0>, 's_time': <shinken.property.FloatProp object at 0x7f91b73f4910>, 'worker': <shinken.property.StringProp object at 0x7f91b73f4bd0>, 'command_call': <shinken.property.StringProp object at 0x7f91b73f4850>, 'notif_nb': <shinken.property.IntegerProp object at 0x7f91b73f49d0>, 'reactionner_tag': <shinken.property.StringProp object at 0x7f91b73f4c10>, 'module_type': <shinken.property.StringProp object at 0x7f91b73f4b90>, 't_to_go': <shinken.property.IntegerProp object at 0x7f91b73f4a50>, 'service_description': <shinken.property.StringProp object at 0x7f91b73f45d0>, 'notification_type': <shinken.property.IntegerProp object at 0x7f91b73f4490>, 'contact_name': <shinken.property.StringProp object at 0x7f91b73f4550>, 'sched_id': <shinken.property.IntegerProp object at 0x7f91b73f4ad0>, 'timeout': <shinken.property.IntegerProp object at 0x7f91b73f4b10>, 'exit_status': <shinken.property.IntegerProp object at 0x7f91b73f4810>, 'check_time': <shinken.property.IntegerProp object at 0x7f91b73f4b50>, 'contacts_notified': <shinken.property.StringProp object at 0x7f91b73f4790>, 'ack_author': <shinken.property.StringProp object at 0x7f91b73f46d0>, 'enable_environment_macros': <shinken.property.BoolProp object at 0x7f91b73f4c90>, 'escalated': <shinken.property.BoolProp object at 0x7f91b73f4750>, 'is_a': <shinken.property.StringProp object at 0x7f91b73f43d0>, 'state': <shinken.property.StringProp object at 0x7f91b73f4650>, 'contact': <shinken.property.StringProp object at 0x7f91b73f4950>, 'command': <shinken.property.StringProp object at 0x7f91b73f4a90>, 'end_time': <shinken.property.StringProp object at 0x7f91b73f4510>, 'env': <shinken.property.StringProp object at 0x7f91b73f47d0>, 'output': <shinken.property.StringProp object at 0x7f91b73f4690>, '_in_timeout': <shinken.property.BoolProp object at 0x7f91b73f4990>, 'already_start_escalations': <shinken.property.StringProp object at 0x7f91b73f4cd0>, 'type': <shinken.property.StringProp object at 0x7f91b73f4450>, 'host_name': <shinken.property.StringProp object at 0x7f91b73f4590>}
reactionner_tag
reason_type
s_time
sched_id
service_description
start_time
state
status
t_to_go
timeout
type
u_time
worker

property Module

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

Bases: shinken.property.Property

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

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

class shinken.property.BoolProp(default=<object object>, 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, merging='uniq')[source]

Bases: shinken.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]
class shinken.property.IntegerProp(default=<object object>, 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, merging='uniq')[source]

Bases: shinken.property.Property

Please Add a Docstring to describe the class here

pythonize(val)[source]
class shinken.property.FloatProp(default=<object object>, 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, merging='uniq')[source]

Bases: shinken.property.Property

Please Add a Docstring to describe the class here

pythonize(val)[source]
class shinken.property.CharProp(default=<object object>, 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, merging='uniq')[source]

Bases: shinken.property.Property

Please Add a Docstring to describe the class here

pythonize(val)[source]
class shinken.property.StringProp(default=<object object>, 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, merging='uniq')[source]

Bases: shinken.property.Property

Please Add a Docstring to describe the class here

pythonize(val)[source]
class shinken.property.ListProp(default=<object object>, 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, merging='uniq')[source]

Bases: shinken.property.Property

Please Add a Docstring to describe the class here

pythonize(val)[source]

satellite Module

scheduler Module

singleton Module

class shinken.singleton.Singleton(name, bases, dict)[source]

Bases: type

The classic Singleton class. So all instance of this class will be the same instance in fact.

sorteddict Module

class shinken.sorteddict.SortedDict(*args, **kwargs)[source]

Bases: dict

Dictionary with sorted keys.

The interface is similar to the ordinary dict’s one, but: * methods: __repr__(), __str__(), __iter__(), iterkeys(), itervalues(),

iteritems(), keys(), values(), items() and popitem() – return results taking into consideration sorted keys order;
  • new methods: largest_key(), largest_item(), smallest_key(), smallest_item() added.
clear() → None. Remove all items from D.[source]
copy() → a shallow copy of D (still as a SortedDict).[source]
classmethod fromkeys(S[, v]) → New dict with keys from S and values equal to v.[source]

v defaults to None.

items() → a list of (key, value) pairs sorted by keys[source]

(add reverse=True for reverse ordering).

iteritems() → an iterator over (key, value) pairs sorted by keys[source]

(add reverse=True for reverse ordering).

iterkeys(reverse=False)

D.__iter__() <==> iter(D) <==> D.iterkeys() -> an iterator over sorted keys (add reverse=True for reverse ordering).

itervalues() → an iterator over values sorted by keys[source]

(add reverse=True for reverse ordering).

keys() → a sorted list of keys[source]

(add reverse=True for reverse ordering).

largest_item() → a (key, value) pair with the largest key;[source]

raise KeyError if D is empty.

largest_key() → the largest key; raise KeyError if D is empty.[source]
pop(k[, d]) → v, remove specified key and return the corresponding value.[source]

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v). Remove and return a (key, value) pair with[source]

the largest key; raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D[source]
smallest_item() → a (key, value) pair with the smallest key;[source]

raise KeyError if D is empty.

smallest_key() → the smallest key; raise KeyError if D is empty.[source]
update([E, ]**F) → None. Update D from dict/iterable E and F.[source]

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → a list of values sorted by keys[source]

(add reverse=True for reverse ordering).

shinken.sorteddict.dictdoc(method)[source]

A decorator making reuse of the ordinary dict’s docstrings more concise.

trigger_functions Module

class shinken.trigger_functions.declared(f)[source]

Bases: object

Decorator to add function in trigger environnement

util Module

shinken.util.alive_then_spare_then_deads(x, y)[source]
shinken.util.apply_change_recursive_pattern_change(s, rule)[source]
shinken.util.expand_with_macros(ref, value)[source]
shinken.util.expand_xy_pattern(pattern)[source]
shinken.util.expect_file_dirs(root, path)[source]
shinken.util.filter_any(name)[source]
shinken.util.filter_host_by_bp_rule_label(label)[source]
shinken.util.filter_host_by_group(group)[source]
shinken.util.filter_host_by_name(name)[source]
shinken.util.filter_host_by_regex(regex)[source]
shinken.util.filter_host_by_template(tpl)[source]
shinken.util.filter_none(name)[source]
shinken.util.filter_service_by_bp_rule_label(label)[source]
shinken.util.filter_service_by_host_bp_rule_label(label)[source]
shinken.util.filter_service_by_host_name(host_name)[source]
shinken.util.filter_service_by_host_template_name(tpl)[source]
shinken.util.filter_service_by_hostgroup_name(group)[source]
shinken.util.filter_service_by_name(name)[source]
shinken.util.filter_service_by_regex_host_name(regex)[source]
shinken.util.filter_service_by_regex_name(regex)[source]
shinken.util.filter_service_by_servicegroup_name(group)[source]
shinken.util.format_t_into_dhms_format(t)[source]
shinken.util.from_bool_to_int(b)[source]
shinken.util.from_bool_to_string(b)[source]
shinken.util.from_float_to_int(val)[source]
shinken.util.from_list_to_split(val)[source]
shinken.util.get_customs_keys(d)[source]
shinken.util.get_customs_values(d)[source]
shinken.util.get_day(t)[source]
shinken.util.get_end_of_day(year, month_id, day)[source]
shinken.util.get_key_value_sequence(entry, default_value=None)[source]
shinken.util.get_obj_full_name(obj)[source]
shinken.util.get_obj_name(obj)[source]
shinken.util.get_obj_name_two_args_and_void(obj, value)[source]
shinken.util.get_sec_from_morning(t)[source]
shinken.util.get_start_of_day(year, month_id, day)[source]
shinken.util.get_wday(t)[source]
shinken.util.got_generation_rule_pattern_change(xy_couples)[source]
shinken.util.jsonify_r(obj)[source]
shinken.util.nighty_five_percent(t)[source]
shinken.util.print_date(t)[source]
shinken.util.safe_print(*args)[source]
shinken.util.scheduler_no_spare_first(x, y)[source]
shinken.util.sort_by_ids(x, y)[source]
shinken.util.split_semicolon(line, maxsplit=None)[source]

Split a line on semicolons characters but not on the escaped semicolons

shinken.util.strip_and_uniq(tab)[source]
shinken.util.to_best_int_float(val)[source]
shinken.util.to_bool(val)[source]
shinken.util.to_char(val)[source]
shinken.util.to_float(val)[source]
shinken.util.to_hostnames_list(ref, tab)[source]
shinken.util.to_int(val)[source]
shinken.util.to_list_of_names(ref, tab)[source]
shinken.util.to_list_string_of_names(ref, tab)[source]
shinken.util.to_name_if_possible(ref, value)[source]
shinken.util.to_split(val, split_on_coma=True)[source]
shinken.util.to_svc_hst_distinct_lists(ref, tab)[source]
shinken.util.unique_value(val)[source]

worker Module

class shinken.worker.Worker(id, s, 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]
check_for_system_time_change()[source]
do_work(s, returns_queue, c)[source]
get_new_checks()[source]
id = 0
is_alive()[source]
is_killable()[source]
is_mortal()[source]
join(timeout=None)[source]
launch_new_checks()[source]
manage_finished_checks()[source]
reset_idle()[source]
send_message(msg)[source]
set_proctitle()[source]
set_zombie()[source]
start()[source]
terminate()[source]
work(s, returns_queue, c)[source]