*A little cleanup in the livestatus test
[shinken.git] / shinken / external_command.py
blob85ba4c1046bfa3a59d41768aba21bfdfcb23dbb5
1 #!/usr/bin/env python
2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
6 #This file is part of Shinken.
8 #Shinken is free software: you can redistribute it and/or modify
9 #it under the terms of the GNU Affero General Public License as published by
10 #the Free Software Foundation, either version 3 of the License, or
11 #(at your option) any later version.
13 #Shinken is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #GNU Affero General Public License for more details.
18 #You should have received a copy of the GNU Affero General Public License
19 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
22 import os, time
24 from shinken.util import to_int, to_bool
25 from shinken.downtime import Downtime
26 from shinken.contactdowntime import ContactDowntime
27 from shinken.comment import Comment
28 from shinken.command import CommandCall
29 from shinken.log import logger
31 class ExternalCommand:
32 my_type = 'externalcommand'
33 def __init__(self, cmd_line):
34 self.cmd_line = cmd_line
37 class ExternalCommandManager:
39 commands = {
40 'CHANGE_CONTACT_MODSATTR' : {'global' : True, 'args' : ['contact', None]},
41 'CHANGE_CONTACT_MODHATTR' : {'global' : True, 'args' : ['contact', None]},
42 'CHANGE_CONTACT_MODATTR' : {'global' : True, 'args' : ['contact', None]},
43 'CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD' : {'global' : True, 'args' : ['contact', 'time_period']},
44 'ADD_SVC_COMMENT' : {'global' : False, 'args' : ['service', 'to_bool', 'author', None]},
45 'ADD_HOST_COMMENT' : {'global' : False, 'args' : ['host', 'to_bool', 'author', None]},
46 'ACKNOWLEDGE_SVC_PROBLEM' : {'global' : False, 'args' : ['service' , 'to_int', 'to_bool', 'to_bool', 'author', None]},
47 'ACKNOWLEDGE_HOST_PROBLEM' : {'global' : False, 'args' : ['host', 'to_int', 'to_bool', 'to_bool', 'author', None]},
48 'CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD' : {'global' : True, 'args' : ['contact', 'time_period']},
49 'CHANGE_CUSTOM_CONTACT_VAR' : {'global' : True, 'args' : ['contact', None,None]},
50 'CHANGE_CUSTOM_HOST_VAR' : {'global' : False, 'args' : ['host', None,None]},
51 'CHANGE_CUSTOM_SVC_VAR' : {'global' : False, 'args' : ['service', None,None]},
52 'CHANGE_GLOBAL_HOST_EVENT_HANDLER' : {'global' : True, 'args' : ['command']},
53 'CHANGE_GLOBAL_SVC_EVENT_HANDLER' : {'global' : True, 'args' : ['command']},
54 'CHANGE_HOST_CHECK_COMMAND' : {'global' : False, 'args' : ['host', 'command']},
55 'CHANGE_HOST_CHECK_TIMEPERIOD' : {'global' : False, 'args' : ['host', 'time_period']},
56 'CHANGE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host', 'command']},
57 'CHANGE_HOST_MODATTR' : {'global' : False, 'args' : ['host', 'to_int']},
58 'CHANGE_MAX_HOST_CHECK_ATTEMPTS': {'global' : False, 'args' : ['host', 'to_int']},
59 'CHANGE_MAX_SVC_CHECK_ATTEMPTS' : {'global' : False, 'args' : ['service', 'to_int']},
60 'CHANGE_NORMAL_HOST_CHECK_INTERVAL' : {'global' : False, 'args' : ['host', 'to_int']},
61 'CHANGE_NORMAL_SVC_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
62 'CHANGE_RETRY_HOST_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
63 'CHANGE_RETRY_SVC_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
64 'CHANGE_SVC_CHECK_COMMAND' : {'global' : False, 'args' : ['service', 'command']},
65 'CHANGE_SVC_CHECK_TIMEPERIOD' : {'global' : False, 'args' : ['service', 'time_period']},
66 'CHANGE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service', 'command']},
67 'CHANGE_SVC_MODATTR' : {'global' : False, 'args' : ['service', 'to_int']},
68 'CHANGE_SVC_NOTIFICATION_TIMEPERIOD' : {'global' : False, 'args' : ['service', 'time_period']},
69 'DELAY_HOST_NOTIFICATION' : {'global' : False, 'args' : ['host', 'to_int']},
70 'DELAY_SVC_NOTIFICATION' : {'global' : False, 'args' : ['service', 'to_int']},
71 'DEL_ALL_HOST_COMMENTS' : {'global' : False, 'args' : ['host']},
72 'DEL_ALL_SVC_COMMENTS' : {'global' : False, 'args' : ['service']},
73 'DEL_CONTACT_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
74 'DEL_HOST_COMMENT' : {'global' : True, 'args' : ['to_int']},
75 'DEL_HOST_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
76 'DEL_SVC_COMMENT' : {'global' : True, 'args' : ['to_int']},
77 'DEL_SVC_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
78 'DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST' : {'global' : False, 'args' : ['host']},
79 'DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
80 'DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
81 'DISABLE_CONTACT_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
82 'DISABLE_CONTACT_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
83 'DISABLE_EVENT_HANDLERS' : {'global' : True, 'args' : []},
84 'DISABLE_FAILURE_PREDICTION' : {'global' : True, 'args' : []},
85 'DISABLE_FLAP_DETECTION' : {'global' : True, 'args' : []},
86 'DISABLE_HOSTGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
87 'DISABLE_HOSTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
88 'DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
89 'DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
90 'DISABLE_HOSTGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
91 'DISABLE_HOSTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
92 'DISABLE_HOST_AND_CHILD_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
93 'DISABLE_HOST_CHECK' : {'global' : False, 'args' : ['host']},
94 'DISABLE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
95 'DISABLE_HOST_FLAP_DETECTION' : {'global' : False, 'args' : ['host']},
96 'DISABLE_HOST_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
97 'DISABLE_HOST_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
98 'DISABLE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host']},
99 'DISABLE_HOST_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
100 'DISABLE_NOTIFICATIONS' : {'global' : True, 'args' : []},
101 'DISABLE_PASSIVE_HOST_CHECKS' : {'global' : False, 'args' : ['host']},
102 'DISABLE_PASSIVE_SVC_CHECKS' : {'global' : False, 'args' : ['service']},
103 'DISABLE_PERFORMANCE_DATA' : {'global' : True, 'args' : []},
104 'DISABLE_SERVICEGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
105 'DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
106 'DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
107 'DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
108 'DISABLE_SERVICEGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
109 'DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
110 'DISABLE_SERVICE_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
111 'DISABLE_SERVICE_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
112 'DISABLE_SVC_CHECK' : {'global' : False, 'args' : ['service']},
113 'DISABLE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
114 'DISABLE_SVC_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
115 'DISABLE_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['service']},
116 'ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST' : {'global' : False, 'args' : ['host']},
117 'ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
118 'ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
119 'ENABLE_CONTACT_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
120 'ENABLE_CONTACT_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
121 'ENABLE_EVENT_HANDLERS' : {'global' : True, 'args' : []},
122 'ENABLE_FAILURE_PREDICTION' : {'global' : True, 'args' : []},
123 'ENABLE_FLAP_DETECTION' : {'global' : True, 'args' : []},
124 'ENABLE_HOSTGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
125 'ENABLE_HOSTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
126 'ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
127 'ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
128 'ENABLE_HOSTGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
129 'ENABLE_HOSTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
130 'ENABLE_HOST_AND_CHILD_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
131 'ENABLE_HOST_CHECK' : {'global' : False, 'args' : ['host']},
132 'ENABLE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
133 'ENABLE_HOST_FLAP_DETECTION' : {'global' : False, 'args' : ['host']},
134 'ENABLE_HOST_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
135 'ENABLE_HOST_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
136 'ENABLE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host']},
137 'ENABLE_HOST_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
138 'ENABLE_NOTIFICATIONS' : {'global' : True, 'args' : []},
139 'ENABLE_PASSIVE_HOST_CHECKS' : {'global' : False, 'args' : ['host']},
140 'ENABLE_PASSIVE_SVC_CHECKS' : {'global' : False, 'args' : ['service']},
141 'ENABLE_PERFORMANCE_DATA' : {'global' : True, 'args' : []},
142 'ENABLE_SERVICEGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
143 'ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
144 'ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
145 'ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
146 'ENABLE_SERVICEGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
147 'ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
148 'ENABLE_SERVICE_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
149 'ENABLE_SVC_CHECK': {'global' : False, 'args' : ['service']},
150 'ENABLE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
151 'ENABLE_SVC_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
152 'ENABLE_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['service']},
153 'PROCESS_FILE' : {'global' : True, 'args' : [None, 'to_bool']},
154 'PROCESS_HOST_CHECK_RESULT' : {'global' : False, 'args' : ['host', 'to_int', None]},
155 'PROCESS_SERVICE_CHECK_RESULT' : {'global' : False, 'args' : ['service', 'to_int', None]},
156 'READ_STATE_INFORMATION' : {'global' : True, 'args' : []},
157 'REMOVE_HOST_ACKNOWLEDGEMENT' : {'global' : False, 'args' : ['host']},
158 'REMOVE_SVC_ACKNOWLEDGEMENT' : {'global' : False, 'args' : ['service']},
159 'RESTART_PROGRAM' : {'global' : True, 'args' : []},
160 'SAVE_STATE_INFORMATION' : {'global' : True, 'args' : []},
161 'SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
162 'SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
163 'SCHEDULE_CONTACT_DOWNTIME' : {'global' : True, 'args' : ['contact', 'to_int', 'to_int', 'author', None]},
164 'SCHEDULE_FORCED_HOST_CHECK' : {'global' : False, 'args' : ['host', 'to_int']},
165 'SCHEDULE_FORCED_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host', 'to_int']},
166 'SCHEDULE_FORCED_SVC_CHECK' : {'global' : False, 'args' : ['service', 'to_int']},
167 'SCHEDULE_HOSTGROUP_HOST_DOWNTIME' : {'global' : True, 'args' : ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
168 'SCHEDULE_HOSTGROUP_SVC_DOWNTIME' : {'global' : True, 'args' : ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
169 'SCHEDULE_HOST_CHECK' : {'global' : False, 'args' : ['host', 'to_int']},
170 'SCHEDULE_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
171 'SCHEDULE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host', 'to_int']},
172 'SCHEDULE_HOST_SVC_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
173 'SCHEDULE_SERVICEGROUP_HOST_DOWNTIME' : {'global' : True, 'args' : ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
174 'SCHEDULE_SERVICEGROUP_SVC_DOWNTIME' : {'global' : True, 'args' : ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
175 'SCHEDULE_SVC_CHECK' : {'global' : False, 'args' : ['service', 'to_int']},
176 'SCHEDULE_SVC_DOWNTIME' : {'global' : False, 'args' : ['service', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
177 'SEND_CUSTOM_HOST_NOTIFICATION' : {'global' : False, 'args' : ['host', 'to_int', 'author', None]},
178 'SEND_CUSTOM_SVC_NOTIFICATION' : {'global' : False, 'args' : ['service', 'to_int', 'author', None]},
179 'SET_HOST_NOTIFICATION_NUMBER' : {'global' : False, 'args' : ['host', 'to_int']},
180 'SET_SVC_NOTIFICATION_NUMBER' : {'global' : False, 'args' : ['service', 'to_int']},
181 'SHUTDOWN_PROGRAM' : {'global' : True, 'args' : []},
182 'START_ACCEPTING_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : []},
183 'START_ACCEPTING_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : []},
184 'START_EXECUTING_HOST_CHECKS' : {'global' : True, 'args' : []},
185 'START_EXECUTING_SVC_CHECKS' : {'global' : True, 'args' : []},
186 'START_OBSESSING_OVER_HOST' : {'global' : False, 'args' : ['host']},
187 'START_OBSESSING_OVER_HOST_CHECKS' : {'global' : True, 'args' : []},
188 'START_OBSESSING_OVER_SVC' : {'global' : False, 'args' : ['service']},
189 'START_OBSESSING_OVER_SVC_CHECKS' : {'global' : True, 'args' : []},
190 'STOP_ACCEPTING_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : []},
191 'STOP_ACCEPTING_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : []},
192 'STOP_EXECUTING_HOST_CHECKS' : {'global' : True, 'args' : []},
193 'STOP_EXECUTING_SVC_CHECKS' : {'global' : True, 'args' : []},
194 'STOP_OBSESSING_OVER_HOST' : {'global' : False, 'args' : ['host']},
195 'STOP_OBSESSING_OVER_HOST_CHECKS' : {'global' : True, 'args' : []},
196 'STOP_OBSESSING_OVER_SVC' : {'global' : False, 'args' : ['service']},
197 'STOP_OBSESSING_OVER_SVC_CHECKS' : {'global' : True, 'args' : []},
198 'LAUNCH_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
199 'LAUNCH_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
200 # Now internal calls
201 'ADD_SIMPLE_HOST_DEPENDENCY' : {'global' : False, 'args' : ['host', 'host']},
202 'DEL_HOST_DEPENDENCY' : {'global' : False, 'args' : ['host', 'host']},
206 def __init__(self, conf, mode):
207 self.mode = mode
208 self.conf = conf
209 self.hosts = conf.hosts
210 self.services = conf.services
211 self.contacts = conf.contacts
212 self.hostgroups = conf.hostgroups
213 self.commands = conf.commands
214 self.servicegroups = conf.servicegroups
215 self.contactgroups = conf.contactgroups
216 self.timeperiods = conf.timeperiods
217 self.pipe_path = conf.command_file
218 self.fifo = None
219 if self.mode == 'dispatcher':
220 self.confs = conf.confs
223 def load_scheduler(self, scheduler):
224 self.sched = scheduler
227 def open(self):
228 #At the first open del and create the fifo
229 if self.fifo == None:
230 if os.path.exists(self.pipe_path):
231 os.unlink(self.pipe_path)
233 if not os.path.exists(self.pipe_path):
234 os.umask(0)
235 try :
236 os.mkfifo(self.pipe_path, 0660)
237 open(self.pipe_path, 'w+', os.O_NONBLOCK)
238 except OSError , exp:
239 print "Error : pipe creation failed (",self.pipe_path,')', exp
240 return None
241 self.fifo = os.open(self.pipe_path, os.O_NONBLOCK)
242 #print 'Fifo:', self.fifo
243 return self.fifo
246 def get(self):
247 buf = os.read(self.fifo, 8096)
248 os.close(self.fifo)
249 r = []
250 if buf != '':
251 t = buf.split('\n')
252 for s in t:
253 if s != '':
254 excmd = ExternalCommand(s)
255 r.append(excmd)
256 return r
257 return []
261 def resolve_command(self, excmd):
262 command = excmd.cmd_line
263 command = command.strip()
264 #Only log if we are in the Arbiter
265 if self.mode == 'dispatcher':
266 logger.log('EXTERNAL COMMAND: '+command.rstrip())
267 self.get_command_and_args(command)
270 #Ok the command is not for every one, so we search
271 #by the hostname which scheduler have the host. Then send
272 #it the command
273 def search_host_and_dispatch(self, host_name, command):
274 print "Calling search_host_and_dispatch", 'for', host_name
275 for cfg in self.confs.values():
276 if cfg.hosts.find_by_name(host_name) is not None:
277 print "Host", host_name, "found in a configuration"
278 if cfg.is_assigned :
279 sched = cfg.assigned_to
280 print "Sending command to the scheduler", sched.get_name()
281 sched.run_external_command(command)
282 else:
283 print "Problem: a configuration is found, but is not assigned!"
284 else:
285 logger.log("Warning: Passive check result was received for host '%s', but the host could not be found!" % host_name)
286 #print "Sorry but the host", host_name, "was not found"
289 #The command is global, so sent it to every schedulers
290 def dispatch_global_command(self, command):
291 for sched in self.conf.schedulerlinks:
292 print "Sending a command", command, 'to scheduler', sched
293 if sched.alive:
294 sched.run_external_command(command)
297 #We need to get the first part, the command name
298 def get_command_and_args(self, command):
299 print "Trying to resolve", command
300 if command[-1] == '\n':
301 command = command[:-1]
302 elts = command.split(';')
303 part1 = elts[0]
305 elts2 = part1.split(' ')
306 print "Elts2:", elts2
307 if len(elts2) != 2:
308 print "Malformed command", command
309 return None
310 c_name = elts2[1]
312 print "Get command name", c_name
313 if c_name not in ExternalCommandManager.commands:
314 print "This command is not recognized, sorry"
315 return None
317 if self.mode == 'dispatcher' and ExternalCommandManager.commands[c_name]['global']:
318 print "This command is a global one, we resent it to all schedulers"
319 self.dispatch_global_command(command)
320 return None
321 print "Is global?", c_name, ExternalCommandManager.commands[c_name]['global']
322 print "Mode:", self.mode
323 print "This command have arguments:", ExternalCommandManager.commands[c_name]['args'], len(ExternalCommandManager.commands[c_name]['args'])
325 args = []
326 i = 1
327 in_service = False
328 tmp_host = ''
329 try:
330 for elt in elts[1:]:
331 print "Searching for a new arg:", elt, i
332 val = elt.strip()
333 if val[-1] == '\n':
334 val = val[:-1]
336 print "For command arg", val
338 if not in_service:
339 type_searched = ExternalCommandManager.commands[c_name]['args'][i-1]
340 print "Search for a arg", type_searched
342 if type_searched == 'host':
343 if self.mode == 'dispatcher':
344 self.search_host_and_dispatch(val, command)
345 return None
346 h = self.hosts.find_by_name(val)
347 if h is not None:
348 args.append(h)
350 elif type_searched == 'contact':
351 c = self.contacts.find_by_name(val)
352 if c is not None:
353 args.append(c)
355 elif type_searched == 'time_period':
356 t = self.timeperiods.find_by_name(val)
357 if t is not None:
358 args.append(t)
360 elif type_searched == 'to_bool':
361 args.append(to_bool(val))
363 elif type_searched == 'to_int':
364 args.append(to_int(val))
366 elif type_searched in ('author', None):
367 args.append(val)
369 elif type_searched == 'command':
370 c = self.commands.find_cmd_by_name(val)
371 if c is not None:
372 args.append(val)#the find will be redone by
373 #the commandCall creation, but != None
374 #is usefull so a bad command will be catch
376 elif type_searched == 'host_group':
377 hg = self.hostgroups.find_by_name(val)
378 if hg is not None:
379 args.append(hg)
381 elif type_searched == 'service_group':
382 sg = self.servicegroups.find_by_name(val)
383 if sg is not None:
384 args.append(sg)
386 elif type_searched == 'contact_group':
387 cg = self.contact_groups.find_by_name(val)
388 if cg is not None:
389 args.append(cg)
391 #special case: service are TWO args host;service, so one more loop
392 #to get the two parts
393 elif type_searched == 'service':
394 in_service = True
395 tmp_host = elt.strip()
396 print "TMP HOST", tmp_host
397 if tmp_host[-1] == '\n':
398 tmp_host = tmp_host[:-1]
400 if self.mode == 'dispatcher':
401 self.search_host_and_dispatch(tmp_host, command)
402 return None
404 i += 1
405 else:
406 in_service = False
407 srv_name = elt
408 if srv_name[-1] == '\n':
409 srv_name = srv_name[:-1]
410 print "Got service full", tmp_host, srv_name
411 s = self.services.find_srv_by_name_and_hostname(tmp_host, srv_name)
412 if s is not None:
413 args.append(s)
414 else: #error, must be logged
415 logger.log("Warning: a command was received for service '%s' on host '%s', but the service could not be found!" % (srv_name, tmp_host))
417 except IndexError:
418 print "Sorry, the arguments are not corrects"
419 return None
420 print 'Finally got ARGS:', args
421 if len(args) == len(ExternalCommandManager.commands[c_name]['args']):
422 print "OK, we can call the command", c_name, "with", args
423 f = getattr(self, c_name)
424 apply(f, args)
425 else:
426 print "Sorry, the arguments are not corrects", args
430 #CHANGE_CONTACT_MODSATTR;<contact_name>;<value>
431 def CHANGE_CONTACT_MODSATTR(self, contact, value):
432 pass
434 #CHANGE_CONTACT_MODHATTR;<contact_name>;<value>
435 def CHANGE_CONTACT_MODHATTR(self, contact, value):
436 pass
438 #CHANGE_CONTACT_MODATTR;<contact_name>;<value>
439 def CHANGE_CONTACT_MODATTR(self, contact, value):
440 pass
442 #CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>
443 def CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD(self, contact, notification_timeperiod):
444 contact.host_notification_period = notification_timeperiod
445 self.sched.get_and_register_status_brok(contact)
447 #ADD_SVC_COMMENT;<host_name>;<service_description>;<persistent>;<author>;<comment>
448 def ADD_SVC_COMMENT(self, service, persistent, author, comment):
449 c = Comment(service, persistent, author, comment, 2, 1, 1, False, 0)
450 service.add_comment(c)
451 self.sched.add(c)
453 #ADD_HOST_COMMENT;<host_name>;<persistent>;<author>;<comment>
454 def ADD_HOST_COMMENT(self, host, persistent, author, comment):
455 c = Comment(host, persistent, author, comment, 1, 1, 1, False, 0)
456 host.add_comment(c)
457 self.sched.add(c)
459 #ACKNOWLEDGE_SVC_PROBLEM;<host_name>;<service_description>;<sticky>;<notify>;<persistent>;<author>;<comment>
460 def ACKNOWLEDGE_SVC_PROBLEM(self, service, sticky, notify, persistent, author, comment):
461 service.acknowledge_problem(sticky, notify, persistent, author, comment)
463 #ACKNOWLEDGE_HOST_PROBLEM;<host_name>;<sticky>;<notify>;<persistent>;<author>;<comment>
464 #TODO : add a better ACK management
465 def ACKNOWLEDGE_HOST_PROBLEM(self, host, sticky, notify, persistent, author, comment):
466 host.acknowledge_problem(sticky, notify, persistent, author, comment)
468 #CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>
469 def CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD(self, contact, notification_timeperiod):
470 contact.service_notification_period = notification_timeperiod
471 self.sched.get_and_register_status_brok(contact)
473 #CHANGE_CUSTOM_CONTACT_VAR;<contact_name>;<varname>;<varvalue>
474 def CHANGE_CUSTOM_CONTACT_VAR(self, contact, varname, varvalue):
475 contact.customs[varname.upper()] = varvalue
477 #CHANGE_CUSTOM_HOST_VAR;<host_name>;<varname>;<varvalue>
478 def CHANGE_CUSTOM_HOST_VAR(self, host, varname, varvalue):
479 host.customs[varname.upper()] = varvalue
481 #CHANGE_CUSTOM_SVC_VAR;<host_name>;<service_description>;<varname>;<varvalue>
482 def CHANGE_CUSTOM_SVC_VAR(self, service, varname, varvalue):
483 service.customs[varname.upper()] = varvalue
485 #CHANGE_GLOBAL_HOST_EVENT_HANDLER;<event_handler_command>
486 def CHANGE_GLOBAL_HOST_EVENT_HANDLER(self, event_handler_command):
487 pass
489 #CHANGE_GLOBAL_SVC_EVENT_HANDLER;<event_handler_command>
490 def CHANGE_GLOBAL_SVC_EVENT_HANDLER(self, event_handler_command):
491 pass
493 #CHANGE_HOST_CHECK_COMMAND;<host_name>;<check_command>
494 def CHANGE_HOST_CHECK_COMMAND(self, host, check_command):
495 host.check_command = CommandCall(self.commands, check_command, poller_tag=host.poller_tag)
496 self.sched.get_and_register_status_brok(host)
498 #CHANGE_HOST_CHECK_TIMEPERIOD;<host_name>;<timeperiod>
499 def CHANGE_HOST_CHECK_TIMEPERIOD(self, host, timeperiod):
500 host.check_period = timeperiod
501 self.sched.get_and_register_status_brok(service)
503 #CHANGE_HOST_EVENT_HANDLER;<host_name>;<event_handler_command>
504 def CHANGE_HOST_EVENT_HANDLER(self, host, event_handler_command):
505 host.event_handler = CommandCall(self.commands, event_handler_command)
506 self.sched.get_and_register_status_brok(host)
508 #CHANGE_HOST_MODATTR;<host_name>;<value>
509 def CHANGE_HOST_MODATTR(self, host, value):
510 pass
512 #CHANGE_MAX_HOST_CHECK_ATTEMPTS;<host_name>;<check_attempts>
513 def CHANGE_MAX_HOST_CHECK_ATTEMPTS(self, host, check_attempts):
514 host.max_check_attempts = check_attempts
515 self.sched.get_and_register_status_brok(host)
517 #CHANGE_MAX_SVC_CHECK_ATTEMPTS;<host_name>;<service_description>;<check_attempts>
518 def CHANGE_MAX_SVC_CHECK_ATTEMPTS(self, service, check_attempts):
519 service.max_check_attempts = check_attempts
520 self.sched.get_and_register_status_brok(service)
522 #CHANGE_NORMAL_HOST_CHECK_INTERVAL;<host_name>;<check_interval>
523 def CHANGE_NORMAL_HOST_CHECK_INTERVAL(self, host, check_interval):
524 host.check_interval = check_interval
525 self.sched.get_and_register_status_brok(host)
527 #CHANGE_NORMAL_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
528 def CHANGE_NORMAL_SVC_CHECK_INTERVAL(self, service, check_interval):
529 service.check_interval = check_interval
530 self.sched.get_and_register_status_brok(service)
532 #CHANGE_RETRY_HOST_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
533 def CHANGE_RETRY_HOST_CHECK_INTERVAL(self, host, check_interval):
534 host.retry_interval = check_interval
535 self.sched.get_and_register_status_brok(host)
537 #CHANGE_RETRY_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
538 def CHANGE_RETRY_SVC_CHECK_INTERVAL(self, service, check_interval):
539 service.retry_interval = check_interval
540 self.sched.get_and_register_status_brok(service)
542 #CHANGE_SVC_CHECK_COMMAND;<host_name>;<service_description>;<check_command>
543 def CHANGE_SVC_CHECK_COMMAND(self, service, check_command):
544 service.check_command = CommandCall(self.commands, check_command, poller_tag=service.poller_tag)
545 self.sched.get_and_register_status_brok(service)
547 #CHANGE_SVC_CHECK_TIMEPERIOD;<host_name>;<service_description>;<check_timeperiod>
548 def CHANGE_SVC_CHECK_TIMEPERIOD(self, service, check_timeperiod):
549 service.check_period = check_timeperiod
550 self.sched.get_and_register_status_brok(service)
552 #CHANGE_SVC_EVENT_HANDLER;<host_name>;<service_description>;<event_handler_command>
553 def CHANGE_SVC_EVENT_HANDLER(self, service, event_handler_command):
554 service.event_handler = CommandCall(self.commands, event_handler_command)
555 self.sched.get_and_register_status_brok(service)
557 #CHANGE_SVC_MODATTR;<host_name>;<service_description>;<value>
558 def CHANGE_SVC_MODATTR(self, service, value):
559 pass
561 #CHANGE_SVC_NOTIFICATION_TIMEPERIOD;<host_name>;<service_description>;<notification_timeperiod>
562 def CHANGE_SVC_NOTIFICATION_TIMEPERIOD(self, service, notification_timeperiod):
563 service.notification_period = notification_timeperiod
564 self.sched.get_and_register_status_brok(service)
566 #DELAY_HOST_NOTIFICATION;<host_name>;<notification_time>
567 def DELAY_HOST_NOTIFICATION(self, host, notification_time):
568 host.first_notification_delay = notification_time
569 self.sched.get_and_register_status_brok(host)
571 #DELAY_SVC_NOTIFICATION;<host_name>;<service_description>;<notification_time>
572 def DELAY_SVC_NOTIFICATION(self, service, notification_time):
573 service.first_notification_delay = notification_time
574 self.sched.get_and_register_status_brok(service)
576 #DEL_ALL_HOST_COMMENTS;<host_name>
577 def DEL_ALL_HOST_COMMENTS(self, host):
578 for c in host.comments:
579 self.DEL_HOST_COMMENT(c.id)
581 #DEL_ALL_SVC_COMMENTS;<host_name>;<service_description>
582 def DEL_ALL_SVC_COMMENTS(self, service):
583 for c in service.comments:
584 self.DEL_SVC_COMMENT(c.id)
586 #DEL_CONTACT_DOWNTIME;<downtime_id>
587 def DEL_CONTACT_DOWNTIME(self, downtime_id):
588 if downtime_id in self.sched.contact_downtimes:
589 self.sched.contact_downtimes[downtime_id].cancel()
592 #DEL_HOST_COMMENT;<comment_id>
593 def DEL_HOST_COMMENT(self, comment_id):
594 if comment_id in self.sched.comments:
595 self.sched.comments[comment_id].can_be_deleted = True
597 #DEL_HOST_DOWNTIME;<downtime_id>
598 def DEL_HOST_DOWNTIME(self, downtime_id):
599 if downtime_id in self.sched.downtimes:
600 self.sched.downtimes[downtime_id].cancel()
602 #DEL_SVC_COMMENT;<comment_id>
603 def DEL_SVC_COMMENT(self, comment_id):
604 if comment_id in self.sched.comments:
605 self.sched.comments[comment_id].can_be_deleted = True
607 #DEL_SVC_DOWNTIME;<downtime_id>
608 def DEL_SVC_DOWNTIME(self, downtime_id):
609 if downtime_id in self.sched.downtimes:
610 self.sched.downtimes[downtime_id].cancel()
612 #DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
613 def DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST(self, host):
614 pass
616 #DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>
617 def DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS(self, contactgroup):
618 for contact in contactgroup:
619 self.DISABLE_CONTACT_HOST_NOTIFICATIONS(contact)
621 #DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>
622 def DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS(self, contactgroup):
623 for contact in contactgroup:
624 self.DISABLE_CONTACT_SVC_NOTIFICATIONS(contact)
626 #DISABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
627 def DISABLE_CONTACT_HOST_NOTIFICATIONS(self, contact):
628 contact.host_notifications_enabled = False
629 self.sched.get_and_register_status_brok(contact)
631 #DISABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
632 def DISABLE_CONTACT_SVC_NOTIFICATIONS(self, contact):
633 contact.service_notifications_enabled = False
634 self.sched.get_and_register_status_brok(contact)
636 #DISABLE_EVENT_HANDLERS
637 def DISABLE_EVENT_HANDLERS(self):
638 self.conf.enable_event_handlers = False
639 self.conf.explode_global_conf()
640 self.sched.get_and_register_update_program_status_brok()
642 #DISABLE_FAILURE_PREDICTION
643 def DISABLE_FAILURE_PREDICTION(self):
644 self.conf.enable_failure_prediction = False
645 self.conf.explode_global_conf()
646 self.sched.get_and_register_update_program_status_brok()
648 #DISABLE_FLAP_DETECTION
649 def DISABLE_FLAP_DETECTION(self):
650 self.conf.enable_flap_detection = False
651 self.conf.explode_global_conf()
652 self.sched.get_and_register_update_program_status_brok()
654 #DISABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
655 def DISABLE_HOSTGROUP_HOST_CHECKS(self, hostgroup):
656 for host in hostgroup:
657 self.DISABLE_HOST_CHECK(host)
659 #DISABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>
660 def DISABLE_HOSTGROUP_HOST_NOTIFICATIONS(self, hostgroup):
661 for host in hostgroup:
662 self.DISABLE_HOST_NOTIFICATIONS(host)
664 #DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>
665 def DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS(self, hostgroup):
666 for host in hostgroup:
667 self.DISABLE_PASSIVE_HOST_CHECKS(host)
669 #DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>
670 def DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS(self, hostgroup):
671 for host in hostgroup:
672 for service in host.services:
673 self.DISABLE_PASSIVE_SVC_CHECKS(service)
675 #DISABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>
676 def DISABLE_HOSTGROUP_SVC_CHECKS(self, hostgroup):
677 for host in hostgroup:
678 for service in host.services:
679 self.DISABLE_SVC_CHECK(service)
681 #DISABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>
682 def DISABLE_HOSTGROUP_SVC_NOTIFICATIONS(self, hostgroup):
683 for host in hostgroup:
684 for service in host.services:
685 self.DISABLE_SVC_NOTIFICATIONS(service)
687 #DISABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name>
688 def DISABLE_HOST_AND_CHILD_NOTIFICATIONS(self, host):
689 pass
691 #DISABLE_HOST_CHECK;<host_name>
692 def DISABLE_HOST_CHECK(self, host):
693 host.active_checks_enabled = False
694 self.sched.get_and_register_status_brok(host)
696 #DISABLE_HOST_EVENT_HANDLER;<host_name>
697 def DISABLE_HOST_EVENT_HANDLER(self, host):
698 host.event_handler_enabled = False
699 self.sched.get_and_register_status_brok(host)
701 #DISABLE_HOST_FLAP_DETECTION;<host_name>
702 def DISABLE_HOST_FLAP_DETECTION(self, host):
703 host.flap_detection_enabled = False
704 self.sched.get_and_register_status_brok(host)
706 #DISABLE_HOST_FRESHNESS_CHECKS
707 def DISABLE_HOST_FRESHNESS_CHECKS(self, host):
708 host.check_freshness = False
709 self.sched.get_and_register_status_brok(host)
711 #DISABLE_HOST_NOTIFICATIONS;<host_name>
712 def DISABLE_HOST_NOTIFICATIONS(self, host):
713 host.notifications_enabled = False
714 self.sched.get_and_register_status_brok(host)
716 #DISABLE_HOST_SVC_CHECKS;<host_name>
717 def DISABLE_HOST_SVC_CHECKS(self, host):
718 for s in host.services:
719 self.DISABLE_SVC_CHECK(s)
720 self.sched.get_and_register_status_brok(s)
722 #DISABLE_HOST_SVC_NOTIFICATIONS;<host_name>
723 def DISABLE_HOST_SVC_NOTIFICATIONS(self, host):
724 for s in host.services:
725 self.DISABLE_SVC_NOTIFICATIONS(s)
726 self.sched.get_and_register_status_brok(s)
728 #DISABLE_NOTIFICATIONS
729 def DISABLE_NOTIFICATIONS(self):
730 self.conf.enable_notifications = False
731 self.conf.explode_global_conf()
732 self.sched.get_and_register_update_program_status_brok()
734 #DISABLE_PASSIVE_HOST_CHECKS;<host_name>
735 def DISABLE_PASSIVE_HOST_CHECKS(self, host):
736 host.passive_checks_enabled = False
737 self.sched.get_and_register_status_brok(host)
739 #DISABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
740 def DISABLE_PASSIVE_SVC_CHECKS(self, service):
741 service.passive_checks_enabled = False
742 self.sched.get_and_register_status_brok(service)
744 #DISABLE_PERFORMANCE_DATA
745 def DISABLE_PERFORMANCE_DATA(self):
746 self.conf.process_performance_data = False
747 self.conf.explode_global_conf()
748 self.sched.get_and_register_update_program_status_brok()
750 #DISABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
751 def DISABLE_SERVICEGROUP_HOST_CHECKS(self, servicegroup):
752 for service in servicegroup:
753 self.DISABLE_HOST_CHECK(service.host)
755 #DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>
756 def DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS(self, servicegroup):
757 for service in servicegroup:
758 self.DISABLE_HOST_NOTIFICATIONS(service.host)
760 #DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
761 def DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS(self, servicegroup):
762 for service in servicegroup:
763 self.DISABLE_PASSIVE_HOST_CHECKS(service.host)
765 #DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>
766 def DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS(self, servicegroup):
767 for service in servicegroup:
768 self.DISABLE_PASSIVE_SVC_CHECKS(service)
770 #DISABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>
771 def DISABLE_SERVICEGROUP_SVC_CHECKS(self, servicegroup):
772 for service in servicegroup:
773 self.DISABLE_SVC_CHECK(service)
775 #DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>
776 def DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS(self, servicegroup):
777 for service in servicegroup:
778 self.DISABLE_SVC_NOTIFICATIONS(service)
780 #DISABLE_SERVICE_FLAP_DETECTION;<host_name>;<service_description>
781 def DISABLE_SERVICE_FLAP_DETECTION(self, service):
782 service.flap_detection_enabled = False
783 self.sched.get_and_register_status_brok(service)
785 #DISABLE_SERVICE_FRESHNESS_CHECKS
786 def DISABLE_SERVICE_FRESHNESS_CHECKS(self):
787 self.conf.check_service_freshness = False
788 self.conf.explode_global_conf()
789 self.sched.get_and_register_update_program_status_brok()
791 #DISABLE_SVC_CHECK;<host_name>;<service_description>
792 def DISABLE_SVC_CHECK(self, service):
793 service.active_checks_enabled = False
794 self.sched.get_and_register_status_brok(service)
796 #DISABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
797 def DISABLE_SVC_EVENT_HANDLER(self, service):
798 service.event_handler_enabled = False
799 self.sched.get_and_register_status_brok(service)
801 #DISABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
802 def DISABLE_SVC_FLAP_DETECTION(self, service):
803 service.flap_detection_enabled = False
804 self.sched.get_and_register_status_brok(service)
806 #DISABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
807 def DISABLE_SVC_NOTIFICATIONS(self, service):
808 service.notifications_enabled = False
809 self.sched.get_and_register_status_brok(service)
811 #ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
812 def ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST(self, host):
813 pass
815 #ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>
816 def ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS(self, contactgroup):
817 for contact in contactgroup:
818 self.ENABLE_CONTACT_HOST_NOTIFICATIONS(contact)
820 #ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>
821 def ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS(self, contactgroup):
822 for contact in contactgroup:
823 self.ENABLE_CONTACT_SVC_NOTIFICATIONS(contact)
825 #ENABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
826 def ENABLE_CONTACT_HOST_NOTIFICATIONS(self, contact):
827 contact.host_notifications_enabled = True
828 self.sched.get_and_register_status_brok(contact)
830 #ENABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
831 def ENABLE_CONTACT_SVC_NOTIFICATIONS(self, contact):
832 contact.service_notifications_enabled = True
833 self.sched.get_and_register_status_brok(contact)
835 #ENABLE_EVENT_HANDLERS
836 def ENABLE_EVENT_HANDLERS(self):
837 self.conf.enable_event_handlers = True
838 self.conf.explode_global_conf()
839 self.sched.get_and_register_update_program_status_brok()
841 #ENABLE_FAILURE_PREDICTION
842 def ENABLE_FAILURE_PREDICTION(self):
843 self.conf.enable_failure_prediction = True
844 self.conf.explode_global_conf()
845 self.sched.get_and_register_update_program_status_brok()
847 #ENABLE_FLAP_DETECTION
848 def ENABLE_FLAP_DETECTION(self):
849 self.conf.enable_flap_detection = True
850 self.conf.explode_global_conf()
851 self.sched.get_and_register_update_program_status_brok()
853 #ENABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
854 def ENABLE_HOSTGROUP_HOST_CHECKS(self, hostgroup):
855 for host in hostgroup:
856 self.ENABLE_HOST_CHECK(host)
858 #ENABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>
859 def ENABLE_HOSTGROUP_HOST_NOTIFICATIONS(self, hostgroup):
860 for host in hostgroup:
861 self.ENABLE_HOST_NOTIFICATIONS(host)
863 #ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>
864 def ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS(self, hostgroup):
865 for host in hostgroup:
866 self.ENABLE_PASSIVE_HOST_CHECKS(host)
868 #ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>
869 def ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS(self, hostgroup):
870 for host in hostgroup:
871 for service in host.services:
872 self.ENABLE_PASSIVE_SVC_CHECKS(service)
874 #ENABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>
875 def ENABLE_HOSTGROUP_SVC_CHECKS(self, hostgroup):
876 for host in hostgroup:
877 for service in host.services:
878 self.ENABLE_SVC_CHECK(service)
880 #ENABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>
881 def ENABLE_HOSTGROUP_SVC_NOTIFICATIONS(self, hostgroup):
882 for host in hostgroup:
883 for service in host.services:
884 self.ENABLE_SVC_NOTIFICATIONS(service)
886 #ENABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name>
887 def ENABLE_HOST_AND_CHILD_NOTIFICATIONS(self, host):
888 pass
890 #ENABLE_HOST_CHECK;<host_name>
891 def ENABLE_HOST_CHECK(self, host):
892 host.active_checks_enabled = True
893 self.sched.get_and_register_status_brok(host)
895 #ENABLE_HOST_EVENT_HANDLER;<host_name>
896 def ENABLE_HOST_EVENT_HANDLER(self, host):
897 host.enable_event_handlers = True
898 self.sched.get_and_register_status_brok(host)
900 #ENABLE_HOST_FLAP_DETECTION;<host_name>
901 def ENABLE_HOST_FLAP_DETECTION(self, host):
902 host.flap_detection_enabled = True
903 self.sched.get_and_register_status_brok(host)
905 #ENABLE_HOST_FRESHNESS_CHECKS
906 def ENABLE_HOST_FRESHNESS_CHECKS(self):
907 self.conf.check_host_freshness = True
908 self.conf.explode_global_conf()
909 self.sched.get_and_register_update_program_status_brok()
911 #ENABLE_HOST_NOTIFICATIONS;<host_name>
912 def ENABLE_HOST_NOTIFICATIONS(self, host):
913 host.notifications_enabled = True
914 self.sched.get_and_register_status_brok(host)
916 #ENABLE_HOST_SVC_CHECKS;<host_name>
917 def ENABLE_HOST_SVC_CHECKS(self, host):
918 for s in host.services:
919 self.ENABLE_SVC_CHECK(s)
920 self.sched.get_and_register_status_brok(s)
922 #ENABLE_HOST_SVC_NOTIFICATIONS;<host_name>
923 def ENABLE_HOST_SVC_NOTIFICATIONS(self, host):
924 for s in host.services:
925 self.ENABLE_SVC_NOTIFICATIONS(s)
926 self.sched.get_and_register_status_brok(s)
928 #ENABLE_NOTIFICATIONS
929 def ENABLE_NOTIFICATIONS(self):
930 self.conf.enable_notifications = True
931 self.conf.explode_global_conf()
932 self.sched.get_and_register_update_program_status_brok()
934 #ENABLE_PASSIVE_HOST_CHECKS;<host_name>
935 def ENABLE_PASSIVE_HOST_CHECKS(self, host):
936 host.passive_checks_enabled = True
937 self.sched.get_and_register_status_brok(host)
939 #ENABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
940 def ENABLE_PASSIVE_SVC_CHECKS(self, service):
941 service.passive_checks_enabled = True
942 self.sched.get_and_register_status_brok(service)
944 #ENABLE_PERFORMANCE_DATA
945 def ENABLE_PERFORMANCE_DATA(self):
946 self.conf.process_performance_data = True
947 self.conf.explode_global_conf()
948 self.sched.get_and_register_update_program_status_brok()
950 #ENABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
951 def ENABLE_SERVICEGROUP_HOST_CHECKS(self, servicegroup):
952 for service in servicegroup:
953 self.ENABLE_HOST_CHECK(service.host)
955 #ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>
956 def ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS(self, servicegroup):
957 for service in servicegroup:
958 self.ENABLE_HOST_NOTIFICATIONS(service.host)
960 #ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
961 def ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS(self, servicegroup):
962 for service in servicegroup:
963 self.ENABLE_PASSIVE_HOST_CHECKS(service.host)
965 #ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>
966 def ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS(self, servicegroup):
967 for service in servicegroup:
968 self.ENABLE_PASSIVE_SVC_CHECKS(service)
970 #ENABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>
971 def ENABLE_SERVICEGROUP_SVC_CHECKS(self, servicegroup):
972 for service in servicegroup:
973 self.ENABLE_SVC_CHECK(service)
975 #ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>
976 def ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS(self, servicegroup):
977 for service in servicegroup:
978 self.ENABLE_SVC_NOTIFICATIONS(service)
980 #ENABLE_SERVICE_FRESHNESS_CHECKS
981 def ENABLE_SERVICE_FRESHNESS_CHECKS(self):
982 self.conf.check_service_freshness = True
983 self.conf.explode_global_conf()
984 self.sched.get_and_register_update_program_status_brok()
986 #ENABLE_SVC_CHECK;<host_name>;<service_description>
987 def ENABLE_SVC_CHECK(self, service):
988 service.active_checks_enabled = True
989 self.sched.get_and_register_status_brok(service)
991 #ENABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
992 def ENABLE_SVC_EVENT_HANDLER(self, service):
993 service.event_handler_enabled = True
994 self.sched.get_and_register_status_brok(service)
996 #ENABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
997 def ENABLE_SVC_FLAP_DETECTION(self, service):
998 service.flap_detection_enabled = True
999 self.sched.get_and_register_status_brok(service)
1001 #ENABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
1002 def ENABLE_SVC_NOTIFICATIONS(self, service):
1003 service.notifications_enabled = True
1004 self.sched.get_and_register_status_brok(service)
1006 #PROCESS_FILE;<file_name>;<delete>
1007 def PROCESS_FILE(self, file_name, delete):
1008 pass
1010 #TODO : say that check is PASSIVE
1011 #PROCESS_HOST_CHECK_RESULT;<host_name>;<status_code>;<plugin_output>
1012 def PROCESS_HOST_CHECK_RESULT(self, host, status_code, plugin_output):
1013 #raise a PASSIVE check only if needed
1014 if self.conf.log_passive_checks:
1015 logger.log('PASSIVE HOST CHECK: %s;%d;%s' % (host.get_name(), status_code, plugin_output))
1016 now = time.time()
1017 cls = host.__class__
1018 #If globally disable OR locally, do not launch
1019 if cls.accept_passive_checks and host.passive_checks_enabled:
1020 i = host.launch_check(now, force=True)
1021 for chk in host.actions:
1022 if chk.id == i:
1023 c = chk
1024 #Now we 'transform the check into a result'
1025 #So exit_status, output and status is eaten by the host
1026 c.exit_status = status_code
1027 c.get_outputs(plugin_output, host.max_plugins_output_length)
1028 c.status = 'waitconsume'
1029 self.sched.nb_check_received += 1
1030 #Ok now this result will be reap by scheduler the next loop
1033 #PROCESS_SERVICE_CHECK_RESULT;<host_name>;<service_description>;<return_code>;<plugin_output>
1034 def PROCESS_SERVICE_CHECK_RESULT(self, service, return_code, plugin_output):
1035 #raise a PASSIVE check only if needed
1036 if self.conf.log_passive_checks:
1037 logger.log('PASSIVE SERVICE CHECK: %s;%s;%d;%s' % (service.host.get_name(), service.get_name(), return_code, plugin_output))
1038 now = time.time()
1039 cls = service.__class__
1040 #If globally disable OR locally, do not launch
1041 if cls.accept_passive_checks and service.passive_checks_enabled:
1042 i = service.launch_check(now, force=True)
1043 for chk in service.actions:
1044 if chk.id == i:
1045 c = chk
1046 #Now we 'transform the check into a result'
1047 #So exit_status, output and status is eaten by the service
1048 c.exit_status = return_code
1049 c.get_outputs(plugin_output, service.max_plugins_output_length)
1050 c.status = 'waitconsume'
1051 self.sched.nb_check_received += 1
1052 #Ok now this result will be reap by scheduler the next loop
1055 #READ_STATE_INFORMATION
1056 def READ_STATE_INFORMATION(self):
1057 pass
1059 #REMOVE_HOST_ACKNOWLEDGEMENT;<host_name>
1060 def REMOVE_HOST_ACKNOWLEDGEMENT(self, host):
1061 host.unacknowledge_problem()
1063 #REMOVE_SVC_ACKNOWLEDGEMENT;<host_name>;<service_description>
1064 def REMOVE_SVC_ACKNOWLEDGEMENT(self, service):
1065 service.unacknowledge_problem()
1067 #RESTART_PROGRAM
1068 def RESTART_PROGRAM(self):
1069 pass
1071 #SAVE_STATE_INFORMATION
1072 def SAVE_STATE_INFORMATION(self):
1073 pass
1075 #SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1076 def SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME(self, host, start_time, end_time, fixed, trigger_id, duration, author, comment):
1077 pass
1079 #SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1080 def SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME(self, host, start_time, end_time, fixed, trigger_id, duration, author, comment):
1081 pass
1083 #SCHEDULE_CONTACT_DOWNTIME;<contact_name>;<start_time>;<end_time>;<author>;<comment>
1084 def SCHEDULE_CONTACT_DOWNTIME(self, contact, start_time, end_time, author, comment):
1085 dt = ContactDowntime(contact, start_time, end_time, author, comment)
1086 contact.add_downtime(dt)
1087 self.sched.add(dt)
1088 self.sched.get_and_register_status_brok(contact)
1090 #SCHEDULE_FORCED_HOST_CHECK;<host_name>;<check_time>
1091 def SCHEDULE_FORCED_HOST_CHECK(self, host, check_time):
1092 host.schedule(force=True, force_time=check_time)
1093 self.sched.get_and_register_status_brok(host)
1095 #SCHEDULE_FORCED_HOST_SVC_CHECKS;<host_name>;<check_time>
1096 def SCHEDULE_FORCED_HOST_SVC_CHECKS(self, host, check_time):
1097 for s in host.services:
1098 self.SCHEDULE_FORCED_SVC_CHECK(s, check_time)
1099 self.sched.get_and_register_status_brok(s)
1101 #SCHEDULE_FORCED_SVC_CHECK;<host_name>;<service_description>;<check_time>
1102 def SCHEDULE_FORCED_SVC_CHECK(self, service, check_time):
1103 service.schedule(force=True, force_time=check_time)
1104 self.sched.get_and_register_status_brok(service)
1106 #SCHEDULE_HOSTGROUP_HOST_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1107 def SCHEDULE_HOSTGROUP_HOST_DOWNTIME(self, hostgroup, start_time, end_time, fixed, trigger_id, duration, author, comment):
1108 pass
1110 #SCHEDULE_HOSTGROUP_SVC_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1111 def SCHEDULE_HOSTGROUP_SVC_DOWNTIME(self, hostgroup, start_time, end_time, fixed, trigger_id, duration, author, comment):
1112 pass
1114 #SCHEDULE_HOST_CHECK;<host_name>;<check_time>
1115 def SCHEDULE_HOST_CHECK(self, host, check_time):
1116 host.schedule(force=False, force_time=check_time)
1117 self.sched.get_and_register_status_brok(host)
1119 #SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1120 def SCHEDULE_HOST_DOWNTIME(self, host, start_time, end_time, fixed, trigger_id, duration, author, comment):
1121 dt = Downtime(host, start_time, end_time, fixed, trigger_id, duration, author, comment)
1122 host.add_downtime(dt)
1123 self.sched.add(dt)
1124 self.sched.get_and_register_status_brok(host)
1125 if trigger_id != 0 and trigger_id in self.sched.downtimes:
1126 self.sched.downtimes[trigger_id].trigger_me(dt)
1128 #SCHEDULE_HOST_SVC_CHECKS;<host_name>;<check_time>
1129 def SCHEDULE_HOST_SVC_CHECKS(self, host, check_time):
1130 for s in host.services:
1131 self.SCHEDULE_SVC_CHECK(s, check_time)
1132 self.sched.get_and_register_status_brok(s)
1134 #SCHEDULE_HOST_SVC_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1135 def SCHEDULE_HOST_SVC_DOWNTIME(self, host, start_time, end_time, fixed, trigger_id, duration, author, comment):
1136 for s in host.services:
1137 self.SCHEDULE_SVC_DOWNTIME(s, start_time, end_time, fixed, trigger_id, duration, author, comment)
1139 #SCHEDULE_SERVICEGROUP_HOST_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1140 def SCHEDULE_SERVICEGROUP_HOST_DOWNTIME(self, servicegroup, start_time, end_time, fixed, trigger_id, duration, author, comment):
1141 for h in [s.host for s in servicegroup.get_services()]:
1142 self.SCHEDULE_HOST_DOWNTIME(h, start_time, end_time, fixed, trigger_id, duration, author, comment)
1144 #SCHEDULE_SERVICEGROUP_SVC_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1145 def SCHEDULE_SERVICEGROUP_SVC_DOWNTIME(self, servicegroup, start_time, end_time, fixed, trigger_id, duration, author, comment):
1146 for s in servicegroup.get_services():
1147 self.SCHEDULE_SVC_DOWNTIME(s, start_time, end_time, fixed, trigger_id, duration, author, comment)
1149 #SCHEDULE_SVC_CHECK;<host_name>;<service_description>;<check_time>
1150 def SCHEDULE_SVC_CHECK(self, service, check_time):
1151 service.schedule(force=False, force_time=check_time)
1152 self.sched.get_and_register_status_brok(service)
1154 #SCHEDULE_SVC_DOWNTIME;<host_name>;<service_desription><start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1155 def SCHEDULE_SVC_DOWNTIME(self, service, start_time, end_time, fixed, trigger_id, duration, author, comment):
1156 dt = Downtime(service, start_time, end_time, fixed, trigger_id, duration, author, comment)
1157 service.add_downtime(dt)
1158 self.sched.add(dt)
1159 self.sched.get_and_register_status_brok(service)
1160 if trigger_id != 0 and trigger_id in self.sched.downtimes:
1161 self.sched.downtimes[trigger_id].trigger_me(dt)
1163 #SEND_CUSTOM_HOST_NOTIFICATION;<host_name>;<options>;<author>;<comment>
1164 def SEND_CUSTOM_HOST_NOTIFICATION(self, host, options, author, comment):
1165 pass
1167 #SEND_CUSTOM_SVC_NOTIFICATION;<host_name>;<service_description>;<options>;<author>;<comment>
1168 def SEND_CUSTOM_SVC_NOTIFICATION(self, service, options, author, comment):
1169 pass
1171 #SET_HOST_NOTIFICATION_NUMBER;<host_name>;<notification_number>
1172 def SET_HOST_NOTIFICATION_NUMBER(self, host, notification_number):
1173 pass
1175 #SET_SVC_NOTIFICATION_NUMBER;<host_name>;<service_description>;<notification_number>
1176 def SET_SVC_NOTIFICATION_NUMBER(self, service, notification_number):
1177 pass
1179 #SHUTDOWN_PROGRAM
1180 def SHUTDOWN_PROGRAM(self):
1181 pass
1183 #START_ACCEPTING_PASSIVE_HOST_CHECKS
1184 def START_ACCEPTING_PASSIVE_HOST_CHECKS(self):
1185 self.conf.accept_passive_host_checks = True
1186 self.conf.explode_global_conf()
1187 self.sched.get_and_register_update_program_status_brok()
1189 #START_ACCEPTING_PASSIVE_SVC_CHECKS
1190 def START_ACCEPTING_PASSIVE_SVC_CHECKS(self):
1191 self.conf.accept_passive_service_checks = True
1192 self.conf.explode_global_conf()
1193 self.sched.get_and_register_update_program_status_brok()
1195 #START_EXECUTING_HOST_CHECKS
1196 def START_EXECUTING_HOST_CHECKS(self):
1197 self.conf.execute_host_checks = True
1198 self.conf.explode_global_conf()
1199 self.sched.get_and_register_update_program_status_brok()
1201 #START_EXECUTING_SVC_CHECKS
1202 def START_EXECUTING_SVC_CHECKS(self):
1203 self.conf.execute_service_checks = True
1204 self.conf.explode_global_conf()
1205 self.sched.get_and_register_update_program_status_brok()
1207 #START_OBSESSING_OVER_HOST;<host_name>
1208 def START_OBSESSING_OVER_HOST(self, host):
1209 host.obsess_over_host = True
1210 self.sched.get_and_register_status_brok(host)
1212 #START_OBSESSING_OVER_HOST_CHECKS
1213 def START_OBSESSING_OVER_HOST_CHECKS(self):
1214 self.conf.obsess_over_hosts = True
1215 self.conf.explode_global_conf()
1217 #START_OBSESSING_OVER_SVC;<host_name>;<service_description>
1218 def START_OBSESSING_OVER_SVC(self, service):
1219 service.obsess_over_service = True
1220 self.sched.get_and_register_status_brok(service)
1222 #START_OBSESSING_OVER_SVC_CHECKS
1223 def START_OBSESSING_OVER_SVC_CHECKS(self):
1224 self.conf.obsess_over_services = True
1225 self.conf.explode_global_conf()
1226 self.sched.get_and_register_update_program_status_brok()
1228 #STOP_ACCEPTING_PASSIVE_HOST_CHECKS
1229 def STOP_ACCEPTING_PASSIVE_HOST_CHECKS(self):
1230 self.accept_passive_host_checks = False
1231 self.conf.explode_global_conf()
1232 self.sched.get_and_register_update_program_status_brok()
1234 #STOP_ACCEPTING_PASSIVE_SVC_CHECKS
1235 def STOP_ACCEPTING_PASSIVE_SVC_CHECKS(self):
1236 self.accept_passive_service_checks = False
1237 self.conf.explode_global_conf()
1238 self.sched.get_and_register_update_program_status_brok()
1240 #STOP_EXECUTING_HOST_CHECKS
1241 def STOP_EXECUTING_HOST_CHECKS(self):
1242 self.conf.execute_host_checks = False
1243 self.conf.explode_global_conf()
1244 self.sched.get_and_register_update_program_status_brok()
1246 #STOP_EXECUTING_SVC_CHECKS
1247 def STOP_EXECUTING_SVC_CHECKS(self):
1248 self.conf.execute_service_checks = False
1249 self.conf.explode_global_conf()
1250 self.sched.get_and_register_update_program_status_brok()
1252 #STOP_OBSESSING_OVER_HOST;<host_name>
1253 def STOP_OBSESSING_OVER_HOST(self, host):
1254 host.obsess_over_host = False
1255 self.sched.get_and_register_status_brok(host)
1257 #STOP_OBSESSING_OVER_HOST_CHECKS
1258 def STOP_OBSESSING_OVER_HOST_CHECKS(self):
1259 self.conf.obsess_over_hosts = False
1260 self.conf.explode_global_conf()
1261 self.sched.get_and_register_update_program_status_brok()
1263 #STOP_OBSESSING_OVER_SVC;<host_name>;<service_description>
1264 def STOP_OBSESSING_OVER_SVC(self, service):
1265 service.obsess_over_service = False
1266 self.sched.get_and_register_status_brok(service)
1268 #STOP_OBSESSING_OVER_SVC_CHECKS
1269 def STOP_OBSESSING_OVER_SVC_CHECKS(self):
1270 self.conf.obsess_over_services = False
1271 self.conf.explode_global_conf()
1272 self.sched.get_and_register_update_program_status_brok()
1275 ### Now the shinken specific ones
1276 #LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>
1277 def LAUNCH_SVC_EVENT_HANDLER(self, service):
1278 service.get_event_handlers(externalcmd=True)
1281 #LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>
1282 def LAUNCH_HOST_EVENT_HANDLER(self, host):
1283 host.get_event_handlers(externalcmd=True)
1286 #ADD_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>
1287 def ADD_SIMPLE_HOST_DEPENDENCY(self, son, father):
1288 if not son.is_linked_with_host(father):
1289 print "Doing simple link between", son.get_name(), 'and', father.get_name()
1290 # Add a dep link between the son and the father
1291 son.add_host_act_dependancy(father, ['w', 'u', 'd'], None, True)
1292 self.sched.get_and_register_status_brok(son)
1293 self.sched.get_and_register_status_brok(father)
1296 #ADD_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>
1297 def DEL_HOST_DEPENDENCY(self, son, father):
1298 if son.is_linked_with_host(father):
1299 print "removing simple link between", son.get_name(), 'and', father.get_name()
1300 son.del_host_act_dependancy(father)
1304 if __name__ == '__main__':
1305 import os
1307 FIFO_PATH = '/tmp/my_fifo'
1309 if os.path.exists(FIFO_PATH):
1310 os.unlink(FIFO_PATH)
1312 if not os.path.exists(FIFO_PATH):
1313 os.umask(0)
1314 os.mkfifo(FIFO_PATH, 0660)
1315 my_fifo = open(FIFO_PATH, 'w+')
1316 print "my_fifo:", my_fifo
1318 print open(FIFO_PATH, 'r').readline()