Merge branch 'master' of ssh://naparuba@shinken.git.sourceforge.net/gitroot/shinken...
[shinken.git] / shinken / pollerlink.py
blob3b350520247cf984fda5a0410bd3ef044b72fd27
1 #!/usr/bin/env python
2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
6 #This file is part of Shinken.
8 #Shinken is free software: you can redistribute it and/or modify
9 #it under the terms of the GNU Affero General Public License as published by
10 #the Free Software Foundation, either version 3 of the License, or
11 #(at your option) any later version.
13 #Shinken is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #GNU Affero General Public License for more details.
18 #You should have received a copy of the GNU Affero General Public License
19 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
22 #This class is the link between Arbiter and Poller. With It, arbiter
23 #can see if a poller is alive, and can send it new configuration
25 from shinken.satellitelink import SatelliteLink, SatelliteLinks
26 from shinken.util import to_int, to_bool, to_split
27 from shinken.property import UnusedProp, BoolProp, IntegerProp, FloatProp, CharProp, StringProp, ListProp
29 class PollerLink(SatelliteLink):
30 id = 0
31 my_type = 'poller'
32 #To_send : send or not to satellite conf
33 properties={'poller_name': StringProp(
34 fill_brok=['full_status'],
35 to_send=True),
36 'address': StringProp(
37 fill_brok=['full_status']),
38 'port': IntegerProp(
39 default=7771,
40 fill_brok=['full_status']),
41 'spare': BoolProp(
42 default='0',
43 fill_brok=['full_status']),
44 'manage_sub_realms': BoolProp(
45 default='0',
46 fill_brok=['full_status']),
47 'modules': ListProp(
48 default='',
49 to_send=True),
50 'min_workers': IntegerProp(
51 default='1',
52 fill_brok=['full_status'],
53 to_send=True),
54 'max_workers': IntegerProp(
55 default='30',
56 fill_brok=['full_status'],
57 to_send=True),
58 'processes_by_worker': IntegerProp(
59 default='256',
60 fill_brok=['full_status'],
61 to_send=True),
62 'polling_interval': IntegerProp(
63 default='1',
64 fill_brok=['full_status'],
65 to_send=True),
66 'manage_arbiters': IntegerProp(
67 default='0'),
68 'poller_tags': ListProp(
69 default='',
70 to_send=True),
71 'use_timezone': StringProp(
72 default='NOTSET',
73 to_send=True),
74 'timeout': IntegerProp(
75 default='3',
76 fill_brok=['full_status']),
77 'data_timeout': IntegerProp(
78 default='120',
79 fill_brok=['full_status']),
80 'max_check_attempts': IntegerProp(
81 default='3',
82 fill_brok=['full_status']),
83 'realm' : StringProp(default=''),
86 running_properties = {'con': StringProp(
87 default=None),
88 'alive': StringProp(
89 default=False,
90 fill_brok=['full_status'],
91 to_send=True),
92 'broks': StringProp(
93 default=[]),
94 'attempt': StringProp(
95 default=0,
96 fill_brok=['full_status']), # the number of failed attempt
97 'reachable': StringProp(
98 default=False,
99 fill_brok=['full_status']), # can be network ask or not (dead or check in timeout or error)
100 'configuration_errors' : StringProp(default=[]),
102 macros = {}
104 def get_name(self):
105 return self.poller_name
108 def register_to_my_realm(self):
109 self.realm.pollers.append(self)
110 if self.poller_tags != []:
111 print "I %s manage tags : %s " % (self.get_name(), self.poller_tags)
113 class PollerLinks(SatelliteLinks):
114 name_property = "name"
115 inner_class = PollerLink