2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
5 # Gregory Starck, g.starck@gmail.com
7 #This file is part of Shinken.
9 #Shinken is free software: you can redistribute it and/or modify
10 #it under the terms of the GNU Affero General Public License as published by
11 #the Free Software Foundation, either version 3 of the License, or
12 #(at your option) any later version.
14 #Shinken is distributed in the hope that it will be useful,
15 #but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 #GNU Affero General Public License for more details.
19 #You should have received a copy of the GNU Affero General Public License
20 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
25 from shinken
.util
import to_int
, to_bool
26 from shinken
.downtime
import Downtime
27 from shinken
.contactdowntime
import ContactDowntime
28 from shinken
.comment
import Comment
29 from shinken
.objects
import CommandCall
30 from shinken
.log
import logger
32 from shinken
.pollerlink
import PollerLink
, PollerLinks
34 class ExternalCommand
:
35 my_type
= 'externalcommand'
36 def __init__(self
, cmd_line
):
37 self
.cmd_line
= cmd_line
40 class ExternalCommandManager
:
43 'CHANGE_CONTACT_MODSATTR' : {'global' : True, 'args' : ['contact', None]},
44 'CHANGE_CONTACT_MODHATTR' : {'global' : True, 'args' : ['contact', None]},
45 'CHANGE_CONTACT_MODATTR' : {'global' : True, 'args' : ['contact', None]},
46 'CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD' : {'global' : True, 'args' : ['contact', 'time_period']},
47 'ADD_SVC_COMMENT' : {'global' : False, 'args' : ['service', 'to_bool', 'author', None]},
48 'ADD_HOST_COMMENT' : {'global' : False, 'args' : ['host', 'to_bool', 'author', None]},
49 'ACKNOWLEDGE_SVC_PROBLEM' : {'global' : False, 'args' : ['service' , 'to_int', 'to_bool', 'to_bool', 'author', None]},
50 'ACKNOWLEDGE_HOST_PROBLEM' : {'global' : False, 'args' : ['host', 'to_int', 'to_bool', 'to_bool', 'author', None]},
51 'CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD' : {'global' : True, 'args' : ['contact', 'time_period']},
52 'CHANGE_CUSTOM_CONTACT_VAR' : {'global' : True, 'args' : ['contact', None,None]},
53 'CHANGE_CUSTOM_HOST_VAR' : {'global' : False, 'args' : ['host', None,None]},
54 'CHANGE_CUSTOM_SVC_VAR' : {'global' : False, 'args' : ['service', None,None]},
55 'CHANGE_GLOBAL_HOST_EVENT_HANDLER' : {'global' : True, 'args' : ['command']},
56 'CHANGE_GLOBAL_SVC_EVENT_HANDLER' : {'global' : True, 'args' : ['command']},
57 'CHANGE_HOST_CHECK_COMMAND' : {'global' : False, 'args' : ['host', 'command']},
58 'CHANGE_HOST_CHECK_TIMEPERIOD' : {'global' : False, 'args' : ['host', 'time_period']},
59 'CHANGE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host', 'command']},
60 'CHANGE_HOST_MODATTR' : {'global' : False, 'args' : ['host', 'to_int']},
61 'CHANGE_MAX_HOST_CHECK_ATTEMPTS': {'global' : False, 'args' : ['host', 'to_int']},
62 'CHANGE_MAX_SVC_CHECK_ATTEMPTS' : {'global' : False, 'args' : ['service', 'to_int']},
63 'CHANGE_NORMAL_HOST_CHECK_INTERVAL' : {'global' : False, 'args' : ['host', 'to_int']},
64 'CHANGE_NORMAL_SVC_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
65 'CHANGE_RETRY_HOST_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
66 'CHANGE_RETRY_SVC_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
67 'CHANGE_SVC_CHECK_COMMAND' : {'global' : False, 'args' : ['service', 'command']},
68 'CHANGE_SVC_CHECK_TIMEPERIOD' : {'global' : False, 'args' : ['service', 'time_period']},
69 'CHANGE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service', 'command']},
70 'CHANGE_SVC_MODATTR' : {'global' : False, 'args' : ['service', 'to_int']},
71 'CHANGE_SVC_NOTIFICATION_TIMEPERIOD' : {'global' : False, 'args' : ['service', 'time_period']},
72 'DELAY_HOST_NOTIFICATION' : {'global' : False, 'args' : ['host', 'to_int']},
73 'DELAY_SVC_NOTIFICATION' : {'global' : False, 'args' : ['service', 'to_int']},
74 'DEL_ALL_HOST_COMMENTS' : {'global' : False, 'args' : ['host']},
75 'DEL_ALL_SVC_COMMENTS' : {'global' : False, 'args' : ['service']},
76 'DEL_CONTACT_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
77 'DEL_HOST_COMMENT' : {'global' : True, 'args' : ['to_int']},
78 'DEL_HOST_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
79 'DEL_SVC_COMMENT' : {'global' : True, 'args' : ['to_int']},
80 'DEL_SVC_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
81 'DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST' : {'global' : False, 'args' : ['host']},
82 'DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
83 'DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
84 'DISABLE_CONTACT_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
85 'DISABLE_CONTACT_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
86 'DISABLE_EVENT_HANDLERS' : {'global' : True, 'args' : []},
87 'DISABLE_FAILURE_PREDICTION' : {'global' : True, 'args' : []},
88 'DISABLE_FLAP_DETECTION' : {'global' : True, 'args' : []},
89 'DISABLE_HOSTGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
90 'DISABLE_HOSTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
91 'DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
92 'DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
93 'DISABLE_HOSTGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
94 'DISABLE_HOSTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
95 'DISABLE_HOST_AND_CHILD_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
96 'DISABLE_HOST_CHECK' : {'global' : False, 'args' : ['host']},
97 'DISABLE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
98 'DISABLE_HOST_FLAP_DETECTION' : {'global' : False, 'args' : ['host']},
99 'DISABLE_HOST_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
100 'DISABLE_HOST_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
101 'DISABLE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host']},
102 'DISABLE_HOST_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
103 'DISABLE_NOTIFICATIONS' : {'global' : True, 'args' : []},
104 'DISABLE_PASSIVE_HOST_CHECKS' : {'global' : False, 'args' : ['host']},
105 'DISABLE_PASSIVE_SVC_CHECKS' : {'global' : False, 'args' : ['service']},
106 'DISABLE_PERFORMANCE_DATA' : {'global' : True, 'args' : []},
107 'DISABLE_SERVICEGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
108 'DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
109 'DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
110 'DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
111 'DISABLE_SERVICEGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
112 'DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
113 'DISABLE_SERVICE_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
114 'DISABLE_SERVICE_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
115 'DISABLE_SVC_CHECK' : {'global' : False, 'args' : ['service']},
116 'DISABLE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
117 'DISABLE_SVC_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
118 'DISABLE_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['service']},
119 'ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST' : {'global' : False, 'args' : ['host']},
120 'ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
121 'ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
122 'ENABLE_CONTACT_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
123 'ENABLE_CONTACT_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
124 'ENABLE_EVENT_HANDLERS' : {'global' : True, 'args' : []},
125 'ENABLE_FAILURE_PREDICTION' : {'global' : True, 'args' : []},
126 'ENABLE_FLAP_DETECTION' : {'global' : True, 'args' : []},
127 'ENABLE_HOSTGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
128 'ENABLE_HOSTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
129 'ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
130 'ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
131 'ENABLE_HOSTGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
132 'ENABLE_HOSTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
133 'ENABLE_HOST_AND_CHILD_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
134 'ENABLE_HOST_CHECK' : {'global' : False, 'args' : ['host']},
135 'ENABLE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
136 'ENABLE_HOST_FLAP_DETECTION' : {'global' : False, 'args' : ['host']},
137 'ENABLE_HOST_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
138 'ENABLE_HOST_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
139 'ENABLE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host']},
140 'ENABLE_HOST_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
141 'ENABLE_NOTIFICATIONS' : {'global' : True, 'args' : []},
142 'ENABLE_PASSIVE_HOST_CHECKS' : {'global' : False, 'args' : ['host']},
143 'ENABLE_PASSIVE_SVC_CHECKS' : {'global' : False, 'args' : ['service']},
144 'ENABLE_PERFORMANCE_DATA' : {'global' : True, 'args' : []},
145 'ENABLE_SERVICEGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
146 'ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
147 'ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
148 'ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
149 'ENABLE_SERVICEGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
150 'ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
151 'ENABLE_SERVICE_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
152 'ENABLE_SVC_CHECK': {'global' : False, 'args' : ['service']},
153 'ENABLE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
154 'ENABLE_SVC_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
155 'ENABLE_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['service']},
156 'PROCESS_FILE' : {'global' : True, 'args' : [None, 'to_bool']},
157 'PROCESS_HOST_CHECK_RESULT' : {'global' : False, 'args' : ['host', 'to_int', None]},
158 'PROCESS_SERVICE_CHECK_RESULT' : {'global' : False, 'args' : ['service', 'to_int', None]},
159 'READ_STATE_INFORMATION' : {'global' : True, 'args' : []},
160 'REMOVE_HOST_ACKNOWLEDGEMENT' : {'global' : False, 'args' : ['host']},
161 'REMOVE_SVC_ACKNOWLEDGEMENT' : {'global' : False, 'args' : ['service']},
162 'RESTART_PROGRAM' : {'global' : True, 'args' : []},
163 'SAVE_STATE_INFORMATION' : {'global' : True, 'args' : []},
164 'SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
165 'SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
166 'SCHEDULE_CONTACT_DOWNTIME' : {'global' : True, 'args' : ['contact', 'to_int', 'to_int', 'author', None]},
167 'SCHEDULE_FORCED_HOST_CHECK' : {'global' : False, 'args' : ['host', 'to_int']},
168 'SCHEDULE_FORCED_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host', 'to_int']},
169 'SCHEDULE_FORCED_SVC_CHECK' : {'global' : False, 'args' : ['service', 'to_int']},
170 'SCHEDULE_HOSTGROUP_HOST_DOWNTIME' : {'global' : True, 'args' : ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
171 'SCHEDULE_HOSTGROUP_SVC_DOWNTIME' : {'global' : True, 'args' : ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
172 'SCHEDULE_HOST_CHECK' : {'global' : False, 'args' : ['host', 'to_int']},
173 'SCHEDULE_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
174 'SCHEDULE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host', 'to_int']},
175 'SCHEDULE_HOST_SVC_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
176 'SCHEDULE_SERVICEGROUP_HOST_DOWNTIME' : {'global' : True, 'args' : ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
177 'SCHEDULE_SERVICEGROUP_SVC_DOWNTIME' : {'global' : True, 'args' : ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
178 'SCHEDULE_SVC_CHECK' : {'global' : False, 'args' : ['service', 'to_int']},
179 'SCHEDULE_SVC_DOWNTIME' : {'global' : False, 'args' : ['service', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
180 'SEND_CUSTOM_HOST_NOTIFICATION' : {'global' : False, 'args' : ['host', 'to_int', 'author', None]},
181 'SEND_CUSTOM_SVC_NOTIFICATION' : {'global' : False, 'args' : ['service', 'to_int', 'author', None]},
182 'SET_HOST_NOTIFICATION_NUMBER' : {'global' : False, 'args' : ['host', 'to_int']},
183 'SET_SVC_NOTIFICATION_NUMBER' : {'global' : False, 'args' : ['service', 'to_int']},
184 'SHUTDOWN_PROGRAM' : {'global' : True, 'args' : []},
185 'START_ACCEPTING_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : []},
186 'START_ACCEPTING_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : []},
187 'START_EXECUTING_HOST_CHECKS' : {'global' : True, 'args' : []},
188 'START_EXECUTING_SVC_CHECKS' : {'global' : True, 'args' : []},
189 'START_OBSESSING_OVER_HOST' : {'global' : False, 'args' : ['host']},
190 'START_OBSESSING_OVER_HOST_CHECKS' : {'global' : True, 'args' : []},
191 'START_OBSESSING_OVER_SVC' : {'global' : False, 'args' : ['service']},
192 'START_OBSESSING_OVER_SVC_CHECKS' : {'global' : True, 'args' : []},
193 'STOP_ACCEPTING_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : []},
194 'STOP_ACCEPTING_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : []},
195 'STOP_EXECUTING_HOST_CHECKS' : {'global' : True, 'args' : []},
196 'STOP_EXECUTING_SVC_CHECKS' : {'global' : True, 'args' : []},
197 'STOP_OBSESSING_OVER_HOST' : {'global' : False, 'args' : ['host']},
198 'STOP_OBSESSING_OVER_HOST_CHECKS' : {'global' : True, 'args' : []},
199 'STOP_OBSESSING_OVER_SVC' : {'global' : False, 'args' : ['service']},
200 'STOP_OBSESSING_OVER_SVC_CHECKS' : {'global' : True, 'args' : []},
201 'LAUNCH_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
202 'LAUNCH_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
204 'ADD_SIMPLE_HOST_DEPENDENCY' : {'global' : False, 'args' : ['host', 'host']},
205 'DEL_HOST_DEPENDENCY' : {'global' : False, 'args' : ['host', 'host']},
206 'ADD_SIMPLE_POLLER' : {'global' : True, 'internal' : True, 'args' : [None, None, None, None]},
210 def __init__(self
, conf
, mode
):
213 self
.hosts
= conf
.hosts
214 self
.services
= conf
.services
215 self
.contacts
= conf
.contacts
216 self
.hostgroups
= conf
.hostgroups
217 self
.commands
= conf
.commands
218 self
.servicegroups
= conf
.servicegroups
219 self
.contactgroups
= conf
.contactgroups
220 self
.timeperiods
= conf
.timeperiods
221 self
.pipe_path
= conf
.command_file
223 self
.cmd_fragments
= ''
224 if self
.mode
== 'dispatcher':
225 self
.confs
= conf
.confs
228 def load_scheduler(self
, scheduler
):
229 self
.sched
= scheduler
231 def load_arbiter(self
, arbiter
):
232 self
.arbiter
= arbiter
236 #At the first open del and create the fifo
237 if self
.fifo
== None:
238 if os
.path
.exists(self
.pipe_path
):
239 os
.unlink(self
.pipe_path
)
241 if not os
.path
.exists(self
.pipe_path
):
244 os
.mkfifo(self
.pipe_path
, 0660)
245 open(self
.pipe_path
, 'w+', os
.O_NONBLOCK
)
246 except OSError , exp
:
247 print "Error : pipe creation failed (",self
.pipe_path
,')', exp
249 self
.fifo
= os
.open(self
.pipe_path
, os
.O_NONBLOCK
)
250 #print 'Fifo:', self.fifo
255 buf
= os
.read(self
.fifo
, 8096)
257 fullbuf
= len(buf
) == 8096 and True or False
258 # If the buffer ended with a fragment last time, prepend it here
259 buf
= self
.cmd_fragments
+ buf
261 self
.cmd_fragments
= ''
262 if fullbuf
and buf
[-1] != '\n':
263 # The buffer was full but ends with a command fragment
264 r
.extend([ExternalCommand(s
) for s
in (buf
.split('\n'))[:-1] if s
])
265 self
.cmd_fragments
= (buf
.split('\n'))[-1]
267 # The buffer is either half-filled or full with a '\n' at the end.
268 r
.extend([ExternalCommand(s
) for s
in buf
.split('\n') if s
])
270 # The buffer is empty. We "reset" the fifo here. It will be
271 # re-opened in the main loop.
276 def resolve_command(self
, excmd
):
277 command
= excmd
.cmd_line
278 command
= command
.strip()
279 #Only log if we are in the Arbiter
280 if self
.mode
== 'dispatcher':
281 logger
.log('EXTERNAL COMMAND: '+command
.rstrip())
282 self
.get_command_and_args(command
)
285 #Ok the command is not for every one, so we search
286 #by the hostname which scheduler have the host. Then send
288 def search_host_and_dispatch(self
, host_name
, command
):
289 print "Calling search_host_and_dispatch", 'for', host_name
290 for cfg
in self
.confs
.values():
291 if cfg
.hosts
.find_by_name(host_name
) is not None:
292 print "Host", host_name
, "found in a configuration"
294 sched
= cfg
.assigned_to
295 print "Sending command to the scheduler", sched
.get_name()
296 sched
.run_external_command(command
)
298 print "Problem: a configuration is found, but is not assigned!"
300 logger
.log("Warning: Passive check result was received for host '%s', but the host could not be found!" % host_name
)
301 #print "Sorry but the host", host_name, "was not found"
304 #The command is global, so sent it to every schedulers
305 def dispatch_global_command(self
, command
):
306 for sched
in self
.conf
.schedulerlinks
:
307 print "Sending a command", command
, 'to scheduler', sched
309 sched
.run_external_command(command
)
312 #We need to get the first part, the command name
313 def get_command_and_args(self
, command
):
314 print "Trying to resolve", command
315 command
= command
.rstrip()
316 elts
= command
.split(';') # danger!!! passive checkresults with perfdata
319 elts2
= part1
.split(' ')
320 print "Elts2:", elts2
322 print "Malformed command", command
326 print "Get command name", c_name
327 if c_name
not in ExternalCommandManager
.commands
:
328 print "This command is not recognized, sorry"
331 # Split again based on the number of args we expect. We cannot split
332 # on every ; because this character may appear in the perfdata of
333 # passive check results.
334 entry
= ExternalCommandManager
.commands
[c_name
]
336 #Look if the command is purely internal or not
338 if 'internal' in entry
and entry
['internal']:
341 numargs
= len(entry
['args'])
342 if numargs
and 'service' in entry
['args']:
344 elts
= command
.split(';', numargs
)
346 print self
.mode
, entry
['global']
347 if self
.mode
== 'dispatcher' and entry
['global']:
349 print "This command is a global one, we resent it to all schedulers"
350 self
.dispatch_global_command(command
)
353 print "Is global?", c_name
, entry
['global']
354 print "Mode:", self
.mode
355 print "This command have arguments:", entry
['args'], len(entry
['args'])
363 print "Searching for a new arg:", elt
, i
368 print "For command arg", val
371 type_searched
= entry
['args'][i
-1]
372 print "Search for a arg", type_searched
374 if type_searched
== 'host':
375 if self
.mode
== 'dispatcher':
376 self
.search_host_and_dispatch(val
, command
)
378 h
= self
.hosts
.find_by_name(val
)
382 elif type_searched
== 'contact':
383 c
= self
.contacts
.find_by_name(val
)
387 elif type_searched
== 'time_period':
388 t
= self
.timeperiods
.find_by_name(val
)
392 elif type_searched
== 'to_bool':
393 args
.append(to_bool(val
))
395 elif type_searched
== 'to_int':
396 args
.append(to_int(val
))
398 elif type_searched
in ('author', None):
401 elif type_searched
== 'command':
402 c
= self
.commands
.find_cmd_by_name(val
)
404 args
.append(val
)#the find will be redone by
405 #the commandCall creation, but != None
406 #is usefull so a bad command will be catch
408 elif type_searched
== 'host_group':
409 hg
= self
.hostgroups
.find_by_name(val
)
413 elif type_searched
== 'service_group':
414 sg
= self
.servicegroups
.find_by_name(val
)
418 elif type_searched
== 'contact_group':
419 cg
= self
.contact_groups
.find_by_name(val
)
423 #special case: service are TWO args host;service, so one more loop
424 #to get the two parts
425 elif type_searched
== 'service':
427 tmp_host
= elt
.strip()
428 print "TMP HOST", tmp_host
429 if tmp_host
[-1] == '\n':
430 tmp_host
= tmp_host
[:-1]
432 if self
.mode
== 'dispatcher':
433 self
.search_host_and_dispatch(tmp_host
, command
)
440 if srv_name
[-1] == '\n':
441 srv_name
= srv_name
[:-1]
442 print "Got service full", tmp_host
, srv_name
443 s
= self
.services
.find_srv_by_name_and_hostname(tmp_host
, srv_name
)
446 else: #error, must be logged
447 logger
.log("Warning: a command was received for service '%s' on host '%s', but the service could not be found!" % (srv_name
, tmp_host
))
450 print "Sorry, the arguments are not corrects"
452 print 'Finally got ARGS:', args
453 if len(args
) == len(entry
['args']):
454 print "OK, we can call the command", c_name
, "with", args
455 f
= getattr(self
, c_name
)
458 print "Sorry, the arguments are not corrects", args
462 #CHANGE_CONTACT_MODSATTR;<contact_name>;<value>
463 def CHANGE_CONTACT_MODSATTR(self
, contact
, value
):
466 #CHANGE_CONTACT_MODHATTR;<contact_name>;<value>
467 def CHANGE_CONTACT_MODHATTR(self
, contact
, value
):
470 #CHANGE_CONTACT_MODATTR;<contact_name>;<value>
471 def CHANGE_CONTACT_MODATTR(self
, contact
, value
):
474 #CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>
475 def CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD(self
, contact
, notification_timeperiod
):
476 contact
.host_notification_period
= notification_timeperiod
477 self
.sched
.get_and_register_status_brok(contact
)
479 #ADD_SVC_COMMENT;<host_name>;<service_description>;<persistent>;<author>;<comment>
480 def ADD_SVC_COMMENT(self
, service
, persistent
, author
, comment
):
481 c
= Comment(service
, persistent
, author
, comment
, 2, 1, 1, False, 0)
482 service
.add_comment(c
)
485 #ADD_HOST_COMMENT;<host_name>;<persistent>;<author>;<comment>
486 def ADD_HOST_COMMENT(self
, host
, persistent
, author
, comment
):
487 c
= Comment(host
, persistent
, author
, comment
, 1, 1, 1, False, 0)
491 #ACKNOWLEDGE_SVC_PROBLEM;<host_name>;<service_description>;<sticky>;<notify>;<persistent>;<author>;<comment>
492 def ACKNOWLEDGE_SVC_PROBLEM(self
, service
, sticky
, notify
, persistent
, author
, comment
):
493 service
.acknowledge_problem(sticky
, notify
, persistent
, author
, comment
)
495 #ACKNOWLEDGE_HOST_PROBLEM;<host_name>;<sticky>;<notify>;<persistent>;<author>;<comment>
496 #TODO : add a better ACK management
497 def ACKNOWLEDGE_HOST_PROBLEM(self
, host
, sticky
, notify
, persistent
, author
, comment
):
498 host
.acknowledge_problem(sticky
, notify
, persistent
, author
, comment
)
500 #CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>
501 def CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD(self
, contact
, notification_timeperiod
):
502 contact
.service_notification_period
= notification_timeperiod
503 self
.sched
.get_and_register_status_brok(contact
)
505 #CHANGE_CUSTOM_CONTACT_VAR;<contact_name>;<varname>;<varvalue>
506 def CHANGE_CUSTOM_CONTACT_VAR(self
, contact
, varname
, varvalue
):
507 contact
.customs
[varname
.upper()] = varvalue
509 #CHANGE_CUSTOM_HOST_VAR;<host_name>;<varname>;<varvalue>
510 def CHANGE_CUSTOM_HOST_VAR(self
, host
, varname
, varvalue
):
511 host
.customs
[varname
.upper()] = varvalue
513 #CHANGE_CUSTOM_SVC_VAR;<host_name>;<service_description>;<varname>;<varvalue>
514 def CHANGE_CUSTOM_SVC_VAR(self
, service
, varname
, varvalue
):
515 service
.customs
[varname
.upper()] = varvalue
517 #CHANGE_GLOBAL_HOST_EVENT_HANDLER;<event_handler_command>
518 def CHANGE_GLOBAL_HOST_EVENT_HANDLER(self
, event_handler_command
):
521 #CHANGE_GLOBAL_SVC_EVENT_HANDLER;<event_handler_command>
522 def CHANGE_GLOBAL_SVC_EVENT_HANDLER(self
, event_handler_command
):
525 #CHANGE_HOST_CHECK_COMMAND;<host_name>;<check_command>
526 def CHANGE_HOST_CHECK_COMMAND(self
, host
, check_command
):
527 host
.check_command
= CommandCall(self
.commands
, check_command
, poller_tag
=host
.poller_tag
)
528 self
.sched
.get_and_register_status_brok(host
)
530 #CHANGE_HOST_CHECK_TIMEPERIOD;<host_name>;<timeperiod>
531 def CHANGE_HOST_CHECK_TIMEPERIOD(self
, host
, timeperiod
):
532 host
.check_period
= timeperiod
533 self
.sched
.get_and_register_status_brok(service
)
535 #CHANGE_HOST_EVENT_HANDLER;<host_name>;<event_handler_command>
536 def CHANGE_HOST_EVENT_HANDLER(self
, host
, event_handler_command
):
537 host
.event_handler
= CommandCall(self
.commands
, event_handler_command
)
538 self
.sched
.get_and_register_status_brok(host
)
540 #CHANGE_HOST_MODATTR;<host_name>;<value>
541 def CHANGE_HOST_MODATTR(self
, host
, value
):
544 #CHANGE_MAX_HOST_CHECK_ATTEMPTS;<host_name>;<check_attempts>
545 def CHANGE_MAX_HOST_CHECK_ATTEMPTS(self
, host
, check_attempts
):
546 host
.max_check_attempts
= check_attempts
547 self
.sched
.get_and_register_status_brok(host
)
549 #CHANGE_MAX_SVC_CHECK_ATTEMPTS;<host_name>;<service_description>;<check_attempts>
550 def CHANGE_MAX_SVC_CHECK_ATTEMPTS(self
, service
, check_attempts
):
551 service
.max_check_attempts
= check_attempts
552 self
.sched
.get_and_register_status_brok(service
)
554 #CHANGE_NORMAL_HOST_CHECK_INTERVAL;<host_name>;<check_interval>
555 def CHANGE_NORMAL_HOST_CHECK_INTERVAL(self
, host
, check_interval
):
556 host
.check_interval
= check_interval
557 self
.sched
.get_and_register_status_brok(host
)
559 #CHANGE_NORMAL_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
560 def CHANGE_NORMAL_SVC_CHECK_INTERVAL(self
, service
, check_interval
):
561 service
.check_interval
= check_interval
562 self
.sched
.get_and_register_status_brok(service
)
564 #CHANGE_RETRY_HOST_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
565 def CHANGE_RETRY_HOST_CHECK_INTERVAL(self
, host
, check_interval
):
566 host
.retry_interval
= check_interval
567 self
.sched
.get_and_register_status_brok(host
)
569 #CHANGE_RETRY_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
570 def CHANGE_RETRY_SVC_CHECK_INTERVAL(self
, service
, check_interval
):
571 service
.retry_interval
= check_interval
572 self
.sched
.get_and_register_status_brok(service
)
574 #CHANGE_SVC_CHECK_COMMAND;<host_name>;<service_description>;<check_command>
575 def CHANGE_SVC_CHECK_COMMAND(self
, service
, check_command
):
576 service
.check_command
= CommandCall(self
.commands
, check_command
, poller_tag
=service
.poller_tag
)
577 self
.sched
.get_and_register_status_brok(service
)
579 #CHANGE_SVC_CHECK_TIMEPERIOD;<host_name>;<service_description>;<check_timeperiod>
580 def CHANGE_SVC_CHECK_TIMEPERIOD(self
, service
, check_timeperiod
):
581 service
.check_period
= check_timeperiod
582 self
.sched
.get_and_register_status_brok(service
)
584 #CHANGE_SVC_EVENT_HANDLER;<host_name>;<service_description>;<event_handler_command>
585 def CHANGE_SVC_EVENT_HANDLER(self
, service
, event_handler_command
):
586 service
.event_handler
= CommandCall(self
.commands
, event_handler_command
)
587 self
.sched
.get_and_register_status_brok(service
)
589 #CHANGE_SVC_MODATTR;<host_name>;<service_description>;<value>
590 def CHANGE_SVC_MODATTR(self
, service
, value
):
593 #CHANGE_SVC_NOTIFICATION_TIMEPERIOD;<host_name>;<service_description>;<notification_timeperiod>
594 def CHANGE_SVC_NOTIFICATION_TIMEPERIOD(self
, service
, notification_timeperiod
):
595 service
.notification_period
= notification_timeperiod
596 self
.sched
.get_and_register_status_brok(service
)
598 #DELAY_HOST_NOTIFICATION;<host_name>;<notification_time>
599 def DELAY_HOST_NOTIFICATION(self
, host
, notification_time
):
600 host
.first_notification_delay
= notification_time
601 self
.sched
.get_and_register_status_brok(host
)
603 #DELAY_SVC_NOTIFICATION;<host_name>;<service_description>;<notification_time>
604 def DELAY_SVC_NOTIFICATION(self
, service
, notification_time
):
605 service
.first_notification_delay
= notification_time
606 self
.sched
.get_and_register_status_brok(service
)
608 #DEL_ALL_HOST_COMMENTS;<host_name>
609 def DEL_ALL_HOST_COMMENTS(self
, host
):
610 for c
in host
.comments
:
611 self
.DEL_HOST_COMMENT(c
.id)
613 #DEL_ALL_SVC_COMMENTS;<host_name>;<service_description>
614 def DEL_ALL_SVC_COMMENTS(self
, service
):
615 for c
in service
.comments
:
616 self
.DEL_SVC_COMMENT(c
.id)
618 #DEL_CONTACT_DOWNTIME;<downtime_id>
619 def DEL_CONTACT_DOWNTIME(self
, downtime_id
):
620 if downtime_id
in self
.sched
.contact_downtimes
:
621 self
.sched
.contact_downtimes
[downtime_id
].cancel()
624 #DEL_HOST_COMMENT;<comment_id>
625 def DEL_HOST_COMMENT(self
, comment_id
):
626 if comment_id
in self
.sched
.comments
:
627 self
.sched
.comments
[comment_id
].can_be_deleted
= True
629 #DEL_HOST_DOWNTIME;<downtime_id>
630 def DEL_HOST_DOWNTIME(self
, downtime_id
):
631 if downtime_id
in self
.sched
.downtimes
:
632 self
.sched
.downtimes
[downtime_id
].cancel()
634 #DEL_SVC_COMMENT;<comment_id>
635 def DEL_SVC_COMMENT(self
, comment_id
):
636 if comment_id
in self
.sched
.comments
:
637 self
.sched
.comments
[comment_id
].can_be_deleted
= True
639 #DEL_SVC_DOWNTIME;<downtime_id>
640 def DEL_SVC_DOWNTIME(self
, downtime_id
):
641 if downtime_id
in self
.sched
.downtimes
:
642 self
.sched
.downtimes
[downtime_id
].cancel()
644 #DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
645 def DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST(self
, host
):
648 #DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>
649 def DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS(self
, contactgroup
):
650 for contact
in contactgroup
:
651 self
.DISABLE_CONTACT_HOST_NOTIFICATIONS(contact
)
653 #DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>
654 def DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS(self
, contactgroup
):
655 for contact
in contactgroup
:
656 self
.DISABLE_CONTACT_SVC_NOTIFICATIONS(contact
)
658 #DISABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
659 def DISABLE_CONTACT_HOST_NOTIFICATIONS(self
, contact
):
660 contact
.host_notifications_enabled
= False
661 self
.sched
.get_and_register_status_brok(contact
)
663 #DISABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
664 def DISABLE_CONTACT_SVC_NOTIFICATIONS(self
, contact
):
665 contact
.service_notifications_enabled
= False
666 self
.sched
.get_and_register_status_brok(contact
)
668 #DISABLE_EVENT_HANDLERS
669 def DISABLE_EVENT_HANDLERS(self
):
670 self
.conf
.enable_event_handlers
= False
671 self
.conf
.explode_global_conf()
672 self
.sched
.get_and_register_update_program_status_brok()
674 #DISABLE_FAILURE_PREDICTION
675 def DISABLE_FAILURE_PREDICTION(self
):
676 self
.conf
.enable_failure_prediction
= False
677 self
.conf
.explode_global_conf()
678 self
.sched
.get_and_register_update_program_status_brok()
680 #DISABLE_FLAP_DETECTION
681 def DISABLE_FLAP_DETECTION(self
):
682 self
.conf
.enable_flap_detection
= False
683 self
.conf
.explode_global_conf()
684 self
.sched
.get_and_register_update_program_status_brok()
686 #DISABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
687 def DISABLE_HOSTGROUP_HOST_CHECKS(self
, hostgroup
):
688 for host
in hostgroup
:
689 self
.DISABLE_HOST_CHECK(host
)
691 #DISABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>
692 def DISABLE_HOSTGROUP_HOST_NOTIFICATIONS(self
, hostgroup
):
693 for host
in hostgroup
:
694 self
.DISABLE_HOST_NOTIFICATIONS(host
)
696 #DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>
697 def DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS(self
, hostgroup
):
698 for host
in hostgroup
:
699 self
.DISABLE_PASSIVE_HOST_CHECKS(host
)
701 #DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>
702 def DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS(self
, hostgroup
):
703 for host
in hostgroup
:
704 for service
in host
.services
:
705 self
.DISABLE_PASSIVE_SVC_CHECKS(service
)
707 #DISABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>
708 def DISABLE_HOSTGROUP_SVC_CHECKS(self
, hostgroup
):
709 for host
in hostgroup
:
710 for service
in host
.services
:
711 self
.DISABLE_SVC_CHECK(service
)
713 #DISABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>
714 def DISABLE_HOSTGROUP_SVC_NOTIFICATIONS(self
, hostgroup
):
715 for host
in hostgroup
:
716 for service
in host
.services
:
717 self
.DISABLE_SVC_NOTIFICATIONS(service
)
719 #DISABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name>
720 def DISABLE_HOST_AND_CHILD_NOTIFICATIONS(self
, host
):
723 #DISABLE_HOST_CHECK;<host_name>
724 def DISABLE_HOST_CHECK(self
, host
):
725 host
.active_checks_enabled
= False
726 self
.sched
.get_and_register_status_brok(host
)
728 #DISABLE_HOST_EVENT_HANDLER;<host_name>
729 def DISABLE_HOST_EVENT_HANDLER(self
, host
):
730 host
.event_handler_enabled
= False
731 self
.sched
.get_and_register_status_brok(host
)
733 #DISABLE_HOST_FLAP_DETECTION;<host_name>
734 def DISABLE_HOST_FLAP_DETECTION(self
, host
):
735 host
.flap_detection_enabled
= False
736 self
.sched
.get_and_register_status_brok(host
)
738 #DISABLE_HOST_FRESHNESS_CHECKS
739 def DISABLE_HOST_FRESHNESS_CHECKS(self
, host
):
740 host
.check_freshness
= False
741 self
.sched
.get_and_register_status_brok(host
)
743 #DISABLE_HOST_NOTIFICATIONS;<host_name>
744 def DISABLE_HOST_NOTIFICATIONS(self
, host
):
745 host
.notifications_enabled
= False
746 self
.sched
.get_and_register_status_brok(host
)
748 #DISABLE_HOST_SVC_CHECKS;<host_name>
749 def DISABLE_HOST_SVC_CHECKS(self
, host
):
750 for s
in host
.services
:
751 self
.DISABLE_SVC_CHECK(s
)
752 self
.sched
.get_and_register_status_brok(s
)
754 #DISABLE_HOST_SVC_NOTIFICATIONS;<host_name>
755 def DISABLE_HOST_SVC_NOTIFICATIONS(self
, host
):
756 for s
in host
.services
:
757 self
.DISABLE_SVC_NOTIFICATIONS(s
)
758 self
.sched
.get_and_register_status_brok(s
)
760 #DISABLE_NOTIFICATIONS
761 def DISABLE_NOTIFICATIONS(self
):
762 self
.conf
.enable_notifications
= False
763 self
.conf
.explode_global_conf()
764 self
.sched
.get_and_register_update_program_status_brok()
766 #DISABLE_PASSIVE_HOST_CHECKS;<host_name>
767 def DISABLE_PASSIVE_HOST_CHECKS(self
, host
):
768 host
.passive_checks_enabled
= False
769 self
.sched
.get_and_register_status_brok(host
)
771 #DISABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
772 def DISABLE_PASSIVE_SVC_CHECKS(self
, service
):
773 service
.passive_checks_enabled
= False
774 self
.sched
.get_and_register_status_brok(service
)
776 #DISABLE_PERFORMANCE_DATA
777 def DISABLE_PERFORMANCE_DATA(self
):
778 self
.conf
.process_performance_data
= False
779 self
.conf
.explode_global_conf()
780 self
.sched
.get_and_register_update_program_status_brok()
782 #DISABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
783 def DISABLE_SERVICEGROUP_HOST_CHECKS(self
, servicegroup
):
784 for service
in servicegroup
:
785 self
.DISABLE_HOST_CHECK(service
.host
)
787 #DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>
788 def DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS(self
, servicegroup
):
789 for service
in servicegroup
:
790 self
.DISABLE_HOST_NOTIFICATIONS(service
.host
)
792 #DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
793 def DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS(self
, servicegroup
):
794 for service
in servicegroup
:
795 self
.DISABLE_PASSIVE_HOST_CHECKS(service
.host
)
797 #DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>
798 def DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS(self
, servicegroup
):
799 for service
in servicegroup
:
800 self
.DISABLE_PASSIVE_SVC_CHECKS(service
)
802 #DISABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>
803 def DISABLE_SERVICEGROUP_SVC_CHECKS(self
, servicegroup
):
804 for service
in servicegroup
:
805 self
.DISABLE_SVC_CHECK(service
)
807 #DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>
808 def DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS(self
, servicegroup
):
809 for service
in servicegroup
:
810 self
.DISABLE_SVC_NOTIFICATIONS(service
)
812 #DISABLE_SERVICE_FLAP_DETECTION;<host_name>;<service_description>
813 def DISABLE_SERVICE_FLAP_DETECTION(self
, service
):
814 service
.flap_detection_enabled
= False
815 self
.sched
.get_and_register_status_brok(service
)
817 #DISABLE_SERVICE_FRESHNESS_CHECKS
818 def DISABLE_SERVICE_FRESHNESS_CHECKS(self
):
819 self
.conf
.check_service_freshness
= False
820 self
.conf
.explode_global_conf()
821 self
.sched
.get_and_register_update_program_status_brok()
823 #DISABLE_SVC_CHECK;<host_name>;<service_description>
824 def DISABLE_SVC_CHECK(self
, service
):
825 service
.active_checks_enabled
= False
826 self
.sched
.get_and_register_status_brok(service
)
828 #DISABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
829 def DISABLE_SVC_EVENT_HANDLER(self
, service
):
830 service
.event_handler_enabled
= False
831 self
.sched
.get_and_register_status_brok(service
)
833 #DISABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
834 def DISABLE_SVC_FLAP_DETECTION(self
, service
):
835 service
.flap_detection_enabled
= False
836 self
.sched
.get_and_register_status_brok(service
)
838 #DISABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
839 def DISABLE_SVC_NOTIFICATIONS(self
, service
):
840 service
.notifications_enabled
= False
841 self
.sched
.get_and_register_status_brok(service
)
843 #ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
844 def ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST(self
, host
):
847 #ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>
848 def ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS(self
, contactgroup
):
849 for contact
in contactgroup
:
850 self
.ENABLE_CONTACT_HOST_NOTIFICATIONS(contact
)
852 #ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>
853 def ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS(self
, contactgroup
):
854 for contact
in contactgroup
:
855 self
.ENABLE_CONTACT_SVC_NOTIFICATIONS(contact
)
857 #ENABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
858 def ENABLE_CONTACT_HOST_NOTIFICATIONS(self
, contact
):
859 contact
.host_notifications_enabled
= True
860 self
.sched
.get_and_register_status_brok(contact
)
862 #ENABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
863 def ENABLE_CONTACT_SVC_NOTIFICATIONS(self
, contact
):
864 contact
.service_notifications_enabled
= True
865 self
.sched
.get_and_register_status_brok(contact
)
867 #ENABLE_EVENT_HANDLERS
868 def ENABLE_EVENT_HANDLERS(self
):
869 self
.conf
.enable_event_handlers
= True
870 self
.conf
.explode_global_conf()
871 self
.sched
.get_and_register_update_program_status_brok()
873 #ENABLE_FAILURE_PREDICTION
874 def ENABLE_FAILURE_PREDICTION(self
):
875 self
.conf
.enable_failure_prediction
= True
876 self
.conf
.explode_global_conf()
877 self
.sched
.get_and_register_update_program_status_brok()
879 #ENABLE_FLAP_DETECTION
880 def ENABLE_FLAP_DETECTION(self
):
881 self
.conf
.enable_flap_detection
= True
882 self
.conf
.explode_global_conf()
883 self
.sched
.get_and_register_update_program_status_brok()
885 #ENABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
886 def ENABLE_HOSTGROUP_HOST_CHECKS(self
, hostgroup
):
887 for host
in hostgroup
:
888 self
.ENABLE_HOST_CHECK(host
)
890 #ENABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>
891 def ENABLE_HOSTGROUP_HOST_NOTIFICATIONS(self
, hostgroup
):
892 for host
in hostgroup
:
893 self
.ENABLE_HOST_NOTIFICATIONS(host
)
895 #ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>
896 def ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS(self
, hostgroup
):
897 for host
in hostgroup
:
898 self
.ENABLE_PASSIVE_HOST_CHECKS(host
)
900 #ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>
901 def ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS(self
, hostgroup
):
902 for host
in hostgroup
:
903 for service
in host
.services
:
904 self
.ENABLE_PASSIVE_SVC_CHECKS(service
)
906 #ENABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>
907 def ENABLE_HOSTGROUP_SVC_CHECKS(self
, hostgroup
):
908 for host
in hostgroup
:
909 for service
in host
.services
:
910 self
.ENABLE_SVC_CHECK(service
)
912 #ENABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>
913 def ENABLE_HOSTGROUP_SVC_NOTIFICATIONS(self
, hostgroup
):
914 for host
in hostgroup
:
915 for service
in host
.services
:
916 self
.ENABLE_SVC_NOTIFICATIONS(service
)
918 #ENABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name>
919 def ENABLE_HOST_AND_CHILD_NOTIFICATIONS(self
, host
):
922 #ENABLE_HOST_CHECK;<host_name>
923 def ENABLE_HOST_CHECK(self
, host
):
924 host
.active_checks_enabled
= True
925 self
.sched
.get_and_register_status_brok(host
)
927 #ENABLE_HOST_EVENT_HANDLER;<host_name>
928 def ENABLE_HOST_EVENT_HANDLER(self
, host
):
929 host
.enable_event_handlers
= True
930 self
.sched
.get_and_register_status_brok(host
)
932 #ENABLE_HOST_FLAP_DETECTION;<host_name>
933 def ENABLE_HOST_FLAP_DETECTION(self
, host
):
934 host
.flap_detection_enabled
= True
935 self
.sched
.get_and_register_status_brok(host
)
937 #ENABLE_HOST_FRESHNESS_CHECKS
938 def ENABLE_HOST_FRESHNESS_CHECKS(self
):
939 self
.conf
.check_host_freshness
= True
940 self
.conf
.explode_global_conf()
941 self
.sched
.get_and_register_update_program_status_brok()
943 #ENABLE_HOST_NOTIFICATIONS;<host_name>
944 def ENABLE_HOST_NOTIFICATIONS(self
, host
):
945 host
.notifications_enabled
= True
946 self
.sched
.get_and_register_status_brok(host
)
948 #ENABLE_HOST_SVC_CHECKS;<host_name>
949 def ENABLE_HOST_SVC_CHECKS(self
, host
):
950 for s
in host
.services
:
951 self
.ENABLE_SVC_CHECK(s
)
952 self
.sched
.get_and_register_status_brok(s
)
954 #ENABLE_HOST_SVC_NOTIFICATIONS;<host_name>
955 def ENABLE_HOST_SVC_NOTIFICATIONS(self
, host
):
956 for s
in host
.services
:
957 self
.ENABLE_SVC_NOTIFICATIONS(s
)
958 self
.sched
.get_and_register_status_brok(s
)
960 #ENABLE_NOTIFICATIONS
961 def ENABLE_NOTIFICATIONS(self
):
962 self
.conf
.enable_notifications
= True
963 self
.conf
.explode_global_conf()
964 self
.sched
.get_and_register_update_program_status_brok()
966 #ENABLE_PASSIVE_HOST_CHECKS;<host_name>
967 def ENABLE_PASSIVE_HOST_CHECKS(self
, host
):
968 host
.passive_checks_enabled
= True
969 self
.sched
.get_and_register_status_brok(host
)
971 #ENABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
972 def ENABLE_PASSIVE_SVC_CHECKS(self
, service
):
973 service
.passive_checks_enabled
= True
974 self
.sched
.get_and_register_status_brok(service
)
976 #ENABLE_PERFORMANCE_DATA
977 def ENABLE_PERFORMANCE_DATA(self
):
978 self
.conf
.process_performance_data
= True
979 self
.conf
.explode_global_conf()
980 self
.sched
.get_and_register_update_program_status_brok()
982 #ENABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
983 def ENABLE_SERVICEGROUP_HOST_CHECKS(self
, servicegroup
):
984 for service
in servicegroup
:
985 self
.ENABLE_HOST_CHECK(service
.host
)
987 #ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>
988 def ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS(self
, servicegroup
):
989 for service
in servicegroup
:
990 self
.ENABLE_HOST_NOTIFICATIONS(service
.host
)
992 #ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
993 def ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS(self
, servicegroup
):
994 for service
in servicegroup
:
995 self
.ENABLE_PASSIVE_HOST_CHECKS(service
.host
)
997 #ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>
998 def ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS(self
, servicegroup
):
999 for service
in servicegroup
:
1000 self
.ENABLE_PASSIVE_SVC_CHECKS(service
)
1002 #ENABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>
1003 def ENABLE_SERVICEGROUP_SVC_CHECKS(self
, servicegroup
):
1004 for service
in servicegroup
:
1005 self
.ENABLE_SVC_CHECK(service
)
1007 #ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>
1008 def ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS(self
, servicegroup
):
1009 for service
in servicegroup
:
1010 self
.ENABLE_SVC_NOTIFICATIONS(service
)
1012 #ENABLE_SERVICE_FRESHNESS_CHECKS
1013 def ENABLE_SERVICE_FRESHNESS_CHECKS(self
):
1014 self
.conf
.check_service_freshness
= True
1015 self
.conf
.explode_global_conf()
1016 self
.sched
.get_and_register_update_program_status_brok()
1018 #ENABLE_SVC_CHECK;<host_name>;<service_description>
1019 def ENABLE_SVC_CHECK(self
, service
):
1020 service
.active_checks_enabled
= True
1021 self
.sched
.get_and_register_status_brok(service
)
1023 #ENABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
1024 def ENABLE_SVC_EVENT_HANDLER(self
, service
):
1025 service
.event_handler_enabled
= True
1026 self
.sched
.get_and_register_status_brok(service
)
1028 #ENABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
1029 def ENABLE_SVC_FLAP_DETECTION(self
, service
):
1030 service
.flap_detection_enabled
= True
1031 self
.sched
.get_and_register_status_brok(service
)
1033 #ENABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
1034 def ENABLE_SVC_NOTIFICATIONS(self
, service
):
1035 service
.notifications_enabled
= True
1036 self
.sched
.get_and_register_status_brok(service
)
1038 #PROCESS_FILE;<file_name>;<delete>
1039 def PROCESS_FILE(self
, file_name
, delete
):
1042 #TODO : say that check is PASSIVE
1043 #PROCESS_HOST_CHECK_RESULT;<host_name>;<status_code>;<plugin_output>
1044 def PROCESS_HOST_CHECK_RESULT(self
, host
, status_code
, plugin_output
):
1045 #raise a PASSIVE check only if needed
1046 if self
.conf
.log_passive_checks
:
1047 logger
.log('PASSIVE HOST CHECK: %s;%d;%s' % (host
.get_name(), status_code
, plugin_output
))
1049 cls
= host
.__class
__
1050 #If globally disable OR locally, do not launch
1051 if cls
.accept_passive_checks
and host
.passive_checks_enabled
:
1052 i
= host
.launch_check(now
, force
=True)
1053 for chk
in host
.actions
:
1056 #Now we 'transform the check into a result'
1057 #So exit_status, output and status is eaten by the host
1058 c
.exit_status
= status_code
1059 c
.get_outputs(plugin_output
, host
.max_plugins_output_length
)
1060 c
.status
= 'waitconsume'
1061 self
.sched
.nb_check_received
+= 1
1062 #Ok now this result will be reap by scheduler the next loop
1065 #PROCESS_SERVICE_CHECK_RESULT;<host_name>;<service_description>;<return_code>;<plugin_output>
1066 def PROCESS_SERVICE_CHECK_RESULT(self
, service
, return_code
, plugin_output
):
1067 #raise a PASSIVE check only if needed
1068 if self
.conf
.log_passive_checks
:
1069 logger
.log('PASSIVE SERVICE CHECK: %s;%s;%d;%s' % (service
.host
.get_name(), service
.get_name(), return_code
, plugin_output
))
1071 cls
= service
.__class
__
1072 #If globally disable OR locally, do not launch
1073 if cls
.accept_passive_checks
and service
.passive_checks_enabled
:
1074 i
= service
.launch_check(now
, force
=True)
1075 for chk
in service
.actions
:
1078 #Now we 'transform the check into a result'
1079 #So exit_status, output and status is eaten by the service
1080 c
.exit_status
= return_code
1081 c
.get_outputs(plugin_output
, service
.max_plugins_output_length
)
1082 c
.status
= 'waitconsume'
1083 self
.sched
.nb_check_received
+= 1
1084 #Ok now this result will be reap by scheduler the next loop
1087 #READ_STATE_INFORMATION
1088 def READ_STATE_INFORMATION(self
):
1091 #REMOVE_HOST_ACKNOWLEDGEMENT;<host_name>
1092 def REMOVE_HOST_ACKNOWLEDGEMENT(self
, host
):
1093 host
.unacknowledge_problem()
1095 #REMOVE_SVC_ACKNOWLEDGEMENT;<host_name>;<service_description>
1096 def REMOVE_SVC_ACKNOWLEDGEMENT(self
, service
):
1097 service
.unacknowledge_problem()
1100 def RESTART_PROGRAM(self
):
1103 #SAVE_STATE_INFORMATION
1104 def SAVE_STATE_INFORMATION(self
):
1107 #SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1108 def SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME(self
, host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1111 #SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1112 def SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME(self
, host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1115 #SCHEDULE_CONTACT_DOWNTIME;<contact_name>;<start_time>;<end_time>;<author>;<comment>
1116 def SCHEDULE_CONTACT_DOWNTIME(self
, contact
, start_time
, end_time
, author
, comment
):
1117 dt
= ContactDowntime(contact
, start_time
, end_time
, author
, comment
)
1118 contact
.add_downtime(dt
)
1120 self
.sched
.get_and_register_status_brok(contact
)
1122 #SCHEDULE_FORCED_HOST_CHECK;<host_name>;<check_time>
1123 def SCHEDULE_FORCED_HOST_CHECK(self
, host
, check_time
):
1124 host
.schedule(force
=True, force_time
=check_time
)
1125 self
.sched
.get_and_register_status_brok(host
)
1127 #SCHEDULE_FORCED_HOST_SVC_CHECKS;<host_name>;<check_time>
1128 def SCHEDULE_FORCED_HOST_SVC_CHECKS(self
, host
, check_time
):
1129 for s
in host
.services
:
1130 self
.SCHEDULE_FORCED_SVC_CHECK(s
, check_time
)
1131 self
.sched
.get_and_register_status_brok(s
)
1133 #SCHEDULE_FORCED_SVC_CHECK;<host_name>;<service_description>;<check_time>
1134 def SCHEDULE_FORCED_SVC_CHECK(self
, service
, check_time
):
1135 service
.schedule(force
=True, force_time
=check_time
)
1136 self
.sched
.get_and_register_status_brok(service
)
1138 #SCHEDULE_HOSTGROUP_HOST_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1139 def SCHEDULE_HOSTGROUP_HOST_DOWNTIME(self
, hostgroup
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1142 #SCHEDULE_HOSTGROUP_SVC_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1143 def SCHEDULE_HOSTGROUP_SVC_DOWNTIME(self
, hostgroup
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1146 #SCHEDULE_HOST_CHECK;<host_name>;<check_time>
1147 def SCHEDULE_HOST_CHECK(self
, host
, check_time
):
1148 host
.schedule(force
=False, force_time
=check_time
)
1149 self
.sched
.get_and_register_status_brok(host
)
1151 #SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1152 def SCHEDULE_HOST_DOWNTIME(self
, host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1153 dt
= Downtime(host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1154 host
.add_downtime(dt
)
1156 self
.sched
.get_and_register_status_brok(host
)
1157 if trigger_id
!= 0 and trigger_id
in self
.sched
.downtimes
:
1158 self
.sched
.downtimes
[trigger_id
].trigger_me(dt
)
1160 #SCHEDULE_HOST_SVC_CHECKS;<host_name>;<check_time>
1161 def SCHEDULE_HOST_SVC_CHECKS(self
, host
, check_time
):
1162 for s
in host
.services
:
1163 self
.SCHEDULE_SVC_CHECK(s
, check_time
)
1164 self
.sched
.get_and_register_status_brok(s
)
1166 #SCHEDULE_HOST_SVC_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1167 def SCHEDULE_HOST_SVC_DOWNTIME(self
, host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1168 for s
in host
.services
:
1169 self
.SCHEDULE_SVC_DOWNTIME(s
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1171 #SCHEDULE_SERVICEGROUP_HOST_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1172 def SCHEDULE_SERVICEGROUP_HOST_DOWNTIME(self
, servicegroup
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1173 for h
in [s
.host
for s
in servicegroup
.get_services()]:
1174 self
.SCHEDULE_HOST_DOWNTIME(h
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1176 #SCHEDULE_SERVICEGROUP_SVC_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1177 def SCHEDULE_SERVICEGROUP_SVC_DOWNTIME(self
, servicegroup
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1178 for s
in servicegroup
.get_services():
1179 self
.SCHEDULE_SVC_DOWNTIME(s
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1181 #SCHEDULE_SVC_CHECK;<host_name>;<service_description>;<check_time>
1182 def SCHEDULE_SVC_CHECK(self
, service
, check_time
):
1183 service
.schedule(force
=False, force_time
=check_time
)
1184 self
.sched
.get_and_register_status_brok(service
)
1186 #SCHEDULE_SVC_DOWNTIME;<host_name>;<service_desription><start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1187 def SCHEDULE_SVC_DOWNTIME(self
, service
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1188 dt
= Downtime(service
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1189 service
.add_downtime(dt
)
1191 self
.sched
.get_and_register_status_brok(service
)
1192 if trigger_id
!= 0 and trigger_id
in self
.sched
.downtimes
:
1193 self
.sched
.downtimes
[trigger_id
].trigger_me(dt
)
1195 #SEND_CUSTOM_HOST_NOTIFICATION;<host_name>;<options>;<author>;<comment>
1196 def SEND_CUSTOM_HOST_NOTIFICATION(self
, host
, options
, author
, comment
):
1199 #SEND_CUSTOM_SVC_NOTIFICATION;<host_name>;<service_description>;<options>;<author>;<comment>
1200 def SEND_CUSTOM_SVC_NOTIFICATION(self
, service
, options
, author
, comment
):
1203 #SET_HOST_NOTIFICATION_NUMBER;<host_name>;<notification_number>
1204 def SET_HOST_NOTIFICATION_NUMBER(self
, host
, notification_number
):
1207 #SET_SVC_NOTIFICATION_NUMBER;<host_name>;<service_description>;<notification_number>
1208 def SET_SVC_NOTIFICATION_NUMBER(self
, service
, notification_number
):
1212 def SHUTDOWN_PROGRAM(self
):
1215 #START_ACCEPTING_PASSIVE_HOST_CHECKS
1216 def START_ACCEPTING_PASSIVE_HOST_CHECKS(self
):
1217 self
.conf
.accept_passive_host_checks
= True
1218 self
.conf
.explode_global_conf()
1219 self
.sched
.get_and_register_update_program_status_brok()
1221 #START_ACCEPTING_PASSIVE_SVC_CHECKS
1222 def START_ACCEPTING_PASSIVE_SVC_CHECKS(self
):
1223 self
.conf
.accept_passive_service_checks
= True
1224 self
.conf
.explode_global_conf()
1225 self
.sched
.get_and_register_update_program_status_brok()
1227 #START_EXECUTING_HOST_CHECKS
1228 def START_EXECUTING_HOST_CHECKS(self
):
1229 self
.conf
.execute_host_checks
= True
1230 self
.conf
.explode_global_conf()
1231 self
.sched
.get_and_register_update_program_status_brok()
1233 #START_EXECUTING_SVC_CHECKS
1234 def START_EXECUTING_SVC_CHECKS(self
):
1235 self
.conf
.execute_service_checks
= True
1236 self
.conf
.explode_global_conf()
1237 self
.sched
.get_and_register_update_program_status_brok()
1239 #START_OBSESSING_OVER_HOST;<host_name>
1240 def START_OBSESSING_OVER_HOST(self
, host
):
1241 host
.obsess_over_host
= True
1242 self
.sched
.get_and_register_status_brok(host
)
1244 #START_OBSESSING_OVER_HOST_CHECKS
1245 def START_OBSESSING_OVER_HOST_CHECKS(self
):
1246 self
.conf
.obsess_over_hosts
= True
1247 self
.conf
.explode_global_conf()
1249 #START_OBSESSING_OVER_SVC;<host_name>;<service_description>
1250 def START_OBSESSING_OVER_SVC(self
, service
):
1251 service
.obsess_over_service
= True
1252 self
.sched
.get_and_register_status_brok(service
)
1254 #START_OBSESSING_OVER_SVC_CHECKS
1255 def START_OBSESSING_OVER_SVC_CHECKS(self
):
1256 self
.conf
.obsess_over_services
= True
1257 self
.conf
.explode_global_conf()
1258 self
.sched
.get_and_register_update_program_status_brok()
1260 #STOP_ACCEPTING_PASSIVE_HOST_CHECKS
1261 def STOP_ACCEPTING_PASSIVE_HOST_CHECKS(self
):
1262 self
.accept_passive_host_checks
= False
1263 self
.conf
.explode_global_conf()
1264 self
.sched
.get_and_register_update_program_status_brok()
1266 #STOP_ACCEPTING_PASSIVE_SVC_CHECKS
1267 def STOP_ACCEPTING_PASSIVE_SVC_CHECKS(self
):
1268 self
.accept_passive_service_checks
= False
1269 self
.conf
.explode_global_conf()
1270 self
.sched
.get_and_register_update_program_status_brok()
1272 #STOP_EXECUTING_HOST_CHECKS
1273 def STOP_EXECUTING_HOST_CHECKS(self
):
1274 self
.conf
.execute_host_checks
= False
1275 self
.conf
.explode_global_conf()
1276 self
.sched
.get_and_register_update_program_status_brok()
1278 #STOP_EXECUTING_SVC_CHECKS
1279 def STOP_EXECUTING_SVC_CHECKS(self
):
1280 self
.conf
.execute_service_checks
= False
1281 self
.conf
.explode_global_conf()
1282 self
.sched
.get_and_register_update_program_status_brok()
1284 #STOP_OBSESSING_OVER_HOST;<host_name>
1285 def STOP_OBSESSING_OVER_HOST(self
, host
):
1286 host
.obsess_over_host
= False
1287 self
.sched
.get_and_register_status_brok(host
)
1289 #STOP_OBSESSING_OVER_HOST_CHECKS
1290 def STOP_OBSESSING_OVER_HOST_CHECKS(self
):
1291 self
.conf
.obsess_over_hosts
= False
1292 self
.conf
.explode_global_conf()
1293 self
.sched
.get_and_register_update_program_status_brok()
1295 #STOP_OBSESSING_OVER_SVC;<host_name>;<service_description>
1296 def STOP_OBSESSING_OVER_SVC(self
, service
):
1297 service
.obsess_over_service
= False
1298 self
.sched
.get_and_register_status_brok(service
)
1300 #STOP_OBSESSING_OVER_SVC_CHECKS
1301 def STOP_OBSESSING_OVER_SVC_CHECKS(self
):
1302 self
.conf
.obsess_over_services
= False
1303 self
.conf
.explode_global_conf()
1304 self
.sched
.get_and_register_update_program_status_brok()
1307 ### Now the shinken specific ones
1308 #LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>
1309 def LAUNCH_SVC_EVENT_HANDLER(self
, service
):
1310 service
.get_event_handlers(externalcmd
=True)
1313 #LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>
1314 def LAUNCH_HOST_EVENT_HANDLER(self
, host
):
1315 host
.get_event_handlers(externalcmd
=True)
1318 #ADD_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>
1319 def ADD_SIMPLE_HOST_DEPENDENCY(self
, son
, father
):
1320 if not son
.is_linked_with_host(father
):
1321 print "Doing simple link between", son
.get_name(), 'and', father
.get_name()
1322 # Add a dep link between the son and the father
1323 son
.add_host_act_dependancy(father
, ['w', 'u', 'd'], None, True)
1324 self
.sched
.get_and_register_status_brok(son
)
1325 self
.sched
.get_and_register_status_brok(father
)
1328 #ADD_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>
1329 def DEL_HOST_DEPENDENCY(self
, son
, father
):
1330 if son
.is_linked_with_host(father
):
1331 print "removing simple link between", son
.get_name(), 'and', father
.get_name()
1332 son
.del_host_act_dependancy(father
)
1333 self
.sched
.get_and_register_status_brok(son
)
1334 self
.sched
.get_and_register_status_brok(father
)
1337 #ADD_SIMPLE_POLLER;realm_name;poller_name;address;port
1338 def ADD_SIMPLE_POLLER(self
, realm_name
, poller_name
, address
, port
):
1339 print "I need to add the poller", realm_name
, poller_name
, address
, port
1341 # First we look for the realm
1342 r
= self
.conf
.realms
.find_by_name(realm_name
)
1344 print "Sorry, the realm %s is unknown" % realm_name
1346 print "We found the realm", r
1347 # TODO : backport this in the config class?
1348 # We create the PollerLink object
1349 t
= {'poller_name' : poller_name
, 'address' : address
, 'port' : port
}
1353 p
.prepare_for_conf()
1354 parameters
= {'max_plugins_output_length' : self
.conf
.max_plugins_output_length
}
1355 p
.add_global_conf_parameters(parameters
)
1356 self
.arbiter
.conf
.pollers
[p
.id] = p
1357 self
.arbiter
.dispatcher
.elements
.append(p
)
1358 self
.arbiter
.dispatcher
.satellites
.append(p
)
1361 r
.fill_potential_pollers()
1362 print "Poller %s added" % poller_name
1363 print "Potential", r
.get_potential_satellites_by_type('poller')
1366 if __name__
== '__main__':
1369 FIFO_PATH
= '/tmp/my_fifo'
1371 if os
.path
.exists(FIFO_PATH
):
1372 os
.unlink(FIFO_PATH
)
1374 if not os
.path
.exists(FIFO_PATH
):
1376 os
.mkfifo(FIFO_PATH
, 0660)
1377 my_fifo
= open(FIFO_PATH
, 'w+')
1378 print "my_fifo:", my_fifo
1380 print open(FIFO_PATH
, 'r').readline()