Merge branch 'master' of ssh://lausser,shinken@shinken.git.sourceforge.net/gitroot...
[shinken.git] / shinken / pollerlink.py
blob466f23bd23303a555b2664876ecff41877b4b47d
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
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/>.
24 #This class is the link between Arbiter and Poller. With It, arbiter
25 #can see if a poller is alive, and can send it new configuration
27 from shinken.satellitelink import SatelliteLink, SatelliteLinks
28 from shinken.property import BoolProp, IntegerProp, StringProp, ListProp
30 class PollerLink(SatelliteLink):
31 id = 0
32 my_type = 'poller'
33 #To_send : send or not to satellite conf
34 properties = {
35 'poller_name': StringProp(fill_brok=['full_status'], to_send=True),
36 'address': StringProp(fill_brok=['full_status']),
37 'port': IntegerProp(default=7771, fill_brok=['full_status']),
38 'spare': BoolProp(default='0', fill_brok=['full_status']),
39 'passive' : BoolProp(default='0', fill_brok=['full_status'], to_send=True),
40 'manage_sub_realms': BoolProp(default='0', fill_brok=['full_status']),
41 'modules': ListProp(default='', to_send=True),
42 'min_workers': IntegerProp(default='1', fill_brok=['full_status'], to_send=True),
43 'max_workers': IntegerProp(default='30', fill_brok=['full_status'], to_send=True),
44 'processes_by_worker': IntegerProp(default='256', fill_brok=['full_status'], to_send=True),
45 'polling_interval': IntegerProp(default='1', fill_brok=['full_status'], to_send=True),
46 'manage_arbiters': IntegerProp(default='0'),
47 'poller_tags': ListProp(default='None', to_send=True),
48 'use_timezone': StringProp(default='NOTSET', to_send=True),
49 'timeout': IntegerProp(default='3', fill_brok=['full_status']),
50 'data_timeout': IntegerProp(default='120', fill_brok=['full_status']),
51 'max_check_attempts': IntegerProp(default='3', fill_brok=['full_status']),
52 'realm' : StringProp(default=''),
55 running_properties = {
56 'con': StringProp(default=None),
57 'alive': StringProp(default=True, fill_brok=['full_status'], to_send=True),
58 'broks': StringProp(default=[]),
59 'attempt': StringProp(default=0, fill_brok=['full_status']), # the number of failed attempt
60 'reachable': StringProp(default=False, fill_brok=['full_status']), # can be network ask or not (dead or check in timeout or error)
61 'configuration_errors': StringProp(default=[]),
63 macros = {}
65 def get_name(self):
66 return self.poller_name
69 def register_to_my_realm(self):
70 self.realm.pollers.append(self)
71 if self.poller_tags != []:
72 print "I %s manage tags : %s " % (self.get_name(), self.poller_tags)
74 class PollerLinks(SatelliteLinks):
75 name_property = "poller_name"
76 inner_class = PollerLink