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
6 # Hartmut Goebel, h.goebel@goebel-consult.de
8 #This file is part of Shinken.
10 #Shinken is free software: you can redistribute it and/or modify
11 #it under the terms of the GNU Affero General Public License as published by
12 #the Free Software Foundation, either version 3 of the License, or
13 #(at your option) any later version.
15 #Shinken is distributed in the hope that it will be useful,
16 #but WITHOUT ANY WARRANTY; without even the implied warranty of
17 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 #GNU Affero General Public License for more details.
20 #You should have received a copy of the GNU Affero General Public License
21 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
27 from shinken
.util
import to_int
, to_bool
28 from shinken
.downtime
import Downtime
29 from shinken
.contactdowntime
import ContactDowntime
30 from shinken
.comment
import Comment
31 from shinken
.objects
import CommandCall
32 from shinken
.log
import logger
33 from shinken
.pollerlink
import PollerLink
36 class ExternalCommand
:
37 my_type
= 'externalcommand'
38 def __init__(self
, cmd_line
):
39 self
.cmd_line
= cmd_line
42 class ExternalCommandManager
:
45 'CHANGE_CONTACT_MODSATTR' : {'global' : True, 'args' : ['contact', None]},
46 'CHANGE_CONTACT_MODHATTR' : {'global' : True, 'args' : ['contact', None]},
47 'CHANGE_CONTACT_MODATTR' : {'global' : True, 'args' : ['contact', None]},
48 'CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD' : {'global' : True, 'args' : ['contact', 'time_period']},
49 'ADD_SVC_COMMENT' : {'global' : False, 'args' : ['service', 'to_bool', 'author', None]},
50 'ADD_HOST_COMMENT' : {'global' : False, 'args' : ['host', 'to_bool', 'author', None]},
51 'ACKNOWLEDGE_SVC_PROBLEM' : {'global' : False, 'args' : ['service' , 'to_int', 'to_bool', 'to_bool', 'author', None]},
52 'ACKNOWLEDGE_HOST_PROBLEM' : {'global' : False, 'args' : ['host', 'to_int', 'to_bool', 'to_bool', 'author', None]},
53 'CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD' : {'global' : True, 'args' : ['contact', 'time_period']},
54 'CHANGE_CUSTOM_CONTACT_VAR' : {'global' : True, 'args' : ['contact', None,None]},
55 'CHANGE_CUSTOM_HOST_VAR' : {'global' : False, 'args' : ['host', None,None]},
56 'CHANGE_CUSTOM_SVC_VAR' : {'global' : False, 'args' : ['service', None,None]},
57 'CHANGE_GLOBAL_HOST_EVENT_HANDLER' : {'global' : True, 'args' : ['command']},
58 'CHANGE_GLOBAL_SVC_EVENT_HANDLER' : {'global' : True, 'args' : ['command']},
59 'CHANGE_HOST_CHECK_COMMAND' : {'global' : False, 'args' : ['host', 'command']},
60 'CHANGE_HOST_CHECK_TIMEPERIOD' : {'global' : False, 'args' : ['host', 'time_period']},
61 'CHANGE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host', 'command']},
62 'CHANGE_HOST_MODATTR' : {'global' : False, 'args' : ['host', 'to_int']},
63 'CHANGE_MAX_HOST_CHECK_ATTEMPTS': {'global' : False, 'args' : ['host', 'to_int']},
64 'CHANGE_MAX_SVC_CHECK_ATTEMPTS' : {'global' : False, 'args' : ['service', 'to_int']},
65 'CHANGE_NORMAL_HOST_CHECK_INTERVAL' : {'global' : False, 'args' : ['host', 'to_int']},
66 'CHANGE_NORMAL_SVC_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
67 'CHANGE_RETRY_HOST_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
68 'CHANGE_RETRY_SVC_CHECK_INTERVAL' : {'global' : False, 'args' : ['service', 'to_int']},
69 'CHANGE_SVC_CHECK_COMMAND' : {'global' : False, 'args' : ['service', 'command']},
70 'CHANGE_SVC_CHECK_TIMEPERIOD' : {'global' : False, 'args' : ['service', 'time_period']},
71 'CHANGE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service', 'command']},
72 'CHANGE_SVC_MODATTR' : {'global' : False, 'args' : ['service', 'to_int']},
73 'CHANGE_SVC_NOTIFICATION_TIMEPERIOD' : {'global' : False, 'args' : ['service', 'time_period']},
74 'DELAY_HOST_NOTIFICATION' : {'global' : False, 'args' : ['host', 'to_int']},
75 'DELAY_SVC_NOTIFICATION' : {'global' : False, 'args' : ['service', 'to_int']},
76 'DEL_ALL_HOST_COMMENTS' : {'global' : False, 'args' : ['host']},
77 'DEL_ALL_SVC_COMMENTS' : {'global' : False, 'args' : ['service']},
78 'DEL_CONTACT_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
79 'DEL_HOST_COMMENT' : {'global' : True, 'args' : ['to_int']},
80 'DEL_HOST_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
81 'DEL_SVC_COMMENT' : {'global' : True, 'args' : ['to_int']},
82 'DEL_SVC_DOWNTIME' : {'global' : True, 'args' : ['to_int']},
83 'DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST' : {'global' : False, 'args' : ['host']},
84 'DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
85 'DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
86 'DISABLE_CONTACT_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
87 'DISABLE_CONTACT_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
88 'DISABLE_EVENT_HANDLERS' : {'global' : True, 'args' : []},
89 'DISABLE_FAILURE_PREDICTION' : {'global' : True, 'args' : []},
90 'DISABLE_FLAP_DETECTION' : {'global' : True, 'args' : []},
91 'DISABLE_HOSTGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
92 'DISABLE_HOSTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
93 'DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
94 'DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
95 'DISABLE_HOSTGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
96 'DISABLE_HOSTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
97 'DISABLE_HOST_AND_CHILD_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
98 'DISABLE_HOST_CHECK' : {'global' : False, 'args' : ['host']},
99 'DISABLE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
100 'DISABLE_HOST_FLAP_DETECTION' : {'global' : False, 'args' : ['host']},
101 'DISABLE_HOST_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
102 'DISABLE_HOST_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
103 'DISABLE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host']},
104 'DISABLE_HOST_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
105 'DISABLE_NOTIFICATIONS' : {'global' : True, 'args' : []},
106 'DISABLE_PASSIVE_HOST_CHECKS' : {'global' : False, 'args' : ['host']},
107 'DISABLE_PASSIVE_SVC_CHECKS' : {'global' : False, 'args' : ['service']},
108 'DISABLE_PERFORMANCE_DATA' : {'global' : True, 'args' : []},
109 'DISABLE_SERVICEGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
110 'DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
111 'DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
112 'DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
113 'DISABLE_SERVICEGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
114 'DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
115 'DISABLE_SERVICE_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
116 'DISABLE_SERVICE_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
117 'DISABLE_SVC_CHECK' : {'global' : False, 'args' : ['service']},
118 'DISABLE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
119 'DISABLE_SVC_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
120 'DISABLE_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['service']},
121 'ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST' : {'global' : False, 'args' : ['host']},
122 'ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
123 'ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact_group']},
124 'ENABLE_CONTACT_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
125 'ENABLE_CONTACT_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['contact']},
126 'ENABLE_EVENT_HANDLERS' : {'global' : True, 'args' : []},
127 'ENABLE_FAILURE_PREDICTION' : {'global' : True, 'args' : []},
128 'ENABLE_FLAP_DETECTION' : {'global' : True, 'args' : []},
129 'ENABLE_HOSTGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
130 'ENABLE_HOSTGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
131 'ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['host_group']},
132 'ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
133 'ENABLE_HOSTGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['host_group']},
134 'ENABLE_HOSTGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['host_group']},
135 'ENABLE_HOST_AND_CHILD_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
136 'ENABLE_HOST_CHECK' : {'global' : False, 'args' : ['host']},
137 'ENABLE_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
138 'ENABLE_HOST_FLAP_DETECTION' : {'global' : False, 'args' : ['host']},
139 'ENABLE_HOST_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
140 'ENABLE_HOST_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
141 'ENABLE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host']},
142 'ENABLE_HOST_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['host']},
143 'ENABLE_NOTIFICATIONS' : {'global' : True, 'args' : []},
144 'ENABLE_PASSIVE_HOST_CHECKS' : {'global' : False, 'args' : ['host']},
145 'ENABLE_PASSIVE_SVC_CHECKS' : {'global' : False, 'args' : ['service']},
146 'ENABLE_PERFORMANCE_DATA' : {'global' : True, 'args' : []},
147 'ENABLE_SERVICEGROUP_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
148 'ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
149 'ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : ['service_group']},
150 'ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
151 'ENABLE_SERVICEGROUP_SVC_CHECKS' : {'global' : True, 'args' : ['service_group']},
152 'ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS' : {'global' : True, 'args' : ['service_group']},
153 'ENABLE_SERVICE_FRESHNESS_CHECKS' : {'global' : True, 'args' : []},
154 'ENABLE_SVC_CHECK': {'global' : False, 'args' : ['service']},
155 'ENABLE_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
156 'ENABLE_SVC_FLAP_DETECTION' : {'global' : False, 'args' : ['service']},
157 'ENABLE_SVC_NOTIFICATIONS' : {'global' : False, 'args' : ['service']},
158 'PROCESS_FILE' : {'global' : True, 'args' : [None, 'to_bool']},
159 'PROCESS_HOST_CHECK_RESULT' : {'global' : False, 'args' : ['host', 'to_int', None]},
160 'PROCESS_SERVICE_CHECK_RESULT' : {'global' : False, 'args' : ['service', 'to_int', None]},
161 'READ_STATE_INFORMATION' : {'global' : True, 'args' : []},
162 'REMOVE_HOST_ACKNOWLEDGEMENT' : {'global' : False, 'args' : ['host']},
163 'REMOVE_SVC_ACKNOWLEDGEMENT' : {'global' : False, 'args' : ['service']},
164 'RESTART_PROGRAM' : {'global' : True, 'args' : []},
165 'SAVE_STATE_INFORMATION' : {'global' : True, 'args' : []},
166 'SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
167 'SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
168 'SCHEDULE_CONTACT_DOWNTIME' : {'global' : True, 'args' : ['contact', 'to_int', 'to_int', 'author', None]},
169 'SCHEDULE_FORCED_HOST_CHECK' : {'global' : False, 'args' : ['host', 'to_int']},
170 'SCHEDULE_FORCED_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host', 'to_int']},
171 'SCHEDULE_FORCED_SVC_CHECK' : {'global' : False, 'args' : ['service', 'to_int']},
172 'SCHEDULE_HOSTGROUP_HOST_DOWNTIME' : {'global' : True, 'args' : ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
173 'SCHEDULE_HOSTGROUP_SVC_DOWNTIME' : {'global' : True, 'args' : ['host_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author',None]},
174 'SCHEDULE_HOST_CHECK' : {'global' : False, 'args' : ['host', 'to_int']},
175 'SCHEDULE_HOST_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
176 'SCHEDULE_HOST_SVC_CHECKS' : {'global' : False, 'args' : ['host', 'to_int']},
177 'SCHEDULE_HOST_SVC_DOWNTIME' : {'global' : False, 'args' : ['host', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
178 'SCHEDULE_SERVICEGROUP_HOST_DOWNTIME' : {'global' : True, 'args' : ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
179 'SCHEDULE_SERVICEGROUP_SVC_DOWNTIME' : {'global' : True, 'args' : ['service_group', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
180 'SCHEDULE_SVC_CHECK' : {'global' : False, 'args' : ['service', 'to_int']},
181 'SCHEDULE_SVC_DOWNTIME' : {'global' : False, 'args' : ['service', 'to_int', 'to_int', 'to_bool', 'to_int', 'to_int', 'author', None]},
182 'SEND_CUSTOM_HOST_NOTIFICATION' : {'global' : False, 'args' : ['host', 'to_int', 'author', None]},
183 'SEND_CUSTOM_SVC_NOTIFICATION' : {'global' : False, 'args' : ['service', 'to_int', 'author', None]},
184 'SET_HOST_NOTIFICATION_NUMBER' : {'global' : False, 'args' : ['host', 'to_int']},
185 'SET_SVC_NOTIFICATION_NUMBER' : {'global' : False, 'args' : ['service', 'to_int']},
186 'SHUTDOWN_PROGRAM' : {'global' : True, 'args' : []},
187 'START_ACCEPTING_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : []},
188 'START_ACCEPTING_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : []},
189 'START_EXECUTING_HOST_CHECKS' : {'global' : True, 'args' : []},
190 'START_EXECUTING_SVC_CHECKS' : {'global' : True, 'args' : []},
191 'START_OBSESSING_OVER_HOST' : {'global' : False, 'args' : ['host']},
192 'START_OBSESSING_OVER_HOST_CHECKS' : {'global' : True, 'args' : []},
193 'START_OBSESSING_OVER_SVC' : {'global' : False, 'args' : ['service']},
194 'START_OBSESSING_OVER_SVC_CHECKS' : {'global' : True, 'args' : []},
195 'STOP_ACCEPTING_PASSIVE_HOST_CHECKS' : {'global' : True, 'args' : []},
196 'STOP_ACCEPTING_PASSIVE_SVC_CHECKS' : {'global' : True, 'args' : []},
197 'STOP_EXECUTING_HOST_CHECKS' : {'global' : True, 'args' : []},
198 'STOP_EXECUTING_SVC_CHECKS' : {'global' : True, 'args' : []},
199 'STOP_OBSESSING_OVER_HOST' : {'global' : False, 'args' : ['host']},
200 'STOP_OBSESSING_OVER_HOST_CHECKS' : {'global' : True, 'args' : []},
201 'STOP_OBSESSING_OVER_SVC' : {'global' : False, 'args' : ['service']},
202 'STOP_OBSESSING_OVER_SVC_CHECKS' : {'global' : True, 'args' : []},
203 'LAUNCH_SVC_EVENT_HANDLER' : {'global' : False, 'args' : ['service']},
204 'LAUNCH_HOST_EVENT_HANDLER' : {'global' : False, 'args' : ['host']},
206 'ADD_SIMPLE_HOST_DEPENDENCY' : {'global' : False, 'args' : ['host', 'host']},
207 'DEL_HOST_DEPENDENCY' : {'global' : False, 'args' : ['host', 'host']},
208 'ADD_SIMPLE_POLLER' : {'global' : True, 'internal' : True, 'args' : [None, None, None, None]},
212 def __init__(self
, conf
, mode
):
215 self
.hosts
= conf
.hosts
216 self
.services
= conf
.services
217 self
.contacts
= conf
.contacts
218 self
.hostgroups
= conf
.hostgroups
219 self
.commands
= conf
.commands
220 self
.servicegroups
= conf
.servicegroups
221 self
.contactgroups
= conf
.contactgroups
222 self
.timeperiods
= conf
.timeperiods
223 self
.pipe_path
= conf
.command_file
225 self
.cmd_fragments
= ''
226 if self
.mode
== 'dispatcher':
227 self
.confs
= conf
.confs
230 def load_scheduler(self
, scheduler
):
231 self
.sched
= scheduler
233 def load_arbiter(self
, arbiter
):
234 self
.arbiter
= arbiter
238 #At the first open del and create the fifo
239 if self
.fifo
is None:
240 if os
.path
.exists(self
.pipe_path
):
241 os
.unlink(self
.pipe_path
)
243 if not os
.path
.exists(self
.pipe_path
):
246 os
.mkfifo(self
.pipe_path
, 0660)
247 open(self
.pipe_path
, 'w+', os
.O_NONBLOCK
)
248 except OSError , exp
:
249 print "Error : pipe creation failed (",self
.pipe_path
,')', exp
251 self
.fifo
= os
.open(self
.pipe_path
, os
.O_NONBLOCK
)
252 #print 'Fifo:', self.fifo
257 buf
= os
.read(self
.fifo
, 8096)
259 fullbuf
= len(buf
) == 8096 and True or False
260 # If the buffer ended with a fragment last time, prepend it here
261 buf
= self
.cmd_fragments
+ buf
263 self
.cmd_fragments
= ''
264 if fullbuf
and buf
[-1] != '\n':
265 # The buffer was full but ends with a command fragment
266 r
.extend([ExternalCommand(s
) for s
in (buf
.split('\n'))[:-1] if s
])
267 self
.cmd_fragments
= (buf
.split('\n'))[-1]
269 # The buffer is either half-filled or full with a '\n' at the end.
270 r
.extend([ExternalCommand(s
) for s
in buf
.split('\n') if s
])
272 # The buffer is empty. We "reset" the fifo here. It will be
273 # re-opened in the main loop.
278 def resolve_command(self
, excmd
):
279 command
= excmd
.cmd_line
280 command
= command
.strip()
281 #Only log if we are in the Arbiter
282 if self
.mode
== 'dispatcher':
283 logger
.log('EXTERNAL COMMAND: '+command
.rstrip())
284 self
.get_command_and_args(command
)
287 #Ok the command is not for every one, so we search
288 #by the hostname which scheduler have the host. Then send
290 def search_host_and_dispatch(self
, host_name
, command
):
291 print "Calling search_host_and_dispatch", 'for', host_name
292 for cfg
in self
.confs
.values():
293 if cfg
.hosts
.find_by_name(host_name
) is not None:
294 print "Host", host_name
, "found in a configuration"
296 sched
= cfg
.assigned_to
297 print "Sending command to the scheduler", sched
.get_name()
298 sched
.run_external_command(command
)
300 print "Problem: a configuration is found, but is not assigned!"
302 logger
.log("Warning: Passive check result was received for host '%s', but the host could not be found!" % host_name
)
303 #print "Sorry but the host", host_name, "was not found"
306 #The command is global, so sent it to every schedulers
307 def dispatch_global_command(self
, command
):
308 for sched
in self
.conf
.schedulerlinks
:
309 print "Sending a command", command
, 'to scheduler', sched
311 sched
.run_external_command(command
)
314 #We need to get the first part, the command name
315 def get_command_and_args(self
, command
):
316 print "Trying to resolve", command
317 command
= command
.rstrip()
318 elts
= command
.split(';') # danger!!! passive checkresults with perfdata
321 elts2
= part1
.split(' ')
322 print "Elts2:", elts2
324 print "Malformed command", command
328 print "Get command name", c_name
329 if c_name
not in ExternalCommandManager
.commands
:
330 print "This command is not recognized, sorry"
333 # Split again based on the number of args we expect. We cannot split
334 # on every ; because this character may appear in the perfdata of
335 # passive check results.
336 entry
= ExternalCommandManager
.commands
[c_name
]
338 #Look if the command is purely internal or not
340 if 'internal' in entry
and entry
['internal']:
343 numargs
= len(entry
['args'])
344 if numargs
and 'service' in entry
['args']:
346 elts
= command
.split(';', numargs
)
348 print self
.mode
, entry
['global']
349 if self
.mode
== 'dispatcher' and entry
['global']:
351 print "This command is a global one, we resent it to all schedulers"
352 self
.dispatch_global_command(command
)
355 print "Is global?", c_name
, entry
['global']
356 print "Mode:", self
.mode
357 print "This command have arguments:", entry
['args'], len(entry
['args'])
365 print "Searching for a new arg:", elt
, i
370 print "For command arg", val
373 type_searched
= entry
['args'][i
-1]
374 print "Search for a arg", type_searched
376 if type_searched
== 'host':
377 if self
.mode
== 'dispatcher':
378 self
.search_host_and_dispatch(val
, command
)
380 h
= self
.hosts
.find_by_name(val
)
384 elif type_searched
== 'contact':
385 c
= self
.contacts
.find_by_name(val
)
389 elif type_searched
== 'time_period':
390 t
= self
.timeperiods
.find_by_name(val
)
394 elif type_searched
== 'to_bool':
395 args
.append(to_bool(val
))
397 elif type_searched
== 'to_int':
398 args
.append(to_int(val
))
400 elif type_searched
in ('author', None):
403 elif type_searched
== 'command':
404 c
= self
.commands
.find_cmd_by_name(val
)
406 args
.append(val
)#the find will be redone by
407 #the commandCall creation, but != None
408 #is usefull so a bad command will be catch
410 elif type_searched
== 'host_group':
411 hg
= self
.hostgroups
.find_by_name(val
)
415 elif type_searched
== 'service_group':
416 sg
= self
.servicegroups
.find_by_name(val
)
420 elif type_searched
== 'contact_group':
421 cg
= self
.contact_groups
.find_by_name(val
)
425 #special case: service are TWO args host;service, so one more loop
426 #to get the two parts
427 elif type_searched
== 'service':
429 tmp_host
= elt
.strip()
430 print "TMP HOST", tmp_host
431 if tmp_host
[-1] == '\n':
432 tmp_host
= tmp_host
[:-1]
434 if self
.mode
== 'dispatcher':
435 self
.search_host_and_dispatch(tmp_host
, command
)
442 if srv_name
[-1] == '\n':
443 srv_name
= srv_name
[:-1]
444 print "Got service full", tmp_host
, srv_name
445 s
= self
.services
.find_srv_by_name_and_hostname(tmp_host
, srv_name
)
448 else: #error, must be logged
449 logger
.log("Warning: a command was received for service '%s' on host '%s', but the service could not be found!" % (srv_name
, tmp_host
))
452 print "Sorry, the arguments are not corrects"
454 print 'Finally got ARGS:', args
455 if len(args
) == len(entry
['args']):
456 print "OK, we can call the command", c_name
, "with", args
457 f
= getattr(self
, c_name
)
460 print "Sorry, the arguments are not corrects", args
464 #CHANGE_CONTACT_MODSATTR;<contact_name>;<value>
465 def CHANGE_CONTACT_MODSATTR(self
, contact
, value
):
468 #CHANGE_CONTACT_MODHATTR;<contact_name>;<value>
469 def CHANGE_CONTACT_MODHATTR(self
, contact
, value
):
472 #CHANGE_CONTACT_MODATTR;<contact_name>;<value>
473 def CHANGE_CONTACT_MODATTR(self
, contact
, value
):
476 #CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>
477 def CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD(self
, contact
, notification_timeperiod
):
478 contact
.host_notification_period
= notification_timeperiod
479 self
.sched
.get_and_register_status_brok(contact
)
481 #ADD_SVC_COMMENT;<host_name>;<service_description>;<persistent>;<author>;<comment>
482 def ADD_SVC_COMMENT(self
, service
, persistent
, author
, comment
):
483 c
= Comment(service
, persistent
, author
, comment
, 2, 1, 1, False, 0)
484 service
.add_comment(c
)
487 #ADD_HOST_COMMENT;<host_name>;<persistent>;<author>;<comment>
488 def ADD_HOST_COMMENT(self
, host
, persistent
, author
, comment
):
489 c
= Comment(host
, persistent
, author
, comment
, 1, 1, 1, False, 0)
493 #ACKNOWLEDGE_SVC_PROBLEM;<host_name>;<service_description>;<sticky>;<notify>;<persistent>;<author>;<comment>
494 def ACKNOWLEDGE_SVC_PROBLEM(self
, service
, sticky
, notify
, persistent
, author
, comment
):
495 service
.acknowledge_problem(sticky
, notify
, persistent
, author
, comment
)
497 #ACKNOWLEDGE_HOST_PROBLEM;<host_name>;<sticky>;<notify>;<persistent>;<author>;<comment>
498 #TODO : add a better ACK management
499 def ACKNOWLEDGE_HOST_PROBLEM(self
, host
, sticky
, notify
, persistent
, author
, comment
):
500 host
.acknowledge_problem(sticky
, notify
, persistent
, author
, comment
)
502 #CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>
503 def CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD(self
, contact
, notification_timeperiod
):
504 contact
.service_notification_period
= notification_timeperiod
505 self
.sched
.get_and_register_status_brok(contact
)
507 #CHANGE_CUSTOM_CONTACT_VAR;<contact_name>;<varname>;<varvalue>
508 def CHANGE_CUSTOM_CONTACT_VAR(self
, contact
, varname
, varvalue
):
509 contact
.customs
[varname
.upper()] = varvalue
511 #CHANGE_CUSTOM_HOST_VAR;<host_name>;<varname>;<varvalue>
512 def CHANGE_CUSTOM_HOST_VAR(self
, host
, varname
, varvalue
):
513 host
.customs
[varname
.upper()] = varvalue
515 #CHANGE_CUSTOM_SVC_VAR;<host_name>;<service_description>;<varname>;<varvalue>
516 def CHANGE_CUSTOM_SVC_VAR(self
, service
, varname
, varvalue
):
517 service
.customs
[varname
.upper()] = varvalue
519 #CHANGE_GLOBAL_HOST_EVENT_HANDLER;<event_handler_command>
520 def CHANGE_GLOBAL_HOST_EVENT_HANDLER(self
, event_handler_command
):
523 #CHANGE_GLOBAL_SVC_EVENT_HANDLER;<event_handler_command>
524 def CHANGE_GLOBAL_SVC_EVENT_HANDLER(self
, event_handler_command
):
527 #CHANGE_HOST_CHECK_COMMAND;<host_name>;<check_command>
528 def CHANGE_HOST_CHECK_COMMAND(self
, host
, check_command
):
529 host
.check_command
= CommandCall(self
.commands
, check_command
, poller_tag
=host
.poller_tag
)
530 self
.sched
.get_and_register_status_brok(host
)
532 #CHANGE_HOST_CHECK_TIMEPERIOD;<host_name>;<timeperiod>
533 def CHANGE_HOST_CHECK_TIMEPERIOD(self
, host
, timeperiod
):
534 host
.check_period
= timeperiod
535 self
.sched
.get_and_register_status_brok(service
)
537 #CHANGE_HOST_EVENT_HANDLER;<host_name>;<event_handler_command>
538 def CHANGE_HOST_EVENT_HANDLER(self
, host
, event_handler_command
):
539 host
.event_handler
= CommandCall(self
.commands
, event_handler_command
)
540 self
.sched
.get_and_register_status_brok(host
)
542 #CHANGE_HOST_MODATTR;<host_name>;<value>
543 def CHANGE_HOST_MODATTR(self
, host
, value
):
546 #CHANGE_MAX_HOST_CHECK_ATTEMPTS;<host_name>;<check_attempts>
547 def CHANGE_MAX_HOST_CHECK_ATTEMPTS(self
, host
, check_attempts
):
548 host
.max_check_attempts
= check_attempts
549 self
.sched
.get_and_register_status_brok(host
)
551 #CHANGE_MAX_SVC_CHECK_ATTEMPTS;<host_name>;<service_description>;<check_attempts>
552 def CHANGE_MAX_SVC_CHECK_ATTEMPTS(self
, service
, check_attempts
):
553 service
.max_check_attempts
= check_attempts
554 self
.sched
.get_and_register_status_brok(service
)
556 #CHANGE_NORMAL_HOST_CHECK_INTERVAL;<host_name>;<check_interval>
557 def CHANGE_NORMAL_HOST_CHECK_INTERVAL(self
, host
, check_interval
):
558 host
.check_interval
= check_interval
559 self
.sched
.get_and_register_status_brok(host
)
561 #CHANGE_NORMAL_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
562 def CHANGE_NORMAL_SVC_CHECK_INTERVAL(self
, service
, check_interval
):
563 service
.check_interval
= check_interval
564 self
.sched
.get_and_register_status_brok(service
)
566 #CHANGE_RETRY_HOST_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
567 def CHANGE_RETRY_HOST_CHECK_INTERVAL(self
, host
, check_interval
):
568 host
.retry_interval
= check_interval
569 self
.sched
.get_and_register_status_brok(host
)
571 #CHANGE_RETRY_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>
572 def CHANGE_RETRY_SVC_CHECK_INTERVAL(self
, service
, check_interval
):
573 service
.retry_interval
= check_interval
574 self
.sched
.get_and_register_status_brok(service
)
576 #CHANGE_SVC_CHECK_COMMAND;<host_name>;<service_description>;<check_command>
577 def CHANGE_SVC_CHECK_COMMAND(self
, service
, check_command
):
578 service
.check_command
= CommandCall(self
.commands
, check_command
, poller_tag
=service
.poller_tag
)
579 self
.sched
.get_and_register_status_brok(service
)
581 #CHANGE_SVC_CHECK_TIMEPERIOD;<host_name>;<service_description>;<check_timeperiod>
582 def CHANGE_SVC_CHECK_TIMEPERIOD(self
, service
, check_timeperiod
):
583 service
.check_period
= check_timeperiod
584 self
.sched
.get_and_register_status_brok(service
)
586 #CHANGE_SVC_EVENT_HANDLER;<host_name>;<service_description>;<event_handler_command>
587 def CHANGE_SVC_EVENT_HANDLER(self
, service
, event_handler_command
):
588 service
.event_handler
= CommandCall(self
.commands
, event_handler_command
)
589 self
.sched
.get_and_register_status_brok(service
)
591 #CHANGE_SVC_MODATTR;<host_name>;<service_description>;<value>
592 def CHANGE_SVC_MODATTR(self
, service
, value
):
595 #CHANGE_SVC_NOTIFICATION_TIMEPERIOD;<host_name>;<service_description>;<notification_timeperiod>
596 def CHANGE_SVC_NOTIFICATION_TIMEPERIOD(self
, service
, notification_timeperiod
):
597 service
.notification_period
= notification_timeperiod
598 self
.sched
.get_and_register_status_brok(service
)
600 #DELAY_HOST_NOTIFICATION;<host_name>;<notification_time>
601 def DELAY_HOST_NOTIFICATION(self
, host
, notification_time
):
602 host
.first_notification_delay
= notification_time
603 self
.sched
.get_and_register_status_brok(host
)
605 #DELAY_SVC_NOTIFICATION;<host_name>;<service_description>;<notification_time>
606 def DELAY_SVC_NOTIFICATION(self
, service
, notification_time
):
607 service
.first_notification_delay
= notification_time
608 self
.sched
.get_and_register_status_brok(service
)
610 #DEL_ALL_HOST_COMMENTS;<host_name>
611 def DEL_ALL_HOST_COMMENTS(self
, host
):
612 for c
in host
.comments
:
613 self
.DEL_HOST_COMMENT(c
.id)
615 #DEL_ALL_SVC_COMMENTS;<host_name>;<service_description>
616 def DEL_ALL_SVC_COMMENTS(self
, service
):
617 for c
in service
.comments
:
618 self
.DEL_SVC_COMMENT(c
.id)
620 #DEL_CONTACT_DOWNTIME;<downtime_id>
621 def DEL_CONTACT_DOWNTIME(self
, downtime_id
):
622 if downtime_id
in self
.sched
.contact_downtimes
:
623 self
.sched
.contact_downtimes
[downtime_id
].cancel()
626 #DEL_HOST_COMMENT;<comment_id>
627 def DEL_HOST_COMMENT(self
, comment_id
):
628 if comment_id
in self
.sched
.comments
:
629 self
.sched
.comments
[comment_id
].can_be_deleted
= True
631 #DEL_HOST_DOWNTIME;<downtime_id>
632 def DEL_HOST_DOWNTIME(self
, downtime_id
):
633 if downtime_id
in self
.sched
.downtimes
:
634 self
.sched
.downtimes
[downtime_id
].cancel()
636 #DEL_SVC_COMMENT;<comment_id>
637 def DEL_SVC_COMMENT(self
, comment_id
):
638 if comment_id
in self
.sched
.comments
:
639 self
.sched
.comments
[comment_id
].can_be_deleted
= True
641 #DEL_SVC_DOWNTIME;<downtime_id>
642 def DEL_SVC_DOWNTIME(self
, downtime_id
):
643 if downtime_id
in self
.sched
.downtimes
:
644 self
.sched
.downtimes
[downtime_id
].cancel()
646 #DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
647 def DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST(self
, host
):
650 #DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>
651 def DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS(self
, contactgroup
):
652 for contact
in contactgroup
:
653 self
.DISABLE_CONTACT_HOST_NOTIFICATIONS(contact
)
655 #DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>
656 def DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS(self
, contactgroup
):
657 for contact
in contactgroup
:
658 self
.DISABLE_CONTACT_SVC_NOTIFICATIONS(contact
)
660 #DISABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
661 def DISABLE_CONTACT_HOST_NOTIFICATIONS(self
, contact
):
662 contact
.host_notifications_enabled
= False
663 self
.sched
.get_and_register_status_brok(contact
)
665 #DISABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
666 def DISABLE_CONTACT_SVC_NOTIFICATIONS(self
, contact
):
667 contact
.service_notifications_enabled
= False
668 self
.sched
.get_and_register_status_brok(contact
)
670 #DISABLE_EVENT_HANDLERS
671 def DISABLE_EVENT_HANDLERS(self
):
672 self
.conf
.enable_event_handlers
= False
673 self
.conf
.explode_global_conf()
674 self
.sched
.get_and_register_update_program_status_brok()
676 #DISABLE_FAILURE_PREDICTION
677 def DISABLE_FAILURE_PREDICTION(self
):
678 self
.conf
.enable_failure_prediction
= False
679 self
.conf
.explode_global_conf()
680 self
.sched
.get_and_register_update_program_status_brok()
682 #DISABLE_FLAP_DETECTION
683 def DISABLE_FLAP_DETECTION(self
):
684 self
.conf
.enable_flap_detection
= False
685 self
.conf
.explode_global_conf()
686 self
.sched
.get_and_register_update_program_status_brok()
688 #DISABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
689 def DISABLE_HOSTGROUP_HOST_CHECKS(self
, hostgroup
):
690 for host
in hostgroup
:
691 self
.DISABLE_HOST_CHECK(host
)
693 #DISABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>
694 def DISABLE_HOSTGROUP_HOST_NOTIFICATIONS(self
, hostgroup
):
695 for host
in hostgroup
:
696 self
.DISABLE_HOST_NOTIFICATIONS(host
)
698 #DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>
699 def DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS(self
, hostgroup
):
700 for host
in hostgroup
:
701 self
.DISABLE_PASSIVE_HOST_CHECKS(host
)
703 #DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>
704 def DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS(self
, hostgroup
):
705 for host
in hostgroup
:
706 for service
in host
.services
:
707 self
.DISABLE_PASSIVE_SVC_CHECKS(service
)
709 #DISABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>
710 def DISABLE_HOSTGROUP_SVC_CHECKS(self
, hostgroup
):
711 for host
in hostgroup
:
712 for service
in host
.services
:
713 self
.DISABLE_SVC_CHECK(service
)
715 #DISABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>
716 def DISABLE_HOSTGROUP_SVC_NOTIFICATIONS(self
, hostgroup
):
717 for host
in hostgroup
:
718 for service
in host
.services
:
719 self
.DISABLE_SVC_NOTIFICATIONS(service
)
721 #DISABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name>
722 def DISABLE_HOST_AND_CHILD_NOTIFICATIONS(self
, host
):
725 #DISABLE_HOST_CHECK;<host_name>
726 def DISABLE_HOST_CHECK(self
, host
):
727 host
.active_checks_enabled
= False
728 self
.sched
.get_and_register_status_brok(host
)
730 #DISABLE_HOST_EVENT_HANDLER;<host_name>
731 def DISABLE_HOST_EVENT_HANDLER(self
, host
):
732 host
.event_handler_enabled
= False
733 self
.sched
.get_and_register_status_brok(host
)
735 #DISABLE_HOST_FLAP_DETECTION;<host_name>
736 def DISABLE_HOST_FLAP_DETECTION(self
, host
):
737 host
.flap_detection_enabled
= False
738 self
.sched
.get_and_register_status_brok(host
)
740 #DISABLE_HOST_FRESHNESS_CHECKS
741 def DISABLE_HOST_FRESHNESS_CHECKS(self
, host
):
742 host
.check_freshness
= False
743 self
.sched
.get_and_register_status_brok(host
)
745 #DISABLE_HOST_NOTIFICATIONS;<host_name>
746 def DISABLE_HOST_NOTIFICATIONS(self
, host
):
747 host
.notifications_enabled
= False
748 self
.sched
.get_and_register_status_brok(host
)
750 #DISABLE_HOST_SVC_CHECKS;<host_name>
751 def DISABLE_HOST_SVC_CHECKS(self
, host
):
752 for s
in host
.services
:
753 self
.DISABLE_SVC_CHECK(s
)
754 self
.sched
.get_and_register_status_brok(s
)
756 #DISABLE_HOST_SVC_NOTIFICATIONS;<host_name>
757 def DISABLE_HOST_SVC_NOTIFICATIONS(self
, host
):
758 for s
in host
.services
:
759 self
.DISABLE_SVC_NOTIFICATIONS(s
)
760 self
.sched
.get_and_register_status_brok(s
)
762 #DISABLE_NOTIFICATIONS
763 def DISABLE_NOTIFICATIONS(self
):
764 self
.conf
.enable_notifications
= False
765 self
.conf
.explode_global_conf()
766 self
.sched
.get_and_register_update_program_status_brok()
768 #DISABLE_PASSIVE_HOST_CHECKS;<host_name>
769 def DISABLE_PASSIVE_HOST_CHECKS(self
, host
):
770 host
.passive_checks_enabled
= False
771 self
.sched
.get_and_register_status_brok(host
)
773 #DISABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
774 def DISABLE_PASSIVE_SVC_CHECKS(self
, service
):
775 service
.passive_checks_enabled
= False
776 self
.sched
.get_and_register_status_brok(service
)
778 #DISABLE_PERFORMANCE_DATA
779 def DISABLE_PERFORMANCE_DATA(self
):
780 self
.conf
.process_performance_data
= False
781 self
.conf
.explode_global_conf()
782 self
.sched
.get_and_register_update_program_status_brok()
784 #DISABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
785 def DISABLE_SERVICEGROUP_HOST_CHECKS(self
, servicegroup
):
786 for service
in servicegroup
:
787 self
.DISABLE_HOST_CHECK(service
.host
)
789 #DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>
790 def DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS(self
, servicegroup
):
791 for service
in servicegroup
:
792 self
.DISABLE_HOST_NOTIFICATIONS(service
.host
)
794 #DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
795 def DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS(self
, servicegroup
):
796 for service
in servicegroup
:
797 self
.DISABLE_PASSIVE_HOST_CHECKS(service
.host
)
799 #DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>
800 def DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS(self
, servicegroup
):
801 for service
in servicegroup
:
802 self
.DISABLE_PASSIVE_SVC_CHECKS(service
)
804 #DISABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>
805 def DISABLE_SERVICEGROUP_SVC_CHECKS(self
, servicegroup
):
806 for service
in servicegroup
:
807 self
.DISABLE_SVC_CHECK(service
)
809 #DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>
810 def DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS(self
, servicegroup
):
811 for service
in servicegroup
:
812 self
.DISABLE_SVC_NOTIFICATIONS(service
)
814 #DISABLE_SERVICE_FLAP_DETECTION;<host_name>;<service_description>
815 def DISABLE_SERVICE_FLAP_DETECTION(self
, service
):
816 service
.flap_detection_enabled
= False
817 self
.sched
.get_and_register_status_brok(service
)
819 #DISABLE_SERVICE_FRESHNESS_CHECKS
820 def DISABLE_SERVICE_FRESHNESS_CHECKS(self
):
821 self
.conf
.check_service_freshness
= False
822 self
.conf
.explode_global_conf()
823 self
.sched
.get_and_register_update_program_status_brok()
825 #DISABLE_SVC_CHECK;<host_name>;<service_description>
826 def DISABLE_SVC_CHECK(self
, service
):
827 service
.active_checks_enabled
= False
828 self
.sched
.get_and_register_status_brok(service
)
830 #DISABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
831 def DISABLE_SVC_EVENT_HANDLER(self
, service
):
832 service
.event_handler_enabled
= False
833 self
.sched
.get_and_register_status_brok(service
)
835 #DISABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
836 def DISABLE_SVC_FLAP_DETECTION(self
, service
):
837 service
.flap_detection_enabled
= False
838 self
.sched
.get_and_register_status_brok(service
)
840 #DISABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
841 def DISABLE_SVC_NOTIFICATIONS(self
, service
):
842 service
.notifications_enabled
= False
843 self
.sched
.get_and_register_status_brok(service
)
845 #ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST;<host_name>
846 def ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST(self
, host
):
849 #ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>
850 def ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS(self
, contactgroup
):
851 for contact
in contactgroup
:
852 self
.ENABLE_CONTACT_HOST_NOTIFICATIONS(contact
)
854 #ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>
855 def ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS(self
, contactgroup
):
856 for contact
in contactgroup
:
857 self
.ENABLE_CONTACT_SVC_NOTIFICATIONS(contact
)
859 #ENABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>
860 def ENABLE_CONTACT_HOST_NOTIFICATIONS(self
, contact
):
861 contact
.host_notifications_enabled
= True
862 self
.sched
.get_and_register_status_brok(contact
)
864 #ENABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>
865 def ENABLE_CONTACT_SVC_NOTIFICATIONS(self
, contact
):
866 contact
.service_notifications_enabled
= True
867 self
.sched
.get_and_register_status_brok(contact
)
869 #ENABLE_EVENT_HANDLERS
870 def ENABLE_EVENT_HANDLERS(self
):
871 self
.conf
.enable_event_handlers
= True
872 self
.conf
.explode_global_conf()
873 self
.sched
.get_and_register_update_program_status_brok()
875 #ENABLE_FAILURE_PREDICTION
876 def ENABLE_FAILURE_PREDICTION(self
):
877 self
.conf
.enable_failure_prediction
= True
878 self
.conf
.explode_global_conf()
879 self
.sched
.get_and_register_update_program_status_brok()
881 #ENABLE_FLAP_DETECTION
882 def ENABLE_FLAP_DETECTION(self
):
883 self
.conf
.enable_flap_detection
= True
884 self
.conf
.explode_global_conf()
885 self
.sched
.get_and_register_update_program_status_brok()
887 #ENABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>
888 def ENABLE_HOSTGROUP_HOST_CHECKS(self
, hostgroup
):
889 for host
in hostgroup
:
890 self
.ENABLE_HOST_CHECK(host
)
892 #ENABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>
893 def ENABLE_HOSTGROUP_HOST_NOTIFICATIONS(self
, hostgroup
):
894 for host
in hostgroup
:
895 self
.ENABLE_HOST_NOTIFICATIONS(host
)
897 #ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>
898 def ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS(self
, hostgroup
):
899 for host
in hostgroup
:
900 self
.ENABLE_PASSIVE_HOST_CHECKS(host
)
902 #ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>
903 def ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS(self
, hostgroup
):
904 for host
in hostgroup
:
905 for service
in host
.services
:
906 self
.ENABLE_PASSIVE_SVC_CHECKS(service
)
908 #ENABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>
909 def ENABLE_HOSTGROUP_SVC_CHECKS(self
, hostgroup
):
910 for host
in hostgroup
:
911 for service
in host
.services
:
912 self
.ENABLE_SVC_CHECK(service
)
914 #ENABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>
915 def ENABLE_HOSTGROUP_SVC_NOTIFICATIONS(self
, hostgroup
):
916 for host
in hostgroup
:
917 for service
in host
.services
:
918 self
.ENABLE_SVC_NOTIFICATIONS(service
)
920 #ENABLE_HOST_AND_CHILD_NOTIFICATIONS;<host_name>
921 def ENABLE_HOST_AND_CHILD_NOTIFICATIONS(self
, host
):
924 #ENABLE_HOST_CHECK;<host_name>
925 def ENABLE_HOST_CHECK(self
, host
):
926 host
.active_checks_enabled
= True
927 self
.sched
.get_and_register_status_brok(host
)
929 #ENABLE_HOST_EVENT_HANDLER;<host_name>
930 def ENABLE_HOST_EVENT_HANDLER(self
, host
):
931 host
.enable_event_handlers
= True
932 self
.sched
.get_and_register_status_brok(host
)
934 #ENABLE_HOST_FLAP_DETECTION;<host_name>
935 def ENABLE_HOST_FLAP_DETECTION(self
, host
):
936 host
.flap_detection_enabled
= True
937 self
.sched
.get_and_register_status_brok(host
)
939 #ENABLE_HOST_FRESHNESS_CHECKS
940 def ENABLE_HOST_FRESHNESS_CHECKS(self
):
941 self
.conf
.check_host_freshness
= True
942 self
.conf
.explode_global_conf()
943 self
.sched
.get_and_register_update_program_status_brok()
945 #ENABLE_HOST_NOTIFICATIONS;<host_name>
946 def ENABLE_HOST_NOTIFICATIONS(self
, host
):
947 host
.notifications_enabled
= True
948 self
.sched
.get_and_register_status_brok(host
)
950 #ENABLE_HOST_SVC_CHECKS;<host_name>
951 def ENABLE_HOST_SVC_CHECKS(self
, host
):
952 for s
in host
.services
:
953 self
.ENABLE_SVC_CHECK(s
)
954 self
.sched
.get_and_register_status_brok(s
)
956 #ENABLE_HOST_SVC_NOTIFICATIONS;<host_name>
957 def ENABLE_HOST_SVC_NOTIFICATIONS(self
, host
):
958 for s
in host
.services
:
959 self
.ENABLE_SVC_NOTIFICATIONS(s
)
960 self
.sched
.get_and_register_status_brok(s
)
962 #ENABLE_NOTIFICATIONS
963 def ENABLE_NOTIFICATIONS(self
):
964 self
.conf
.enable_notifications
= True
965 self
.conf
.explode_global_conf()
966 self
.sched
.get_and_register_update_program_status_brok()
968 #ENABLE_PASSIVE_HOST_CHECKS;<host_name>
969 def ENABLE_PASSIVE_HOST_CHECKS(self
, host
):
970 host
.passive_checks_enabled
= True
971 self
.sched
.get_and_register_status_brok(host
)
973 #ENABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>
974 def ENABLE_PASSIVE_SVC_CHECKS(self
, service
):
975 service
.passive_checks_enabled
= True
976 self
.sched
.get_and_register_status_brok(service
)
978 #ENABLE_PERFORMANCE_DATA
979 def ENABLE_PERFORMANCE_DATA(self
):
980 self
.conf
.process_performance_data
= True
981 self
.conf
.explode_global_conf()
982 self
.sched
.get_and_register_update_program_status_brok()
984 #ENABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>
985 def ENABLE_SERVICEGROUP_HOST_CHECKS(self
, servicegroup
):
986 for service
in servicegroup
:
987 self
.ENABLE_HOST_CHECK(service
.host
)
989 #ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>
990 def ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS(self
, servicegroup
):
991 for service
in servicegroup
:
992 self
.ENABLE_HOST_NOTIFICATIONS(service
.host
)
994 #ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>
995 def ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS(self
, servicegroup
):
996 for service
in servicegroup
:
997 self
.ENABLE_PASSIVE_HOST_CHECKS(service
.host
)
999 #ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>
1000 def ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS(self
, servicegroup
):
1001 for service
in servicegroup
:
1002 self
.ENABLE_PASSIVE_SVC_CHECKS(service
)
1004 #ENABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>
1005 def ENABLE_SERVICEGROUP_SVC_CHECKS(self
, servicegroup
):
1006 for service
in servicegroup
:
1007 self
.ENABLE_SVC_CHECK(service
)
1009 #ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>
1010 def ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS(self
, servicegroup
):
1011 for service
in servicegroup
:
1012 self
.ENABLE_SVC_NOTIFICATIONS(service
)
1014 #ENABLE_SERVICE_FRESHNESS_CHECKS
1015 def ENABLE_SERVICE_FRESHNESS_CHECKS(self
):
1016 self
.conf
.check_service_freshness
= True
1017 self
.conf
.explode_global_conf()
1018 self
.sched
.get_and_register_update_program_status_brok()
1020 #ENABLE_SVC_CHECK;<host_name>;<service_description>
1021 def ENABLE_SVC_CHECK(self
, service
):
1022 service
.active_checks_enabled
= True
1023 self
.sched
.get_and_register_status_brok(service
)
1025 #ENABLE_SVC_EVENT_HANDLER;<host_name>;<service_description>
1026 def ENABLE_SVC_EVENT_HANDLER(self
, service
):
1027 service
.event_handler_enabled
= True
1028 self
.sched
.get_and_register_status_brok(service
)
1030 #ENABLE_SVC_FLAP_DETECTION;<host_name>;<service_description>
1031 def ENABLE_SVC_FLAP_DETECTION(self
, service
):
1032 service
.flap_detection_enabled
= True
1033 self
.sched
.get_and_register_status_brok(service
)
1035 #ENABLE_SVC_NOTIFICATIONS;<host_name>;<service_description>
1036 def ENABLE_SVC_NOTIFICATIONS(self
, service
):
1037 service
.notifications_enabled
= True
1038 self
.sched
.get_and_register_status_brok(service
)
1040 #PROCESS_FILE;<file_name>;<delete>
1041 def PROCESS_FILE(self
, file_name
, delete
):
1044 #TODO : say that check is PASSIVE
1045 #PROCESS_HOST_CHECK_RESULT;<host_name>;<status_code>;<plugin_output>
1046 def PROCESS_HOST_CHECK_RESULT(self
, host
, status_code
, plugin_output
):
1047 #raise a PASSIVE check only if needed
1048 if self
.conf
.log_passive_checks
:
1049 logger
.log('PASSIVE HOST CHECK: %s;%d;%s' % (host
.get_name(), status_code
, plugin_output
))
1051 cls
= host
.__class
__
1052 #If globally disable OR locally, do not launch
1053 if cls
.accept_passive_checks
and host
.passive_checks_enabled
:
1054 i
= host
.launch_check(now
, force
=True)
1055 for chk
in host
.actions
:
1058 #Now we 'transform the check into a result'
1059 #So exit_status, output and status is eaten by the host
1060 c
.exit_status
= status_code
1061 c
.get_outputs(plugin_output
, host
.max_plugins_output_length
)
1062 c
.status
= 'waitconsume'
1063 self
.sched
.nb_check_received
+= 1
1064 #Ok now this result will be reap by scheduler the next loop
1067 #PROCESS_SERVICE_CHECK_RESULT;<host_name>;<service_description>;<return_code>;<plugin_output>
1068 def PROCESS_SERVICE_CHECK_RESULT(self
, service
, return_code
, plugin_output
):
1069 #raise a PASSIVE check only if needed
1070 if self
.conf
.log_passive_checks
:
1071 logger
.log('PASSIVE SERVICE CHECK: %s;%s;%d;%s' % (service
.host
.get_name(), service
.get_name(), return_code
, plugin_output
))
1073 cls
= service
.__class
__
1074 #If globally disable OR locally, do not launch
1075 if cls
.accept_passive_checks
and service
.passive_checks_enabled
:
1076 i
= service
.launch_check(now
, force
=True)
1077 for chk
in service
.actions
:
1080 #Now we 'transform the check into a result'
1081 #So exit_status, output and status is eaten by the service
1082 c
.exit_status
= return_code
1083 c
.get_outputs(plugin_output
, service
.max_plugins_output_length
)
1084 c
.status
= 'waitconsume'
1085 self
.sched
.nb_check_received
+= 1
1086 #Ok now this result will be reap by scheduler the next loop
1089 #READ_STATE_INFORMATION
1090 def READ_STATE_INFORMATION(self
):
1093 #REMOVE_HOST_ACKNOWLEDGEMENT;<host_name>
1094 def REMOVE_HOST_ACKNOWLEDGEMENT(self
, host
):
1095 host
.unacknowledge_problem()
1097 #REMOVE_SVC_ACKNOWLEDGEMENT;<host_name>;<service_description>
1098 def REMOVE_SVC_ACKNOWLEDGEMENT(self
, service
):
1099 service
.unacknowledge_problem()
1102 def RESTART_PROGRAM(self
):
1105 #SAVE_STATE_INFORMATION
1106 def SAVE_STATE_INFORMATION(self
):
1109 #SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1110 def SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME(self
, host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1113 #SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1114 def SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME(self
, host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1117 #SCHEDULE_CONTACT_DOWNTIME;<contact_name>;<start_time>;<end_time>;<author>;<comment>
1118 def SCHEDULE_CONTACT_DOWNTIME(self
, contact
, start_time
, end_time
, author
, comment
):
1119 dt
= ContactDowntime(contact
, start_time
, end_time
, author
, comment
)
1120 contact
.add_downtime(dt
)
1122 self
.sched
.get_and_register_status_brok(contact
)
1124 #SCHEDULE_FORCED_HOST_CHECK;<host_name>;<check_time>
1125 def SCHEDULE_FORCED_HOST_CHECK(self
, host
, check_time
):
1126 host
.schedule(force
=True, force_time
=check_time
)
1127 self
.sched
.get_and_register_status_brok(host
)
1129 #SCHEDULE_FORCED_HOST_SVC_CHECKS;<host_name>;<check_time>
1130 def SCHEDULE_FORCED_HOST_SVC_CHECKS(self
, host
, check_time
):
1131 for s
in host
.services
:
1132 self
.SCHEDULE_FORCED_SVC_CHECK(s
, check_time
)
1133 self
.sched
.get_and_register_status_brok(s
)
1135 #SCHEDULE_FORCED_SVC_CHECK;<host_name>;<service_description>;<check_time>
1136 def SCHEDULE_FORCED_SVC_CHECK(self
, service
, check_time
):
1137 service
.schedule(force
=True, force_time
=check_time
)
1138 self
.sched
.get_and_register_status_brok(service
)
1140 #SCHEDULE_HOSTGROUP_HOST_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1141 def SCHEDULE_HOSTGROUP_HOST_DOWNTIME(self
, hostgroup
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1144 #SCHEDULE_HOSTGROUP_SVC_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1145 def SCHEDULE_HOSTGROUP_SVC_DOWNTIME(self
, hostgroup
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1148 #SCHEDULE_HOST_CHECK;<host_name>;<check_time>
1149 def SCHEDULE_HOST_CHECK(self
, host
, check_time
):
1150 host
.schedule(force
=False, force_time
=check_time
)
1151 self
.sched
.get_and_register_status_brok(host
)
1153 #SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1154 def SCHEDULE_HOST_DOWNTIME(self
, host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1155 dt
= Downtime(host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1156 host
.add_downtime(dt
)
1158 self
.sched
.get_and_register_status_brok(host
)
1159 if trigger_id
!= 0 and trigger_id
in self
.sched
.downtimes
:
1160 self
.sched
.downtimes
[trigger_id
].trigger_me(dt
)
1162 #SCHEDULE_HOST_SVC_CHECKS;<host_name>;<check_time>
1163 def SCHEDULE_HOST_SVC_CHECKS(self
, host
, check_time
):
1164 for s
in host
.services
:
1165 self
.SCHEDULE_SVC_CHECK(s
, check_time
)
1166 self
.sched
.get_and_register_status_brok(s
)
1168 #SCHEDULE_HOST_SVC_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1169 def SCHEDULE_HOST_SVC_DOWNTIME(self
, host
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1170 for s
in host
.services
:
1171 self
.SCHEDULE_SVC_DOWNTIME(s
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1173 #SCHEDULE_SERVICEGROUP_HOST_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1174 def SCHEDULE_SERVICEGROUP_HOST_DOWNTIME(self
, servicegroup
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1175 for h
in [s
.host
for s
in servicegroup
.get_services()]:
1176 self
.SCHEDULE_HOST_DOWNTIME(h
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1178 #SCHEDULE_SERVICEGROUP_SVC_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1179 def SCHEDULE_SERVICEGROUP_SVC_DOWNTIME(self
, servicegroup
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1180 for s
in servicegroup
.get_services():
1181 self
.SCHEDULE_SVC_DOWNTIME(s
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1183 #SCHEDULE_SVC_CHECK;<host_name>;<service_description>;<check_time>
1184 def SCHEDULE_SVC_CHECK(self
, service
, check_time
):
1185 service
.schedule(force
=False, force_time
=check_time
)
1186 self
.sched
.get_and_register_status_brok(service
)
1188 #SCHEDULE_SVC_DOWNTIME;<host_name>;<service_desription><start_time>;<end_time>;<fixed>;<trigger_id>;<duration>;<author>;<comment>
1189 def SCHEDULE_SVC_DOWNTIME(self
, service
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
):
1190 dt
= Downtime(service
, start_time
, end_time
, fixed
, trigger_id
, duration
, author
, comment
)
1191 service
.add_downtime(dt
)
1193 self
.sched
.get_and_register_status_brok(service
)
1194 if trigger_id
!= 0 and trigger_id
in self
.sched
.downtimes
:
1195 self
.sched
.downtimes
[trigger_id
].trigger_me(dt
)
1197 #SEND_CUSTOM_HOST_NOTIFICATION;<host_name>;<options>;<author>;<comment>
1198 def SEND_CUSTOM_HOST_NOTIFICATION(self
, host
, options
, author
, comment
):
1201 #SEND_CUSTOM_SVC_NOTIFICATION;<host_name>;<service_description>;<options>;<author>;<comment>
1202 def SEND_CUSTOM_SVC_NOTIFICATION(self
, service
, options
, author
, comment
):
1205 #SET_HOST_NOTIFICATION_NUMBER;<host_name>;<notification_number>
1206 def SET_HOST_NOTIFICATION_NUMBER(self
, host
, notification_number
):
1209 #SET_SVC_NOTIFICATION_NUMBER;<host_name>;<service_description>;<notification_number>
1210 def SET_SVC_NOTIFICATION_NUMBER(self
, service
, notification_number
):
1214 def SHUTDOWN_PROGRAM(self
):
1217 #START_ACCEPTING_PASSIVE_HOST_CHECKS
1218 def START_ACCEPTING_PASSIVE_HOST_CHECKS(self
):
1219 self
.conf
.accept_passive_host_checks
= True
1220 self
.conf
.explode_global_conf()
1221 self
.sched
.get_and_register_update_program_status_brok()
1223 #START_ACCEPTING_PASSIVE_SVC_CHECKS
1224 def START_ACCEPTING_PASSIVE_SVC_CHECKS(self
):
1225 self
.conf
.accept_passive_service_checks
= True
1226 self
.conf
.explode_global_conf()
1227 self
.sched
.get_and_register_update_program_status_brok()
1229 #START_EXECUTING_HOST_CHECKS
1230 def START_EXECUTING_HOST_CHECKS(self
):
1231 self
.conf
.execute_host_checks
= True
1232 self
.conf
.explode_global_conf()
1233 self
.sched
.get_and_register_update_program_status_brok()
1235 #START_EXECUTING_SVC_CHECKS
1236 def START_EXECUTING_SVC_CHECKS(self
):
1237 self
.conf
.execute_service_checks
= True
1238 self
.conf
.explode_global_conf()
1239 self
.sched
.get_and_register_update_program_status_brok()
1241 #START_OBSESSING_OVER_HOST;<host_name>
1242 def START_OBSESSING_OVER_HOST(self
, host
):
1243 host
.obsess_over_host
= True
1244 self
.sched
.get_and_register_status_brok(host
)
1246 #START_OBSESSING_OVER_HOST_CHECKS
1247 def START_OBSESSING_OVER_HOST_CHECKS(self
):
1248 self
.conf
.obsess_over_hosts
= True
1249 self
.conf
.explode_global_conf()
1251 #START_OBSESSING_OVER_SVC;<host_name>;<service_description>
1252 def START_OBSESSING_OVER_SVC(self
, service
):
1253 service
.obsess_over_service
= True
1254 self
.sched
.get_and_register_status_brok(service
)
1256 #START_OBSESSING_OVER_SVC_CHECKS
1257 def START_OBSESSING_OVER_SVC_CHECKS(self
):
1258 self
.conf
.obsess_over_services
= True
1259 self
.conf
.explode_global_conf()
1260 self
.sched
.get_and_register_update_program_status_brok()
1262 #STOP_ACCEPTING_PASSIVE_HOST_CHECKS
1263 def STOP_ACCEPTING_PASSIVE_HOST_CHECKS(self
):
1264 self
.accept_passive_host_checks
= False
1265 self
.conf
.explode_global_conf()
1266 self
.sched
.get_and_register_update_program_status_brok()
1268 #STOP_ACCEPTING_PASSIVE_SVC_CHECKS
1269 def STOP_ACCEPTING_PASSIVE_SVC_CHECKS(self
):
1270 self
.accept_passive_service_checks
= False
1271 self
.conf
.explode_global_conf()
1272 self
.sched
.get_and_register_update_program_status_brok()
1274 #STOP_EXECUTING_HOST_CHECKS
1275 def STOP_EXECUTING_HOST_CHECKS(self
):
1276 self
.conf
.execute_host_checks
= False
1277 self
.conf
.explode_global_conf()
1278 self
.sched
.get_and_register_update_program_status_brok()
1280 #STOP_EXECUTING_SVC_CHECKS
1281 def STOP_EXECUTING_SVC_CHECKS(self
):
1282 self
.conf
.execute_service_checks
= False
1283 self
.conf
.explode_global_conf()
1284 self
.sched
.get_and_register_update_program_status_brok()
1286 #STOP_OBSESSING_OVER_HOST;<host_name>
1287 def STOP_OBSESSING_OVER_HOST(self
, host
):
1288 host
.obsess_over_host
= False
1289 self
.sched
.get_and_register_status_brok(host
)
1291 #STOP_OBSESSING_OVER_HOST_CHECKS
1292 def STOP_OBSESSING_OVER_HOST_CHECKS(self
):
1293 self
.conf
.obsess_over_hosts
= False
1294 self
.conf
.explode_global_conf()
1295 self
.sched
.get_and_register_update_program_status_brok()
1297 #STOP_OBSESSING_OVER_SVC;<host_name>;<service_description>
1298 def STOP_OBSESSING_OVER_SVC(self
, service
):
1299 service
.obsess_over_service
= False
1300 self
.sched
.get_and_register_status_brok(service
)
1302 #STOP_OBSESSING_OVER_SVC_CHECKS
1303 def STOP_OBSESSING_OVER_SVC_CHECKS(self
):
1304 self
.conf
.obsess_over_services
= False
1305 self
.conf
.explode_global_conf()
1306 self
.sched
.get_and_register_update_program_status_brok()
1309 ### Now the shinken specific ones
1310 #LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>
1311 def LAUNCH_SVC_EVENT_HANDLER(self
, service
):
1312 service
.get_event_handlers(externalcmd
=True)
1315 #LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>
1316 def LAUNCH_HOST_EVENT_HANDLER(self
, host
):
1317 host
.get_event_handlers(externalcmd
=True)
1320 #ADD_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>
1321 def ADD_SIMPLE_HOST_DEPENDENCY(self
, son
, father
):
1322 if not son
.is_linked_with_host(father
):
1323 print "Doing simple link between", son
.get_name(), 'and', father
.get_name()
1324 # Add a dep link between the son and the father
1325 son
.add_host_act_dependancy(father
, ['w', 'u', 'd'], None, True)
1326 self
.sched
.get_and_register_status_brok(son
)
1327 self
.sched
.get_and_register_status_brok(father
)
1330 #ADD_SIMPLE_HOST_DEPENDENCY;<host_name>;<host_name>
1331 def DEL_HOST_DEPENDENCY(self
, son
, father
):
1332 if son
.is_linked_with_host(father
):
1333 print "removing simple link between", son
.get_name(), 'and', father
.get_name()
1334 son
.del_host_act_dependancy(father
)
1335 self
.sched
.get_and_register_status_brok(son
)
1336 self
.sched
.get_and_register_status_brok(father
)
1339 #ADD_SIMPLE_POLLER;realm_name;poller_name;address;port
1340 def ADD_SIMPLE_POLLER(self
, realm_name
, poller_name
, address
, port
):
1341 print "I need to add the poller", realm_name
, poller_name
, address
, port
1343 # First we look for the realm
1344 r
= self
.conf
.realms
.find_by_name(realm_name
)
1346 print "Sorry, the realm %s is unknown" % realm_name
1348 print "We found the realm", r
1349 # TODO : backport this in the config class?
1350 # We create the PollerLink object
1351 t
= {'poller_name' : poller_name
, 'address' : address
, 'port' : port
}
1355 p
.prepare_for_conf()
1356 parameters
= {'max_plugins_output_length' : self
.conf
.max_plugins_output_length
}
1357 p
.add_global_conf_parameters(parameters
)
1358 self
.arbiter
.conf
.pollers
[p
.id] = p
1359 self
.arbiter
.dispatcher
.elements
.append(p
)
1360 self
.arbiter
.dispatcher
.satellites
.append(p
)
1363 r
.fill_potential_pollers()
1364 print "Poller %s added" % poller_name
1365 print "Potential", r
.get_potential_satellites_by_type('poller')
1368 if __name__
== '__main__':
1370 FIFO_PATH
= '/tmp/my_fifo'
1372 if os
.path
.exists(FIFO_PATH
):
1373 os
.unlink(FIFO_PATH
)
1375 if not os
.path
.exists(FIFO_PATH
):
1377 os
.mkfifo(FIFO_PATH
, 0660)
1378 my_fifo
= open(FIFO_PATH
, 'w+')
1379 print "my_fifo:", my_fifo
1381 print open(FIFO_PATH
, 'r').readline()