Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix_tmpl_foreach_…
Browse files Browse the repository at this point in the history
…same_host_and_name

Conflicts:
	shinken/objects/service.py
  • Loading branch information
geektophe committed Aug 31, 2015
2 parents 401f983 + 94627cd commit 04ddd4d
Show file tree
Hide file tree
Showing 28 changed files with 899 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ INSTALLED_FILES
.settings
.gitignore
modules/*
.ropeproject
.coverage

# Logs and databases #
######################
Expand Down
22 changes: 22 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
Shinken ChangeLog
########################

2.4.2 - xx/09/2015
-------------------
CORE ENHANCEMENT
Add: Service excludes/includes/overrides extension
Add: Implementation of inital_state

CORE FIXES
Fix: Service Description using duplicate_foreach with only $KEY$ as description
Fix: Service_(includes|excludes) template recursion

2.4.1 - 15/07/2015
-------------------
CORE ENHANCEMENT
Add: Safe Pickle
Add: Better Debian 8 Jessie support

CORE FIXES
Fix: Display_name when using duplicate_foreach
Fix: template definition loop did segfault python
Fix: Service Description inheritance when using several level of inheritance
Fix: cpu looping for receiver

2.4 - 04/05/2015
-------------------
CORE ENHANCEMENT
Expand Down
81 changes: 76 additions & 5 deletions doc/source/07_advanced/objectinheritance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,18 @@ Its syntax is:

It could be summarized as "*For the service bound to me, named ``xxx``, I want the directive ``yyy`` set to ``zzz`` rather tran the inherited value*"

The service description selector (represented by ``xxx`` in the previous example) may be:

A service name (default)
The ``service_description`` of one of the services attached to the host.

``*`` (wildcard)
Means *all the services attached to the host*

A regular expression
A regular expression against the ``service_description`` of the services attached to the host (it has to be prefixed by ``r:``).


Example:

::
Expand All @@ -543,8 +555,22 @@ Example:
...
}
...
define host {
host_name web-back-02
hostgroups web
service_overrides *,notification_options c
...
}
...
define host {
host_name web-back-03
hostgroups web
service_overrides r:^HTTP,notification_options r
...
}
...

In the previous example, we defined only one instance of the HTTP service, and we enforced the service ``notification_options`` for the web servers composing the backend. The final result is the same, but the second example is shorter, and does not require the second service definition.
In the previous example, we defined only one instance of the HTTP service, and we enforced the service ``notification_options`` for some web servers composing the backend. The final result is the same, but the second example is shorter, and does not require the second service definition.

Using packs allows an even shorter configuration.

Expand All @@ -566,6 +592,20 @@ Example:
...
}
...
define host {
use http
host_name web-back-02
service_overrides HTTP,notification_options c
...
}
...
define host {
use http
host_name web-back-03
service_overrides HTTP,notification_options r
...
}
...

In the packs example, the web server from the front-end cluster uses the value defined in the pack, and the one from the backend cluster has its HTTP service (inherited from the HTTP pack also) enforced its ``notification_options`` directive.

Expand Down Expand Up @@ -612,26 +652,57 @@ In this situation, there is several ways to manage the situation:

None of these options are satisfying.

There is a last solution that consists of excluding the corresponding service from the specified host. This may be done using the ``service_excludes directive``.
There is a last solution that consists of excluding the corresponding service from the specified host. This may be done using the ``service_excludes`` directive.

Its syntax is:

::

service_excludes xxx

The service description selector (represented by ``xxx`` in the previous example) may be:

A service name (default)
The ``service_description`` of one of the services attached to the host.

``*`` (wildcard)
Means *all the services attached to the host*

A regular expression
A regular expression against the ``service_description`` of the services attached to the host (it has to be prefixed by ``r:``).

Example:


::

define host {
use web-fromt
use web-front
host_name web-back-01
...
}

define host {
use web-fromt
use web-front
host_name web-back-02 ; The virtual server
service_excludes Management interface
...
}
...
define host {
use web-front
host_name web-back-03 ; The virtual server
service_excludes *
...
}
...
define host {
use web-front
host_name web-back-04 ; The virtual server
service_excludes r^Management
...
}
...


In the case you want the opposite (exclude all except) you can use the service_includes directive
In the case you want the opposite (exclude all except) you can use the ``service_includes`` directive which is its corollary.
6 changes: 5 additions & 1 deletion doc/source/08_configobjects/host.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ parents *host_names*
hostgroups *hostgroup_names*
check_command *command_name*
initial_state [o,d,u]
initial_output *output*
**max_check_attempts** **#**
check_interval #
retry_interval #
Expand Down Expand Up @@ -148,7 +149,10 @@ check_command
This directive is used to specify the *short name* of the :ref:`command <configobjects/command>` that should be used to check if the host is up or down. Typically, this command would try and ping the host to see if it is "alive". The command must return a status of OK (0) or Shinken will assume the host is down. If you leave this argument blank, the host will *not* be actively checked. Thus, Shinken will likely always assume the host is up (it may show up as being in a "PENDING" state in the web interface). This is useful if you are monitoring printers or other devices that are frequently turned off. The maximum amount of time that the notification command can run is controlled by the :ref:`host_check_timeout <configuration/configmain#host_check_timeout>` option.

initial_state
By default Shinken will assume that all hosts are in UP states when in starts. You can override the initial state for a host by using this directive. Valid options are: **o** = UP, **d** = DOWN, and **u** = UNREACHABLE.
By default Shinken will assume that all hosts are in PENDING state when in starts. You can override the initial state for a host by using this directive. Valid options are: **o** = UP, **d** = DOWN, and **u** = UNREACHABLE.

initial_output
As of the initial state, the initial check output may also be overridden by this directive.

max_check_attempts
This directive is used to define the number of times that Shinken will retry the host check command if it returns any state other than an OK state. Setting this value to 1 will cause Shinken to generate an alert without retrying the host check again.
Expand Down
8 changes: 6 additions & 2 deletions doc/source/08_configobjects/service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ servicegroups servicegroup_names
is_volatile [0/1]
**check_command** ***command_name***
initial_state [o,w,u,c]
initial_output *output*
**max_check_attempts** **#**
**check_interval** **#**
**retry_interval** **#**
Expand Down Expand Up @@ -164,13 +165,16 @@ check_command
If at least one of the apaches on servers websrv1 and websrv2 is OK and if the oracle database on dbsrv1 is OK then the rule and thus the service is OK

initial_state
By default Shinken will assume that all services are in OK states when in starts. You can override the initial state for a service by using this directive. Valid options are:
By default Shinken will assume that all services are in PENDING state when in starts. You can override the initial state for a service by using this directive. Valid options are:

* **o** = OK
* **w** = WARNING
* **u** = UNKNOWN
* **c** = CRITICAL.

initial_output
As of the initial state, the initial check output may also be overridden by this directive.

max_check_attempts
This directive is used to define the number of times that Shinken will retry the service check command if it returns any state other than an OK state. Setting this value to 1 will cause Shinken to generate an alert without retrying the service check again.

Expand Down Expand Up @@ -384,7 +388,7 @@ maintenance_period

host_dependency_enabled
This variable may be used to remove the dependency between a service and its parent host. Used for volatile services that need notification related to itself and not depend on the host notifications.

labels
This variable may be used to place arbitrary labels (separated by comma character). Those labels may be used in other configuration objects such as :ref:`business rules <medium/business-rules>` to identify groups of services.

Expand Down
2 changes: 1 addition & 1 deletion for_fedora/systemd/shinken-broker.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=syslog.target
[Service]
Type=forking
ExecStart=/usr/sbin/shinken-broker -d -c /etc/shinken/daemons/brokerd.ini
KillMode=process
KillMode=mixed
TimeoutStopSec=3

[Install]
Expand Down
3 changes: 3 additions & 0 deletions shinken/daemons/arbiterdaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ def load_config_file(self):
# applying dependencies
self.conf.apply_dependencies()

# sets objects initial state
self.conf.set_initial_state()

# Hacking some global parameters inherited from Nagios to create
# on the fly some Broker modules like for status.dat parameters
# or nagios.log one if there are none already available
Expand Down
63 changes: 33 additions & 30 deletions shinken/misc/termcolor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@

ATTRIBUTES = dict(
list(
zip([
'bold',
'dark',
'',
'underline',
'blink',
'',
'reverse',
'concealed'
],
zip(
[
'bold',
'dark',
'',
'underline',
'blink',
'',
'reverse',
'concealed'
],
list(range(1, 9))
)
)
Expand All @@ -52,16 +53,17 @@

HIGHLIGHTS = dict(
list(
zip([
'on_grey',
'on_red',
'on_green',
'on_yellow',
'on_blue',
'on_magenta',
'on_cyan',
'on_white'
],
zip(
[
'on_grey',
'on_red',
'on_green',
'on_yellow',
'on_blue',
'on_magenta',
'on_cyan',
'on_white'
],
list(range(40, 48))
)
)
Expand All @@ -70,16 +72,17 @@

COLORS = dict(
list(
zip([
'grey',
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white',
],
zip(
[
'grey',
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white',
],
list(range(90, 98))
)
)
Expand Down
7 changes: 7 additions & 0 deletions shinken/objects/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,13 @@ def linkify(self):
def remove_exclusions(self):
return self.services.remove_exclusions(self.hosts)

def set_initial_state(self):
"""
Sets services and hosts initial states.
"""
self.hosts.set_initial_state()
self.services.set_initial_state()

# Some elements are maybe set as wrong after a is_correct, so clean them
# if possible
def clean(self):
Expand Down
Loading

0 comments on commit 04ddd4d

Please sign in to comment.