Refactoring: Changed remaining check parameters starting with an 's' to the new rules...
[check_mk.git] / .werks / 8293
blobbf52807381197b0d74ff28704faecc3a305fc9b6
1 Title: Alert handlers: optionally process every single check execution, inline alert handlers
2 Level: 2
3 Edition: cee
4 Component: cmc
5 Version: 1.2.7i3
6 Date: 1437567777
7 Class: feature
9 The new alert handlers can now optionally be called at every check
10 execution. This is a possible way to bring check results into some external
11 system (like a database). Please note that this can cost many CPU ressources
12 and slow down the monitoring if the alert handler cannot process the data
13 fast enough.
15 In order to implement more performance alert handlers, these can now optionally
16 be written as Python functions that are being called without creating a new
17 process. Such an inline alert handler has the following structure:
19 F+:/omd/sites/mysite/local/share/check_mk/alert_handlers/foo
20 #!/usr/bin/python
21 # Inline: yes
23 # Do some basic initialization (optional)
24 def handle_init():
25     log("INIT")
27 # Called at shutdown (optional)
28 def handle_shutdown():
29     log("SHUTDOWN")
31 # Called at every alert (mandatory)
32 def handle_alert(context):
33     log("ALERT: %s" % context)
34 F-:
36 You need to define at least <tt>handle_alert</tt>. The argument <tt>context</tt> is a dictionary
37 with keys like <tt>"HOSTNAME"</tt>. You can use the function <tt>log(...)</tt>, which will write
38 some diagnostic text into <tt>var/log/alerts.log</tt> - marked with the name of you alert handler.
40 The two global variables <tt>omd_root</tt> and <tt>omd_site</tt> are set to the home directory
41 and to the name of the OMD site.
43 It is allowed to use <tt>import</tt> commands in your handler.
45 Note that in the second line you need to put <tt># Inline: yes</tt>. That way Check_MK nows
46 that the alert handler should be loaded as inline Python function and not run as a script.
48 Note also that after each change to an inline alert handler you need to restart the
49 CMC:
51 C+:
52 OM:omd restart cmc
53 C-: