1 #!/usr/bin/env python2.6
2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
6 #This file is part of Shinken.
8 #Shinken is free software: you can redistribute it and/or modify
9 #it under the terms of the GNU Affero General Public License as published by
10 #the Free Software Foundation, either version 3 of the License, or
11 #(at your option) any later version.
13 #Shinken is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #GNU Affero General Public License for more details.
18 #You should have received a copy of the GNU Affero General Public License
19 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
22 # This file is used to test acknowledge of problems
27 from shinken_test
import *
29 class TestConfig(ShinkenTest
):
32 self
.setup_with_file('etc/nagios_on_demand_event_handlers.cfg')
35 def test_on_demand_eh(self
):
38 # critical notification
39 # run loop -> another notification
41 host
= self
.sched
.hosts
.find_by_name("test_host_0")
42 host
.checks_in_progress
= []
43 host
.act_depend_of
= [] # ignore the router
44 svc
= self
.sched
.services
.find_srv_by_name_and_hostname("test_host_0", "test_ok_0")
45 svc
.checks_in_progress
= []
46 svc
.act_depend_of
= [] # no hostchecks on critical checkresults
47 #--------------------------------------------------------------
48 # initialize host/service state
49 #--------------------------------------------------------------
50 self
.assert_(svc
.event_handler_enabled
== False)
52 self
.scheduler_loop(5, [[svc
, 2, 'CRITICAL']])
53 # We should NOT see any event hnalder here :)
54 self
.assert_(not self
.any_log_match('SERVICE EVENT HANDLER'))
55 print "MY Actions", self
.sched
.actions
57 # And now we ask for a launch in manual
59 cmd
= "[%lu] LAUNCH_SVC_EVENT_HANDLER;test_host_0;test_ok_0" % now
60 self
.sched
.run_external_command(cmd
)
61 self
.sched
.get_new_actions()
63 self
.assert_(self
.any_log_match('SERVICE EVENT HANDLER'))
68 if __name__
== '__main__':