Index: trunk/pybal/pybal/monitors/idleconnection.py |
— | — | @@ -56,6 +56,8 @@ |
57 | 57 | # Immediately set status to down |
58 | 58 | self._resultDown(reason.getErrorMessage()) |
59 | 59 | |
| 60 | + self.report("Connection failed.") |
| 61 | + |
60 | 62 | # Slowly reconnect |
61 | 63 | self.retry(connector) |
62 | 64 | |
— | — | @@ -70,6 +72,8 @@ |
71 | 73 | # Connection lost in a non clean way. Immediately set status to down |
72 | 74 | self._resultDown(reason.getErrorMessage()) |
73 | 75 | |
| 76 | + self.report("Connection lost.") |
| 77 | + |
74 | 78 | # Slowly reconnect |
75 | 79 | self.retry(connector) |
76 | 80 | |
— | — | @@ -81,6 +85,8 @@ |
82 | 86 | |
83 | 87 | # Reset reconnection delay |
84 | 88 | self.resetDelay() |
| 89 | + |
| 90 | + self.report("Connection established.") |
85 | 91 | |
86 | 92 | def buildProtocol(self, addr): |
87 | 93 | """ |
Index: trunk/pybal/pybal/monitors/__init__.py |
— | — | @@ -7,4 +7,4 @@ |
8 | 8 | $Id$ |
9 | 9 | """ |
10 | 10 | |
11 | | -__all__ = [ 'proxyfetch', 'idleconnection', 'runcommand' ] |
\ No newline at end of file |
| 11 | +__all__ = [ 'proxyfetch', 'idleconnection', 'runcommand', 'vipping' ] |
\ No newline at end of file |
Index: trunk/pybal/pybal/monitors/__skeleton__.py |
— | — | @@ -0,0 +1,38 @@ |
| 2 | +""" |
| 3 | +__skeleton__.py |
| 4 | +Copyright (C) 2006-2008 by Mark Bergsma <mark@nedworks.org> |
| 5 | + |
| 6 | +Copy and modify this file to write a new PyBal monitor. |
| 7 | +It contains the minimum imports and base methods that need |
| 8 | +to be implemented. |
| 9 | + |
| 10 | +$Id$ |
| 11 | +""" |
| 12 | + |
| 13 | +from pybal import monitor |
| 14 | + |
| 15 | +from twisted.internet import reactor |
| 16 | + |
| 17 | +class SkeletonMonitoringProtocol(monitor.MonitoringProtocol): |
| 18 | + """ |
| 19 | + Description. |
| 20 | + """ |
| 21 | + |
| 22 | + __name__ = 'Skeleton' |
| 23 | + |
| 24 | + def __init__(self, coordinator, server, configuration): |
| 25 | + """Constructor""" |
| 26 | + |
| 27 | + # Call ancestor constructor |
| 28 | + super(SkeletonMonitoringProtocol, self).__init__(coordinator, server, configuration) |
| 29 | + |
| 30 | + # Install cleanup handler |
| 31 | + reactor.addSystemEventTrigger('before', 'shutdown', self.stop) |
| 32 | + |
| 33 | + def run(self): |
| 34 | + """Start the monitoring""" |
| 35 | + pass |
| 36 | + |
| 37 | + def stop(self): |
| 38 | + """Stop the monitoring""" |
| 39 | + pass |
Index: trunk/pybal/pybal/pybal.py |
— | — | @@ -210,7 +210,18 @@ |
211 | 211 | # Hand over enabled servers to LVSService |
212 | 212 | self.lvsservice.assignServers( |
213 | 213 | set([server for server in self.servers.itervalues() if server.pooled])) |
| 214 | + |
| 215 | + def refreshModifiedServers(self): |
| 216 | + """ |
| 217 | + Calculates the status of every server that existed before the config change. |
| 218 | + """ |
214 | 219 | |
| 220 | + for server in self.servers.itervalues(): |
| 221 | + if not server.modified: continue |
| 222 | + |
| 223 | + server.up = server.calcStatus() |
| 224 | + server.pooled = server.enabled and server.up |
| 225 | + |
215 | 226 | def resultDown(self, monitor, reason=None): |
216 | 227 | """ |
217 | 228 | Accepts a 'down' notification status result from a single monitoring instance |
— | — | @@ -343,6 +354,9 @@ |
344 | 355 | server.destroy() |
345 | 356 | del self.servers[host] |
346 | 357 | |
| 358 | + # Calculate up status for previously existing, modified servers |
| 359 | + self.refreshModifiedServers() |
| 360 | + |
347 | 361 | # Assign the updated list of enabled servers to the LVSService instance |
348 | 362 | self.assignServers() |
349 | 363 | |