*Change the jenkins/hudson test scripts
[shinken.git] / shinken / external_command.py
blob1c301eda75fbe300624b9b2b61a5bac6cc69c607
1 #!/usr/bin/env python
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/>.
23 import os, time
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.command import CommandCall
30 from shinken.log import logger
32 class ExternalCommand:
33 my_type = 'externalcommand'
34 def __init__(self, cmd_line):
35 self.cmd_line = cmd_line
38 class ExternalCommandManager:
40 commands = {
41 'CHANGE_CONTACT_MODSATTR' : {'global' : True, 'args' : ['contact', None]},
42 'CHANGE_CONTACT_MODHATTR' : {'global' : True, 'args' : ['contact', None]},
43 'CHANGE_CONTACT_MODATTR' : {'global' : True, 'args' : ['contact', None]},
44 'CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD' : {'global' : True, 'args' : ['contact', 'time_period']},
45 'ADD_SVC_COMMENT' : {'global' : False, 'args' : ['service', 'to_bool', 'author', None]},
46 'ADD_HOST_COMMENT' : {'global' : False, 'args' : ['host', 'to_bool', 'author', None]},
47 'ACKNOWLEDGE_SVC_PROBLEM' : {'global' : False, 'args' : ['service' , 'to_int', 'to_bool', 'to_bool', 'author', None]},
48 'ACKNOWLEDGE_HOST_PROBLEM' : {'global' : False, 'args' : ['host', 'to_int', 'to_bool', 'to_bool', 'author', None]},
49 'CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD' : {'global' : True, 'args' : ['contact', 'time_period']},
50 'CHANGE_CUSTOM_CONTACT_VAR' : {'global' : True, 'args' : ['contact', None,None]},
51 'CHANGE_CUSTOM_HOST_VAR' : {'global' : False, 'args' : ['host', None,None]},
52 'CHANGE_CUSTOM_SVC_VAR' : {'global' : False, 'args' : ['service', None,None]},
53 'CHANGE_GLOBAL_HOST_EVENT_HANDLER' : {'global' : True, 'args' : ['command']},
54 'CHANGE_GLOBAL_SVC_EVENT_HANDLER' : {'global' : True, 'args' : ['command']},
55 'CHANGE_HOST_CHECK_COMMAND' : {'global' : False, 'args' : ['host', 'command']},
56 'CHANGE_HOST_CHECK_TIMEPERIOD' : {'global' : False, 'args' : ['host', 'time_period']},
57 'CHANGE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host', 'command']},
58 'CHANGE_HOST_MODATTR' : {'global' : False, 'args' : ['host', 'to_int']},
59 'CHANGE_MAX_HOST_CHECK_ATTEMPTS': {'global' : False, 'args' : ['host', 'to_int']},
60 'CHANGE_MAX_SVC_CHECK_ATTEMPTS' : {'global' : False, 'args' : ['service', 'to_int']},
61 'CHANGE_NORMAL_HOST_CHECK_INTERVAL' : {'global' : False, 'args' : ['host', 'to_int']},
62 'CHANGE_NORMAL_SVC_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
63 'CHANGE_RETRY_HOST_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
64 'CHANGE_RETRY_SVC_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
65 'CHANGE_SVC_CHECK_COMMAND' : {'global' : False, 'args' : ['service', 'command']},
66 'CHANGE_SVC_CHECK_TIMEPERIOD' : {'global' : False, 'args' : ['service', 'time_period']},
67 'CHANGE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service', 'command']},
68 'CHANGE_SVC_MODATTR' : {'global' : False, 'args' : ['service', 'to_int']},
69 'CHANGE_SVC_NOTIFICATION_TIMEPERIOD' : {'global' : False, 'args' : ['service', 'time_period']},
70 'DELAY_HOST_NOTIFICATION' : {'global' : False, 'args' : ['host', 'to_int']},
71 'DELAY_SVC_NOTIFICATION' : {'global' : False, 'args' : ['service', 'to_int']},
72 'DEL_ALL_HOST_COMMENTS' : {'global' : False, 'args' : ['host']},
73 'DEL_ALL_SVC_COMMENTS' : {'global' : False, 'args' : ['service']},
74 'DEL_CONTACT_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
75 'DEL_HOST_COMMENT' : {'global' : True, 'args' : ['to_int']},
76 'DEL_HOST_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
77 'DEL_SVC_COMMENT' : {'global' : True, 'args' : ['to_int']},
78 'DEL_SVC_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
79 'DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST' : {'global' : False, 'args' : ['host']},
80 'DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
81 'DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
82 'DISABLE_CONTACT_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
83 'DISABLE_CONTACT_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
84 'DISABLE_EVENT_HANDLERS' : {'global' : True, 'args' : []},
85 'DISABLE_FAILURE_PREDICTION' : {'global' : True, 'args' : []},
86 'DISABLE_FLAP_DETECTION' : {'global' : True, 'args' : []},
87 'DISABLE_HOSTGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
88 'DISABLE_HOSTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
89 'DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
90 'DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
91 'DISABLE_HOSTGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
92 'DISABLE_HOSTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
93 'DISABLE_HOST_AND_CHILD_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
94 'DISABLE_HOST_CHECK' : {'global' : False, 'args' : ['host']},
95 'DISABLE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
96 'DISABLE_HOST_FLAP_DETECTION' : {'global' : False, 'args' : ['host']},
97 'DISABLE_HOST_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
98 'DISABLE_HOST_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
99 'DISABLE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host']},
100 'DISABLE_HOST_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
101 'DISABLE_NOTIFICATIONS' : {'global' : True, 'args' : []},
102 'DISABLE_PASSIVE_HOST_CHECKS' : {'global' : False, 'args' : ['host']},
103 'DISABLE_PASSIVE_SVC_CHECKS' : {'global' : False, 'args' : ['service']},
104 'DISABLE_PERFORMANCE_DATA' : {'global' : True, 'args' : []},
105 'DISABLE_SERVICEGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
106 'DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
107 'DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
108 'DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
109 'DISABLE_SERVICEGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
110 'DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
111 'DISABLE_SERVICE_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
112 'DISABLE_SERVICE_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
113 'DISABLE_SVC_CHECK' : {'global' : False, 'args' : ['service']},
114 'DISABLE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
115 'DISABLE_SVC_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
116 'DISABLE_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['service']},
117 'ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST' : {'global' : False, 'args' : ['host']},
118 'ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
119 'ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
120 'ENABLE_CONTACT_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
121 'ENABLE_CONTACT_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
122 'ENABLE_EVENT_HANDLERS' : {'global' : True, 'args' : []},
123 'ENABLE_FAILURE_PREDICTION' : {'global' : True, 'args' : []},
124 'ENABLE_FLAP_DETECTION' : {'global' : True, 'args' : []},
125 'ENABLE_HOSTGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
126 'ENABLE_HOSTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
127 'ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
128 'ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
129 'ENABLE_HOSTGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
130 'ENABLE_HOSTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
131 'ENABLE_HOST_AND_CHILD_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
132 'ENABLE_HOST_CHECK' : {'global' : False, 'args' : ['host']},
133 'ENABLE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
134 'ENABLE_HOST_FLAP_DETECTION' : {'global' : False, 'args' : ['host']},
135 'ENABLE_HOST_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
136 'ENABLE_HOST_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
137 'ENABLE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host']},
138 'ENABLE_HOST_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
139 'ENABLE_NOTIFICATIONS' : {'global' : True, 'args' : []},
140 'ENABLE_PASSIVE_HOST_CHECKS' : {'global' : False, 'args' : ['host']},
141 'ENABLE_PASSIVE_SVC_CHECKS' : {'global' : False, 'args' : ['service']},
142 'ENABLE_PERFORMANCE_DATA' : {'global' : True, 'args' : []},
143 'ENABLE_SERVICEGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
144 'ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
145 'ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
146 'ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
147 'ENABLE_SERVICEGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
148 'ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
149 'ENABLE_SERVICE_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
150 'ENABLE_SVC_CHECK': {'global' : False, 'args' : ['service']},
151 'ENABLE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
152 'ENABLE_SVC_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
153 'ENABLE_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['service']},
154 'PROCESS_FILE' : {'global' : True, 'args' : [None, 'to_bool']},
155 'PROCESS_HOST_CHECK_RESULT' : {'global' : False, 'args' : ['host', 'to_int', None]},
156 'PROCESS_SERVICE_CHECK_RESULT' : {'global' : False, 'args' : ['service', 'to_int', None]},
157 'READ_STATE_INFORMATION' : {'global' : True, 'args' : []},
158 'REMOVE_HOST_ACKNOWLEDGEMENT' : {'global' : False, 'args' : ['host']},
159 'REMOVE_SVC_ACKNOWLEDGEMENT' : {'global' : False, 'args' : ['service']},
160 'RESTART_PROGRAM' : {'global' : True, 'args' : []},
161 'SAVE_STATE_INFORMATION' : {'global' : True, 'args' : []},
162 'SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
163 'SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
164 'SCHEDULE_CONTACT_DOWNTIME' : {'global' : True, 'args' : ['contact', 'to_int', 'to_int', 'author', None]},
165 'SCHEDULE_FORCED_HOST_CHECK' : {'global' : False, 'args' : ['host', 'to_int']},
166 'SCHEDULE_FORCED_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host', 'to_int']},
167 'SCHEDULE_FORCED_SVC_CHECK' : {'global' : False, 'args' : ['service', 'to_int']},
168 'SCHEDULE_HOSTGROUP_HOST_DOWNTIME' : {'global' : True, 'args' : ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
169 'SCHEDULE_HOSTGROUP_SVC_DOWNTIME' : {'global' : True, 'args' : ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
170 'SCHEDULE_HOST_CHECK' : {'global' : False, 'args' : ['host', 'to_int']},
171 'SCHEDULE_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
172 'SCHEDULE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host', 'to_int']},
173 'SCHEDULE_HOST_SVC_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
174 'SCHEDULE_SERVICEGROUP_HOST_DOWNTIME' : {'global' : True, 'args' : ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
175 'SCHEDULE_SERVICEGROUP_SVC_DOWNTIME' : {'global' : True, 'args' : ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
176 'SCHEDULE_SVC_CHECK' : {'global' : False, 'args' : ['service', 'to_int']},
177 'SCHEDULE_SVC_DOWNTIME' : {'global' : False, 'args' : ['service', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
178 'SEND_CUSTOM_HOST_NOTIFICATION' : {'global' : False, 'args' : ['host', 'to_int', 'author', None]},
179 'SEND_CUSTOM_SVC_NOTIFICATION' : {'global' : False, 'args' : ['service', 'to_int', 'author', None]},
180 'SET_HOST_NOTIFICATION_NUMBER' : {'global' : False, 'args' : ['host', 'to_int']},
181 'SET_SVC_NOTIFICATION_NUMBER' : {'global' : False, 'args' : ['service', 'to_int']},
182 'SHUTDOWN_PROGRAM' : {'global' : True, 'args' : []},
183 'START_ACCEPTING_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : []},
184 'START_ACCEPTING_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : []},
185 'START_EXECUTING_HOST_CHECKS' : {'global' : True, 'args' : []},
186 'START_EXECUTING_SVC_CHECKS' : {'global' : True, 'args' : []},
187 'START_OBSESSING_OVER_HOST' : {'global' : False, 'args' : ['host']},
188 'START_OBSESSING_OVER_HOST_CHECKS' : {'global' : True, 'args' : []},
189 'START_OBSESSING_OVER_SVC' : {'global' : False, 'args' : ['service']},
190 'START_OBSESSING_OVER_SVC_CHECKS' : {'global' : True, 'args' : []},
191 'STOP_ACCEPTING_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : []},
192 'STOP_ACCEPTING_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : []},
193 'STOP_EXECUTING_HOST_CHECKS' : {'global' : True, 'args' : []},
194 'STOP_EXECUTING_SVC_CHECKS' : {'global' : True, 'args' : []},
195 'STOP_OBSESSING_OVER_HOST' : {'global' : False, 'args' : ['host']},
196 'STOP_OBSESSING_OVER_HOST_CHECKS' : {'global' : True, 'args' : []},
197 'STOP_OBSESSING_OVER_SVC' : {'global' : False, 'args' : ['service']},
198 'STOP_OBSESSING_OVER_SVC_CHECKS' : {'global' : True, 'args' : []},
199 'LAUNCH_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
200 'LAUNCH_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
201 # Now internal calls
202 'ADD_SIMPLE_HOST_DEPENDENCY' : {'global' : False, 'args' : ['host', 'host']},
203 'DEL_HOST_DEPENDENCY' : {'global' : False, 'args' : ['host', 'host']},
207 def __init__(self, conf, mode):
208 self.mode = mode
209 self.conf = conf
210 self.hosts = conf.hosts
211 self.services = conf.services
212 self.contacts = conf.contacts
213 self.hostgroups = conf.hostgroups
214 self.commands = conf.commands
215 self.servicegroups = conf.servicegroups
216 self.contactgroups = conf.contactgroups
217 self.timeperiods = conf.timeperiods
218 self.pipe_path = conf.command_file
219 self.fifo = None
220 if self.mode == 'dispatcher':
221 self.confs = conf.confs
224 def load_scheduler(self, scheduler):
225 self.sched = scheduler
228 def open(self):
229 #At the first open del and create the fifo
230 if self.fifo == None:
231 if os.path.exists(self.pipe_path):
232 os.unlink(self.pipe_path)
234 if not os.path.exists(self.pipe_path):
235 os.umask(0)
236 try :
237 os.mkfifo(self.pipe_path, 0660)
238 open(self.pipe_path, 'w+', os.O_NONBLOCK)
239 except OSError , exp:
240 print "Error : pipe creation failed (",self.pipe_path,')', exp
241 return None
242 self.fifo = os.open(self.pipe_path, os.O_NONBLOCK)
243 #print 'Fifo:', self.fifo
244 return self.fifo
247 def get(self):
248 buf = os.read(self.fifo, 8096)
249 os.close(self.fifo)
250 r = []
251 if buf != '':
252 t = buf.split('\n')
253 for s in t:
254 if s != '':
255 excmd = ExternalCommand(s)
256 r.append(excmd)
257 return r
258 return []
262 def resolve_command(self, excmd):
263 command = excmd.cmd_line
264 command = command.strip()
265 #Only log if we are in the Arbiter
266 if self.mode == 'dispatcher':
267 logger.log('EXTERNAL COMMAND: '+command.rstrip())
268 self.get_command_and_args(command)
271 #Ok the command is not for every one, so we search
272 #by the hostname which scheduler have the host. Then send
273 #it the command
274 def search_host_and_dispatch(self, host_name, command):
275 print "Calling search_host_and_dispatch", 'for', host_name
276 for cfg in self.confs.values():
277 if cfg.hosts.find_by_name(host_name) is not None:
278 print "Host", host_name, "found in a configuration"
279 if cfg.is_assigned :
280 sched = cfg.assigned_to
281 print "Sending command to the scheduler", sched.get_name()
282 sched.run_external_command(command)
283 else:
284 print "Problem: a configuration is found, but is not assigned!"
285 else:
286 logger.log("Warning: Passive check result was received for host '%s', but the host could not be found!" % host_name)
287 #print "Sorry but the host", host_name, "was not found"
290 #The command is global, so sent it to every schedulers
291 def dispatch_global_command(self, command):
292 for sched in self.conf.schedulerlinks:
293 print "Sending a command", command, 'to scheduler', sched
294 if sched.alive:
295 sched.run_external_command(command)
298 #We need to get the first part, the command name
299 def get_command_and_args(self, command):
300 print "Trying to resolve", command
301 if command[-1] == '\n':
302 command = command[:-1]
303 elts = command.split(';')
304 part1 = elts[0]
306 elts2 = part1.split(' ')
307 print "Elts2:", elts2
308 if len(elts2) != 2:
309 print "Malformed command", command
310 return None
311 c_name = elts2[1]
313 print "Get command name", c_name
314 if c_name not in ExternalCommandManager.commands:
315 print "This command is not recognized, sorry"
316 return None
318 if self.mode == 'dispatcher' and ExternalCommandManager.commands[c_name]['global']:
319 print "This command is a global one, we resent it to all schedulers"
320 self.dispatch_global_command(command)
321 return None
322 print "Is global?", c_name, ExternalCommandManager.commands[c_name]['global']
323 print "Mode:", self.mode
324 print "This command have arguments:", ExternalCommandManager.commands[c_name]['args'], len(ExternalCommandManager.commands[c_name]['args'])
326 args = []
327 i = 1
328 in_service = False
329 tmp_host = ''
330 try:
331 for elt in elts[1:]:
332 print "Searching for a new arg:", elt, i
333 val = elt.strip()
334 if val[-1] == '\n':
335 val = val[:-1]
337 print "For command arg", val
339 if not in_service:
340 type_searched = ExternalCommandManager.commands[c_name]['args'][i-1]
341 print "Search for a arg", type_searched
343 if type_searched == 'host':
344 if self.mode == 'dispatcher':
345 self.search_host_and_dispatch(val, command)
346 return None
347 h = self.hosts.find_by_name(val)
348 if h is not None:
349 args.append(h)
351 elif type_searched == 'contact':
352 c = self.contacts.find_by_name(val)
353 if c is not None:
354 args.append(c)
356 elif type_searched == 'time_period':
357 t = self.timeperiods.find_by_name(val)
358 if t is not None:
359 args.append(t)
361 elif type_searched == 'to_bool':
362 args.append(to_bool(val))
364 elif type_searched == 'to_int':
365 args.append(to_int(val))
367 elif type_searched in ('author', None):
368 args.append(val)
370 elif type_searched == 'command':
371 c = self.commands.find_cmd_by_name(val)
372 if c is not None:
373 args.append(val)#the find will be redone by
374 #the commandCall creation, but != None
375 #is usefull so a bad command will be catch
377 elif type_searched == 'host_group':
378 hg = self.hostgroups.find_by_name(val)
379 if hg is not None:
380 args.append(hg)
382 elif type_searched == 'service_group':
383 sg = self.servicegroups.find_by_name(val)
384 if sg is not None:
385 args.append(sg)
387 elif type_searched == 'contact_group':
388 cg = self.contact_groups.find_by_name(val)
389 if cg is not None:
390 args.append(cg)
392 #special case: service are TWO args host;service, so one more loop
393 #to get the two parts
394 elif type_searched == 'service':
395 in_service = True
396 tmp_host = elt.strip()
397 print "TMP HOST", tmp_host
398 if tmp_host[-1] == '\n':
399 tmp_host = tmp_host[:-1]
401 if self.mode == 'dispatcher':
402 self.search_host_and_dispatch(tmp_host, command)
403 return None
405 i += 1
406 else:
407 in_service = False
408 srv_name = elt
409 if srv_name[-1] == '\n':
410 srv_name = srv_name[:-1]
411 print "Got service full", tmp_host, srv_name
412 s = self.services.find_srv_by_name_and_hostname(tmp_host, srv_name)
413 if s is not None:
414 args.append(s)
415 else: #error, must be logged
416 logger.log("Warning: a command was received for service '%s' on host '%s', but the service could not be found!" % (srv_name, tmp_host))
418 except IndexError:
419 print "Sorry, the arguments are not corrects"
420 return None
421 print 'Finally got ARGS:', args
422 if len(args) == len(ExternalCommandManager.commands[c_name]['args']):
423 print "OK, we can call the command", c_name, "with", args
424 f = getattr(self, c_name)
425 apply(f, args)
426 else:
427 print "Sorry, the arguments are not corrects", args
431 #CHANGE_CONTACT_MODSATTR;<contact_name>;<value>
432 def CHANGE_CONTACT_MODSATTR(self, contact, value):
433 pass
435 #CHANGE_CONTACT_MODHATTR;<contact_name>;<value>
436 def CHANGE_CONTACT_MODHATTR(self, contact, value):
437 pass
439 #CHANGE_CONTACT_MODATTR;<contact_name>;<value>
440 def CHANGE_CONTACT_MODATTR(self, contact, value):
441 pass
443 #CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>
444 def CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD(self, contact, notification_timeperiod):
445 contact.host_notification_period = notification_timeperiod
446 self.sched.get_and_register_status_brok(contact)
448 #ADD_SVC_COMMENT;<host_name>;<service_description>;<persistent>;<author>;<comment>
449 def ADD_SVC_COMMENT(self, service, persistent, author, comment):
450 c = Comment(service, persistent, author, comment, 2, 1, 1, False, 0)
451 service.add_comment(c)
452 self.sched.add(c)
454 #ADD_HOST_COMMENT;<host_name>;<persistent>;<author>;<comment>
455 def ADD_HOST_COMMENT(self, host, persistent, author, comment):
456 c = Comment(host, persistent, author, comment, 1, 1, 1, False, 0)
457 host.add_comment(c)
458 self.sched.add(c)
460 #ACKNOWLEDGE_SVC_PROBLEM;<host_name>;<service_description>;<sticky>;<notify>;<persistent>;<author>;<comment>
461 def ACKNOWLEDGE_SVC_PROBLEM(self, service, sticky, notify, persistent, author, comment):
462 service.acknowledge_problem(sticky, notify, persistent, author, comment)
464 #ACKNOWLEDGE_HOST_PROBLEM;<host_name>;<sticky>;<notify>;<persistent>;<author>;<comment>
465 #TODO : add a better ACK management
466 def ACKNOWLEDGE_HOST_PROBLEM(self, host, sticky, notify, persistent, author, comment):
467 host.acknowledge_problem(sticky, notify, persistent, author, comment)
469 #CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>
470 def CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD(self, contact, notification_timeperiod):
471 contact.service_notification_period = notification_timeperiod
472 self.sched.get_and_register_status_brok(contact)
474 #CHANGE_CUSTOM_CONTACT_VAR;<contact_name>;<varname>;<varvalue>
475 def CHANGE_CUSTOM_CONTACT_VAR(self, contact, varname, varvalue):
476 contact.customs[varname.upper()] = varvalue
478 #CHANGE_CUSTOM_HOST_VAR;<host_name>;<varname>;<varvalue>
479 def CHANGE_CUSTOM_HOST_VAR(self, host, varname, varvalue):
480 host.customs[varname.upper()] = varvalue
482 #CHANGE_CUSTOM_SVC_VAR;<host_name>;<service_description>;<varname>;<varvalue>
483 def CHANGE_CUSTOM_SVC_VAR(self, service, varname, varvalue):
484 service.customs[varname.upper()] = varvalue
486 #CHANGE_GLOBAL_HOST_EVENT_HANDLER;<event_handler_command>
487 def CHANGE_GLOBAL_HOST_EVENT_HANDLER(self, event_handler_command):
488 pass
490 #CHANGE_GLOBAL_SVC_EVENT_HANDLER;<event_handler_command>
491 def CHANGE_GLOBAL_SVC_EVENT_HANDLER(self, event_handler_command):
492 pass
494 #CHANGE_HOST_CHECK_COMMAND;<host_name>;<check_command>
495 def CHANGE_HOST_CHECK_COMMAND(self, host, check_command):
496 host.check_command = CommandCall(self.commands, check_command, poller_tag=host.poller_tag)
497 self.sched.get_and_register_status_brok(host)
499 #CHANGE_HOST_CHECK_TIMEPERIOD;<host_name>;<timeperiod>
500 def CHANGE_HOST_CHECK_TIMEPERIOD(self, host, timeperiod):
501 host.check_period = timeperiod
502 self.sched.get_and_register_status_brok(service)
504 #CHANGE_HOST_EVENT_HANDLER;<host_name>;<event_handler_command>
505 def CHANGE_HOST_EVENT_HANDLER(self, host, event_handler_command):
506 host.event_handler = CommandCall(self.commands, event_handler_command)
507 self.sched.get_and_register_status_brok(host)
509 #CHANGE_HOST_MODATTR;<host_name>;<value>
510 def CHANGE_HOST_MODATTR(self, host, value):
511 pass
513 #CHANGE_MAX_HOST_CHECK_ATTEMPTS;<host_name>;<check_attempts>
514 def CHANGE_MAX_HOST_CHECK_ATTEMPTS(self, host, check_attempts):
515 host.max_check_attempts = check_attempts
516 self.sched.get_and_register_status_brok(host)
518 #CHANGE_MAX_SVC_CHECK_ATTEMPTS;<host_name>;<service_description>;<check_attempts>
519 def CHANGE_MAX_SVC_CHECK_ATTEMPTS(self, service, check_attempts):
520 service.max_check_attempts = check_attempts
521 self.sched.get_and_register_status_brok(service)
523 #CHANGE_NORMAL_HOST_CHECK_INTERVAL;<host_name>;<check_interval>
524 def CHANGE_NORMAL_HOST_CHECK_INTERVAL(self, host, check_interval):
525 host.check_interval = check_interval
526 self.sched.get_and_register_status_brok(host)
528 #CHANGE_NORMAL_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
529 def CHANGE_NORMAL_SVC_CHECK_INTERVAL(self, service, check_interval):
530 service.check_interval = check_interval
531 self.sched.get_and_register_status_brok(service)
533 #CHANGE_RETRY_HOST_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
534 def CHANGE_RETRY_HOST_CHECK_INTERVAL(self, host, check_interval):
535 host.retry_interval = check_interval
536 self.sched.get_and_register_status_brok(host)
538 #CHANGE_RETRY_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
539 def CHANGE_RETRY_SVC_CHECK_INTERVAL(self, service, check_interval):
540 service.retry_interval = check_interval
541 self.sched.get_and_register_status_brok(service)
543 #CHANGE_SVC_CHECK_COMMAND;<host_name>;<service_description>;<check_command>
544 def CHANGE_SVC_CHECK_COMMAND(self, service, check_command):
545 service.check_command = CommandCall(self.commands, check_command, poller_tag=service.poller_tag)
546 self.sched.get_and_register_status_brok(service)
548 #CHANGE_SVC_CHECK_TIMEPERIOD;<host_name>;<service_description>;<check_timeperiod>
549 def CHANGE_SVC_CHECK_TIMEPERIOD(self, service, check_timeperiod):
550 service.check_period = check_timeperiod
551 self.sched.get_and_register_status_brok(service)
553 #CHANGE_SVC_EVENT_HANDLER;<host_name>;<service_description>;<event_handler_command>
554 def CHANGE_SVC_EVENT_HANDLER(self, service, event_handler_command):
555 service.event_handler = CommandCall(self.commands, event_handler_command)
556 self.sched.get_and_register_status_brok(service)
558 #CHANGE_SVC_MODATTR;<host_name>;<service_description>;<value>
559 def CHANGE_SVC_MODATTR(self, service, value):
560 pass
562 #CHANGE_SVC_NOTIFICATION_TIMEPERIOD;<host_name>;<service_description>;<notification_timeperiod>
563 def CHANGE_SVC_NOTIFICATION_TIMEPERIOD(self, service, notification_timeperiod):
564 service.notification_period = notification_timeperiod
565 self.sched.get_and_register_status_brok(service)
567 #DELAY_HOST_NOTIFICATION;<host_name>;<notification_time>
568 def DELAY_HOST_NOTIFICATION(self, host, notification_time):
569 host.first_notification_delay = notification_time
570 self.sched.get_and_register_status_brok(host)
572 #DELAY_SVC_NOTIFICATION;<host_name>;<service_description>;<notification_time>
573 def DELAY_SVC_NOTIFICATION(self, service, notification_time):
574 service.first_notification_delay = notification_time
575 self.sched.get_and_register_status_brok(service)
577 #DEL_ALL_HOST_COMMENTS;<host_name>
578 def DEL_ALL_HOST_COMMENTS(self, host):
579 for c in host.comments:
580 self.DEL_HOST_COMMENT(c.id)
582 #DEL_ALL_SVC_COMMENTS;<host_name>;<service_description>
583 def DEL_ALL_SVC_COMMENTS(self, service):
584 for c in service.comments:
585 self.DEL_SVC_COMMENT(c.id)
587 #DEL_CONTACT_DOWNTIME;<downtime_id>
588 def DEL_CONTACT_DOWNTIME(self, downtime_id):
589 if downtime_id in self.sched.contact_downtimes:
590 self.sched.contact_downtimes[downtime_id].cancel()
593 #DEL_HOST_COMMENT;<comment_id>
594 def DEL_HOST_COMMENT(self, comment_id):
595 if comment_id in self.sched.comments:
596 self.sched.comments[comment_id].can_be_deleted = True
598 #DEL_HOST_DOWNTIME;<downtime_id>
599 def DEL_HOST_DOWNTIME(self, downtime_id):
600 if downtime_id in self.sched.downtimes:
601 self.sched.downtimes[downtime_id].cancel()
603 #DEL_SVC_COMMENT;<comment_id>
604 def DEL_SVC_COMMENT(self, comment_id):
605 if comment_id in self.sched.comments:
606 self.sched.comments[comment_id].can_be_deleted = True
608 #DEL_SVC_DOWNTIME;<downtime_id>
609 def DEL_SVC_DOWNTIME(self, downtime_id):
610 if downtime_id in self.sched.downtimes:
611 self.sched.downtimes[downtime_id].cancel()
613 #DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
614 def DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST(self, host):
615 pass
617 #DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>
618 def DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS(self, contactgroup):
619 for contact in contactgroup:
620 self.DISABLE_CONTACT_HOST_NOTIFICATIONS(contact)
622 #DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>
623 def DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS(self, contactgroup):
624 for contact in contactgroup:
625 self.DISABLE_CONTACT_SVC_NOTIFICATIONS(contact)
627 #DISABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
628 def DISABLE_CONTACT_HOST_NOTIFICATIONS(self, contact):
629 contact.host_notifications_enabled = False
630 self.sched.get_and_register_status_brok(contact)
632 #DISABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
633 def DISABLE_CONTACT_SVC_NOTIFICATIONS(self, contact):
634 contact.service_notifications_enabled = False
635 self.sched.get_and_register_status_brok(contact)
637 #DISABLE_EVENT_HANDLERS
638 def DISABLE_EVENT_HANDLERS(self):
639 self.conf.enable_event_handlers = False
640 self.conf.explode_global_conf()
641 self.sched.get_and_register_update_program_status_brok()
643 #DISABLE_FAILURE_PREDICTION
644 def DISABLE_FAILURE_PREDICTION(self):
645 self.conf.enable_failure_prediction = False
646 self.conf.explode_global_conf()
647 self.sched.get_and_register_update_program_status_brok()
649 #DISABLE_FLAP_DETECTION
650 def DISABLE_FLAP_DETECTION(self):
651 self.conf.enable_flap_detection = False
652 self.conf.explode_global_conf()
653 self.sched.get_and_register_update_program_status_brok()
655 #DISABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
656 def DISABLE_HOSTGROUP_HOST_CHECKS(self, hostgroup):
657 for host in hostgroup:
658 self.DISABLE_HOST_CHECK(host)
660 #DISABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>
661 def DISABLE_HOSTGROUP_HOST_NOTIFICATIONS(self, hostgroup):
662 for host in hostgroup:
663 self.DISABLE_HOST_NOTIFICATIONS(host)
665 #DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>
666 def DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS(self, hostgroup):
667 for host in hostgroup:
668 self.DISABLE_PASSIVE_HOST_CHECKS(host)
670 #DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>
671 def DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS(self, hostgroup):
672 for host in hostgroup:
673 for service in host.services:
674 self.DISABLE_PASSIVE_SVC_CHECKS(service)
676 #DISABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>
677 def DISABLE_HOSTGROUP_SVC_CHECKS(self, hostgroup):
678 for host in hostgroup:
679 for service in host.services:
680 self.DISABLE_SVC_CHECK(service)
682 #DISABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>
683 def DISABLE_HOSTGROUP_SVC_NOTIFICATIONS(self, hostgroup):
684 for host in hostgroup:
685 for service in host.services:
686 self.DISABLE_SVC_NOTIFICATIONS(service)
688 #DISABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name>
689 def DISABLE_HOST_AND_CHILD_NOTIFICATIONS(self, host):
690 pass
692 #DISABLE_HOST_CHECK;<host_name>
693 def DISABLE_HOST_CHECK(self, host):
694 host.active_checks_enabled = False
695 self.sched.get_and_register_status_brok(host)
697 #DISABLE_HOST_EVENT_HANDLER;<host_name>
698 def DISABLE_HOST_EVENT_HANDLER(self, host):
699 host.event_handler_enabled = False
700 self.sched.get_and_register_status_brok(host)
702 #DISABLE_HOST_FLAP_DETECTION;<host_name>
703 def DISABLE_HOST_FLAP_DETECTION(self, host):
704 host.flap_detection_enabled = False
705 self.sched.get_and_register_status_brok(host)
707 #DISABLE_HOST_FRESHNESS_CHECKS
708 def DISABLE_HOST_FRESHNESS_CHECKS(self, host):
709 host.check_freshness = False
710 self.sched.get_and_register_status_brok(host)
712 #DISABLE_HOST_NOTIFICATIONS;<host_name>
713 def DISABLE_HOST_NOTIFICATIONS(self, host):
714 host.notifications_enabled = False
715 self.sched.get_and_register_status_brok(host)
717 #DISABLE_HOST_SVC_CHECKS;<host_name>
718 def DISABLE_HOST_SVC_CHECKS(self, host):
719 for s in host.services:
720 self.DISABLE_SVC_CHECK(s)
721 self.sched.get_and_register_status_brok(s)
723 #DISABLE_HOST_SVC_NOTIFICATIONS;<host_name>
724 def DISABLE_HOST_SVC_NOTIFICATIONS(self, host):
725 for s in host.services:
726 self.DISABLE_SVC_NOTIFICATIONS(s)
727 self.sched.get_and_register_status_brok(s)
729 #DISABLE_NOTIFICATIONS
730 def DISABLE_NOTIFICATIONS(self):
731 self.conf.enable_notifications = False
732 self.conf.explode_global_conf()
733 self.sched.get_and_register_update_program_status_brok()
735 #DISABLE_PASSIVE_HOST_CHECKS;<host_name>
736 def DISABLE_PASSIVE_HOST_CHECKS(self, host):
737 host.passive_checks_enabled = False
738 self.sched.get_and_register_status_brok(host)
740 #DISABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
741 def DISABLE_PASSIVE_SVC_CHECKS(self, service):
742 service.passive_checks_enabled = False
743 self.sched.get_and_register_status_brok(service)
745 #DISABLE_PERFORMANCE_DATA
746 def DISABLE_PERFORMANCE_DATA(self):
747 self.conf.process_performance_data = False
748 self.conf.explode_global_conf()
749 self.sched.get_and_register_update_program_status_brok()
751 #DISABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
752 def DISABLE_SERVICEGROUP_HOST_CHECKS(self, servicegroup):
753 for service in servicegroup:
754 self.DISABLE_HOST_CHECK(service.host)
756 #DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>
757 def DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS(self, servicegroup):
758 for service in servicegroup:
759 self.DISABLE_HOST_NOTIFICATIONS(service.host)
761 #DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
762 def DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS(self, servicegroup):
763 for service in servicegroup:
764 self.DISABLE_PASSIVE_HOST_CHECKS(service.host)
766 #DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>
767 def DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS(self, servicegroup):
768 for service in servicegroup:
769 self.DISABLE_PASSIVE_SVC_CHECKS(service)
771 #DISABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>
772 def DISABLE_SERVICEGROUP_SVC_CHECKS(self, servicegroup):
773 for service in servicegroup:
774 self.DISABLE_SVC_CHECK(service)
776 #DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>
777 def DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS(self, servicegroup):
778 for service in servicegroup:
779 self.DISABLE_SVC_NOTIFICATIONS(service)
781 #DISABLE_SERVICE_FLAP_DETECTION;<host_name>;<service_description>
782 def DISABLE_SERVICE_FLAP_DETECTION(self, service):
783 service.flap_detection_enabled = False
784 self.sched.get_and_register_status_brok(service)
786 #DISABLE_SERVICE_FRESHNESS_CHECKS
787 def DISABLE_SERVICE_FRESHNESS_CHECKS(self):
788 self.conf.check_service_freshness = False
789 self.conf.explode_global_conf()
790 self.sched.get_and_register_update_program_status_brok()
792 #DISABLE_SVC_CHECK;<host_name>;<service_description>
793 def DISABLE_SVC_CHECK(self, service):
794 service.active_checks_enabled = False
795 self.sched.get_and_register_status_brok(service)
797 #DISABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
798 def DISABLE_SVC_EVENT_HANDLER(self, service):
799 service.event_handler_enabled = False
800 self.sched.get_and_register_status_brok(service)
802 #DISABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
803 def DISABLE_SVC_FLAP_DETECTION(self, service):
804 service.flap_detection_enabled = False
805 self.sched.get_and_register_status_brok(service)
807 #DISABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
808 def DISABLE_SVC_NOTIFICATIONS(self, service):
809 service.notifications_enabled = False
810 self.sched.get_and_register_status_brok(service)
812 #ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
813 def ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST(self, host):
814 pass
816 #ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>
817 def ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS(self, contactgroup):
818 for contact in contactgroup:
819 self.ENABLE_CONTACT_HOST_NOTIFICATIONS(contact)
821 #ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>
822 def ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS(self, contactgroup):
823 for contact in contactgroup:
824 self.ENABLE_CONTACT_SVC_NOTIFICATIONS(contact)
826 #ENABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
827 def ENABLE_CONTACT_HOST_NOTIFICATIONS(self, contact):
828 contact.host_notifications_enabled = True
829 self.sched.get_and_register_status_brok(contact)
831 #ENABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
832 def ENABLE_CONTACT_SVC_NOTIFICATIONS(self, contact):
833 contact.service_notifications_enabled = True
834 self.sched.get_and_register_status_brok(contact)
836 #ENABLE_EVENT_HANDLERS
837 def ENABLE_EVENT_HANDLERS(self):
838 self.conf.enable_event_handlers = True
839 self.conf.explode_global_conf()
840 self.sched.get_and_register_update_program_status_brok()
842 #ENABLE_FAILURE_PREDICTION
843 def ENABLE_FAILURE_PREDICTION(self):
844 self.conf.enable_failure_prediction = True
845 self.conf.explode_global_conf()
846 self.sched.get_and_register_update_program_status_brok()
848 #ENABLE_FLAP_DETECTION
849 def ENABLE_FLAP_DETECTION(self):
850 self.conf.enable_flap_detection = True
851 self.conf.explode_global_conf()
852 self.sched.get_and_register_update_program_status_brok()
854 #ENABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
855 def ENABLE_HOSTGROUP_HOST_CHECKS(self, hostgroup):
856 for host in hostgroup:
857 self.ENABLE_HOST_CHECK(host)
859 #ENABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>
860 def ENABLE_HOSTGROUP_HOST_NOTIFICATIONS(self, hostgroup):
861 for host in hostgroup:
862 self.ENABLE_HOST_NOTIFICATIONS(host)
864 #ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>
865 def ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS(self, hostgroup):
866 for host in hostgroup:
867 self.ENABLE_PASSIVE_HOST_CHECKS(host)
869 #ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>
870 def ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS(self, hostgroup):
871 for host in hostgroup:
872 for service in host.services:
873 self.ENABLE_PASSIVE_SVC_CHECKS(service)
875 #ENABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>
876 def ENABLE_HOSTGROUP_SVC_CHECKS(self, hostgroup):
877 for host in hostgroup:
878 for service in host.services:
879 self.ENABLE_SVC_CHECK(service)
881 #ENABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>
882 def ENABLE_HOSTGROUP_SVC_NOTIFICATIONS(self, hostgroup):
883 for host in hostgroup:
884 for service in host.services:
885 self.ENABLE_SVC_NOTIFICATIONS(service)
887 #ENABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name>
888 def ENABLE_HOST_AND_CHILD_NOTIFICATIONS(self, host):
889 pass
891 #ENABLE_HOST_CHECK;<host_name>
892 def ENABLE_HOST_CHECK(self, host):
893 host.active_checks_enabled = True
894 self.sched.get_and_register_status_brok(host)
896 #ENABLE_HOST_EVENT_HANDLER;<host_name>
897 def ENABLE_HOST_EVENT_HANDLER(self, host):
898 host.enable_event_handlers = True
899 self.sched.get_and_register_status_brok(host)
901 #ENABLE_HOST_FLAP_DETECTION;<host_name>
902 def ENABLE_HOST_FLAP_DETECTION(self, host):
903 host.flap_detection_enabled = True
904 self.sched.get_and_register_status_brok(host)
906 #ENABLE_HOST_FRESHNESS_CHECKS
907 def ENABLE_HOST_FRESHNESS_CHECKS(self):
908 self.conf.check_host_freshness = True
909 self.conf.explode_global_conf()
910 self.sched.get_and_register_update_program_status_brok()
912 #ENABLE_HOST_NOTIFICATIONS;<host_name>
913 def ENABLE_HOST_NOTIFICATIONS(self, host):
914 host.notifications_enabled = True
915 self.sched.get_and_register_status_brok(host)
917 #ENABLE_HOST_SVC_CHECKS;<host_name>
918 def ENABLE_HOST_SVC_CHECKS(self, host):
919 for s in host.services:
920 self.ENABLE_SVC_CHECK(s)
921 self.sched.get_and_register_status_brok(s)
923 #ENABLE_HOST_SVC_NOTIFICATIONS;<host_name>
924 def ENABLE_HOST_SVC_NOTIFICATIONS(self, host):
925 for s in host.services:
926 self.ENABLE_SVC_NOTIFICATIONS(s)
927 self.sched.get_and_register_status_brok(s)
929 #ENABLE_NOTIFICATIONS
930 def ENABLE_NOTIFICATIONS(self):
931 self.conf.enable_notifications = True
932 self.conf.explode_global_conf()
933 self.sched.get_and_register_update_program_status_brok()
935 #ENABLE_PASSIVE_HOST_CHECKS;<host_name>
936 def ENABLE_PASSIVE_HOST_CHECKS(self, host):
937 host.passive_checks_enabled = True
938 self.sched.get_and_register_status_brok(host)
940 #ENABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
941 def ENABLE_PASSIVE_SVC_CHECKS(self, service):
942 service.passive_checks_enabled = True
943 self.sched.get_and_register_status_brok(service)
945 #ENABLE_PERFORMANCE_DATA
946 def ENABLE_PERFORMANCE_DATA(self):
947 self.conf.process_performance_data = True
948 self.conf.explode_global_conf()
949 self.sched.get_and_register_update_program_status_brok()
951 #ENABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
952 def ENABLE_SERVICEGROUP_HOST_CHECKS(self, servicegroup):
953 for service in servicegroup:
954 self.ENABLE_HOST_CHECK(service.host)
956 #ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>
957 def ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS(self, servicegroup):
958 for service in servicegroup:
959 self.ENABLE_HOST_NOTIFICATIONS(service.host)
961 #ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
962 def ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS(self, servicegroup):
963 for service in servicegroup:
964 self.ENABLE_PASSIVE_HOST_CHECKS(service.host)
966 #ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>
967 def ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS(self, servicegroup):
968 for service in servicegroup:
969 self.ENABLE_PASSIVE_SVC_CHECKS(service)
971 #ENABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>
972 def ENABLE_SERVICEGROUP_SVC_CHECKS(self, servicegroup):
973 for service in servicegroup:
974 self.ENABLE_SVC_CHECK(service)
976 #ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>
977 def ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS(self, servicegroup):
978 for service in servicegroup:
979 self.ENABLE_SVC_NOTIFICATIONS(service)
981 #ENABLE_SERVICE_FRESHNESS_CHECKS
982 def ENABLE_SERVICE_FRESHNESS_CHECKS(self):
983 self.conf.check_service_freshness = True
984 self.conf.explode_global_conf()
985 self.sched.get_and_register_update_program_status_brok()
987 #ENABLE_SVC_CHECK;<host_name>;<service_description>
988 def ENABLE_SVC_CHECK(self, service):
989 service.active_checks_enabled = True
990 self.sched.get_and_register_status_brok(service)
992 #ENABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
993 def ENABLE_SVC_EVENT_HANDLER(self, service):
994 service.event_handler_enabled = True
995 self.sched.get_and_register_status_brok(service)
997 #ENABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
998 def ENABLE_SVC_FLAP_DETECTION(self, service):
999 service.flap_detection_enabled = True
1000 self.sched.get_and_register_status_brok(service)
1002 #ENABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
1003 def ENABLE_SVC_NOTIFICATIONS(self, service):
1004 service.notifications_enabled = True
1005 self.sched.get_and_register_status_brok(service)
1007 #PROCESS_FILE;<file_name>;<delete>
1008 def PROCESS_FILE(self, file_name, delete):
1009 pass
1011 #TODO : say that check is PASSIVE
1012 #PROCESS_HOST_CHECK_RESULT;<host_name>;<status_code>;<plugin_output>
1013 def PROCESS_HOST_CHECK_RESULT(self, host, status_code, plugin_output):
1014 #raise a PASSIVE check only if needed
1015 if self.conf.log_passive_checks:
1016 logger.log('PASSIVE HOST CHECK: %s;%d;%s' % (host.get_name(), status_code, plugin_output))
1017 now = time.time()
1018 cls = host.__class__
1019 #If globally disable OR locally, do not launch
1020 if cls.accept_passive_checks and host.passive_checks_enabled:
1021 i = host.launch_check(now, force=True)
1022 for chk in host.actions:
1023 if chk.id == i:
1024 c = chk
1025 #Now we 'transform the check into a result'
1026 #So exit_status, output and status is eaten by the host
1027 c.exit_status = status_code
1028 c.get_outputs(plugin_output, host.max_plugins_output_length)
1029 c.status = 'waitconsume'
1030 self.sched.nb_check_received += 1
1031 #Ok now this result will be reap by scheduler the next loop
1034 #PROCESS_SERVICE_CHECK_RESULT;<host_name>;<service_description>;<return_code>;<plugin_output>
1035 def PROCESS_SERVICE_CHECK_RESULT(self, service, return_code, plugin_output):
1036 #raise a PASSIVE check only if needed
1037 if self.conf.log_passive_checks:
1038 logger.log('PASSIVE SERVICE CHECK: %s;%s;%d;%s' % (service.host.get_name(), service.get_name(), return_code, plugin_output))
1039 now = time.time()
1040 cls = service.__class__
1041 #If globally disable OR locally, do not launch
1042 if cls.accept_passive_checks and service.passive_checks_enabled:
1043 i = service.launch_check(now, force=True)
1044 for chk in service.actions:
1045 if chk.id == i:
1046 c = chk
1047 #Now we 'transform the check into a result'
1048 #So exit_status, output and status is eaten by the service
1049 c.exit_status = return_code
1050 c.get_outputs(plugin_output, service.max_plugins_output_length)
1051 c.status = 'waitconsume'
1052 self.sched.nb_check_received += 1
1053 #Ok now this result will be reap by scheduler the next loop
1056 #READ_STATE_INFORMATION
1057 def READ_STATE_INFORMATION(self):
1058 pass
1060 #REMOVE_HOST_ACKNOWLEDGEMENT;<host_name>
1061 def REMOVE_HOST_ACKNOWLEDGEMENT(self, host):
1062 host.unacknowledge_problem()
1064 #REMOVE_SVC_ACKNOWLEDGEMENT;<host_name>;<service_description>
1065 def REMOVE_SVC_ACKNOWLEDGEMENT(self, service):
1066 service.unacknowledge_problem()
1068 #RESTART_PROGRAM
1069 def RESTART_PROGRAM(self):
1070 pass
1072 #SAVE_STATE_INFORMATION
1073 def SAVE_STATE_INFORMATION(self):
1074 pass
1076 #SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1077 def SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME(self, host, start_time, end_time, fixed, trigger_id, duration, author, comment):
1078 pass
1080 #SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1081 def SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME(self, host, start_time, end_time, fixed, trigger_id, duration, author, comment):
1082 pass
1084 #SCHEDULE_CONTACT_DOWNTIME;<contact_name>;<start_time>;<end_time>;<author>;<comment>
1085 def SCHEDULE_CONTACT_DOWNTIME(self, contact, start_time, end_time, author, comment):
1086 dt = ContactDowntime(contact, start_time, end_time, author, comment)
1087 contact.add_downtime(dt)
1088 self.sched.add(dt)
1089 self.sched.get_and_register_status_brok(contact)
1091 #SCHEDULE_FORCED_HOST_CHECK;<host_name>;<check_time>
1092 def SCHEDULE_FORCED_HOST_CHECK(self, host, check_time):
1093 host.schedule(force=True, force_time=check_time)
1094 self.sched.get_and_register_status_brok(host)
1096 #SCHEDULE_FORCED_HOST_SVC_CHECKS;<host_name>;<check_time>
1097 def SCHEDULE_FORCED_HOST_SVC_CHECKS(self, host, check_time):
1098 for s in host.services:
1099 self.SCHEDULE_FORCED_SVC_CHECK(s, check_time)
1100 self.sched.get_and_register_status_brok(s)
1102 #SCHEDULE_FORCED_SVC_CHECK;<host_name>;<service_description>;<check_time>
1103 def SCHEDULE_FORCED_SVC_CHECK(self, service, check_time):
1104 service.schedule(force=True, force_time=check_time)
1105 self.sched.get_and_register_status_brok(service)
1107 #SCHEDULE_HOSTGROUP_HOST_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1108 def SCHEDULE_HOSTGROUP_HOST_DOWNTIME(self, hostgroup, start_time, end_time, fixed, trigger_id, duration, author, comment):
1109 pass
1111 #SCHEDULE_HOSTGROUP_SVC_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1112 def SCHEDULE_HOSTGROUP_SVC_DOWNTIME(self, hostgroup, start_time, end_time, fixed, trigger_id, duration, author, comment):
1113 pass
1115 #SCHEDULE_HOST_CHECK;<host_name>;<check_time>
1116 def SCHEDULE_HOST_CHECK(self, host, check_time):
1117 host.schedule(force=False, force_time=check_time)
1118 self.sched.get_and_register_status_brok(host)
1120 #SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1121 def SCHEDULE_HOST_DOWNTIME(self, host, start_time, end_time, fixed, trigger_id, duration, author, comment):
1122 dt = Downtime(host, start_time, end_time, fixed, trigger_id, duration, author, comment)
1123 host.add_downtime(dt)
1124 self.sched.add(dt)
1125 self.sched.get_and_register_status_brok(host)
1126 if trigger_id != 0 and trigger_id in self.sched.downtimes:
1127 self.sched.downtimes[trigger_id].trigger_me(dt)
1129 #SCHEDULE_HOST_SVC_CHECKS;<host_name>;<check_time>
1130 def SCHEDULE_HOST_SVC_CHECKS(self, host, check_time):
1131 for s in host.services:
1132 self.SCHEDULE_SVC_CHECK(s, check_time)
1133 self.sched.get_and_register_status_brok(s)
1135 #SCHEDULE_HOST_SVC_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1136 def SCHEDULE_HOST_SVC_DOWNTIME(self, host, start_time, end_time, fixed, trigger_id, duration, author, comment):
1137 for s in host.services:
1138 self.SCHEDULE_SVC_DOWNTIME(s, start_time, end_time, fixed, trigger_id, duration, author, comment)
1140 #SCHEDULE_SERVICEGROUP_HOST_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1141 def SCHEDULE_SERVICEGROUP_HOST_DOWNTIME(self, servicegroup, start_time, end_time, fixed, trigger_id, duration, author, comment):
1142 for h in [s.host for s in servicegroup.get_services()]:
1143 self.SCHEDULE_HOST_DOWNTIME(h, start_time, end_time, fixed, trigger_id, duration, author, comment)
1145 #SCHEDULE_SERVICEGROUP_SVC_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1146 def SCHEDULE_SERVICEGROUP_SVC_DOWNTIME(self, servicegroup, start_time, end_time, fixed, trigger_id, duration, author, comment):
1147 for s in servicegroup.get_services():
1148 self.SCHEDULE_SVC_DOWNTIME(s, start_time, end_time, fixed, trigger_id, duration, author, comment)
1150 #SCHEDULE_SVC_CHECK;<host_name>;<service_description>;<check_time>
1151 def SCHEDULE_SVC_CHECK(self, service, check_time):
1152 service.schedule(force=False, force_time=check_time)
1153 self.sched.get_and_register_status_brok(service)
1155 #SCHEDULE_SVC_DOWNTIME;<host_name>;<service_desription><start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1156 def SCHEDULE_SVC_DOWNTIME(self, service, start_time, end_time, fixed, trigger_id, duration, author, comment):
1157 dt = Downtime(service, start_time, end_time, fixed, trigger_id, duration, author, comment)
1158 service.add_downtime(dt)
1159 self.sched.add(dt)
1160 self.sched.get_and_register_status_brok(service)
1161 if trigger_id != 0 and trigger_id in self.sched.downtimes:
1162 self.sched.downtimes[trigger_id].trigger_me(dt)
1164 #SEND_CUSTOM_HOST_NOTIFICATION;<host_name>;<options>;<author>;<comment>
1165 def SEND_CUSTOM_HOST_NOTIFICATION(self, host, options, author, comment):
1166 pass
1168 #SEND_CUSTOM_SVC_NOTIFICATION;<host_name>;<service_description>;<options>;<author>;<comment>
1169 def SEND_CUSTOM_SVC_NOTIFICATION(self, service, options, author, comment):
1170 pass
1172 #SET_HOST_NOTIFICATION_NUMBER;<host_name>;<notification_number>
1173 def SET_HOST_NOTIFICATION_NUMBER(self, host, notification_number):
1174 pass
1176 #SET_SVC_NOTIFICATION_NUMBER;<host_name>;<service_description>;<notification_number>
1177 def SET_SVC_NOTIFICATION_NUMBER(self, service, notification_number):
1178 pass
1180 #SHUTDOWN_PROGRAM
1181 def SHUTDOWN_PROGRAM(self):
1182 pass
1184 #START_ACCEPTING_PASSIVE_HOST_CHECKS
1185 def START_ACCEPTING_PASSIVE_HOST_CHECKS(self):
1186 self.conf.accept_passive_host_checks = True
1187 self.conf.explode_global_conf()
1188 self.sched.get_and_register_update_program_status_brok()
1190 #START_ACCEPTING_PASSIVE_SVC_CHECKS
1191 def START_ACCEPTING_PASSIVE_SVC_CHECKS(self):
1192 self.conf.accept_passive_service_checks = True
1193 self.conf.explode_global_conf()
1194 self.sched.get_and_register_update_program_status_brok()
1196 #START_EXECUTING_HOST_CHECKS
1197 def START_EXECUTING_HOST_CHECKS(self):
1198 self.conf.execute_host_checks = True
1199 self.conf.explode_global_conf()
1200 self.sched.get_and_register_update_program_status_brok()
1202 #START_EXECUTING_SVC_CHECKS
1203 def START_EXECUTING_SVC_CHECKS(self):
1204 self.conf.execute_service_checks = True
1205 self.conf.explode_global_conf()
1206 self.sched.get_and_register_update_program_status_brok()
1208 #START_OBSESSING_OVER_HOST;<host_name>
1209 def START_OBSESSING_OVER_HOST(self, host):
1210 host.obsess_over_host = True
1211 self.sched.get_and_register_status_brok(host)
1213 #START_OBSESSING_OVER_HOST_CHECKS
1214 def START_OBSESSING_OVER_HOST_CHECKS(self):
1215 self.conf.obsess_over_hosts = True
1216 self.conf.explode_global_conf()
1218 #START_OBSESSING_OVER_SVC;<host_name>;<service_description>
1219 def START_OBSESSING_OVER_SVC(self, service):
1220 service.obsess_over_service = True
1221 self.sched.get_and_register_status_brok(service)
1223 #START_OBSESSING_OVER_SVC_CHECKS
1224 def START_OBSESSING_OVER_SVC_CHECKS(self):
1225 self.conf.obsess_over_services = True
1226 self.conf.explode_global_conf()
1227 self.sched.get_and_register_update_program_status_brok()
1229 #STOP_ACCEPTING_PASSIVE_HOST_CHECKS
1230 def STOP_ACCEPTING_PASSIVE_HOST_CHECKS(self):
1231 self.accept_passive_host_checks = False
1232 self.conf.explode_global_conf()
1233 self.sched.get_and_register_update_program_status_brok()
1235 #STOP_ACCEPTING_PASSIVE_SVC_CHECKS
1236 def STOP_ACCEPTING_PASSIVE_SVC_CHECKS(self):
1237 self.accept_passive_service_checks = False
1238 self.conf.explode_global_conf()
1239 self.sched.get_and_register_update_program_status_brok()
1241 #STOP_EXECUTING_HOST_CHECKS
1242 def STOP_EXECUTING_HOST_CHECKS(self):
1243 self.conf.execute_host_checks = False
1244 self.conf.explode_global_conf()
1245 self.sched.get_and_register_update_program_status_brok()
1247 #STOP_EXECUTING_SVC_CHECKS
1248 def STOP_EXECUTING_SVC_CHECKS(self):
1249 self.conf.execute_service_checks = False
1250 self.conf.explode_global_conf()
1251 self.sched.get_and_register_update_program_status_brok()
1253 #STOP_OBSESSING_OVER_HOST;<host_name>
1254 def STOP_OBSESSING_OVER_HOST(self, host):
1255 host.obsess_over_host = False
1256 self.sched.get_and_register_status_brok(host)
1258 #STOP_OBSESSING_OVER_HOST_CHECKS
1259 def STOP_OBSESSING_OVER_HOST_CHECKS(self):
1260 self.conf.obsess_over_hosts = False
1261 self.conf.explode_global_conf()
1262 self.sched.get_and_register_update_program_status_brok()
1264 #STOP_OBSESSING_OVER_SVC;<host_name>;<service_description>
1265 def STOP_OBSESSING_OVER_SVC(self, service):
1266 service.obsess_over_service = False
1267 self.sched.get_and_register_status_brok(service)
1269 #STOP_OBSESSING_OVER_SVC_CHECKS
1270 def STOP_OBSESSING_OVER_SVC_CHECKS(self):
1271 self.conf.obsess_over_services = False
1272 self.conf.explode_global_conf()
1273 self.sched.get_and_register_update_program_status_brok()
1276 ### Now the shinken specific ones
1277 #LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>
1278 def LAUNCH_SVC_EVENT_HANDLER(self, service):
1279 service.get_event_handlers(externalcmd=True)
1282 #LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>
1283 def LAUNCH_HOST_EVENT_HANDLER(self, host):
1284 host.get_event_handlers(externalcmd=True)
1287 #ADD_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>
1288 def ADD_SIMPLE_HOST_DEPENDENCY(self, son, father):
1289 if not son.is_linked_with_host(father):
1290 print "Doing simple link between", son.get_name(), 'and', father.get_name()
1291 # Add a dep link between the son and the father
1292 son.add_host_act_dependancy(father, ['w', 'u', 'd'], None, True)
1293 self.sched.get_and_register_status_brok(son)
1294 self.sched.get_and_register_status_brok(father)
1297 #ADD_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>
1298 def DEL_HOST_DEPENDENCY(self, son, father):
1299 if son.is_linked_with_host(father):
1300 print "removing simple link between", son.get_name(), 'and', father.get_name()
1301 son.del_host_act_dependancy(father)
1302 self.sched.get_and_register_status_brok(son)
1303 self.sched.get_and_register_status_brok(father)
1307 if __name__ == '__main__':
1308 import os
1310 FIFO_PATH = '/tmp/my_fifo'
1312 if os.path.exists(FIFO_PATH):
1313 os.unlink(FIFO_PATH)
1315 if not os.path.exists(FIFO_PATH):
1316 os.umask(0)
1317 os.mkfifo(FIFO_PATH, 0660)
1318 my_fifo = open(FIFO_PATH, 'w+')
1319 print "my_fifo:", my_fifo
1321 print open(FIFO_PATH, 'r').readline()