Package ZenHub :: Module pbClient3
[hide private]
[frames] | no frames]

Source Code for Module ZenHub.pbClient3

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13   
14  #! /usr/bin/python 
15   
16  from twisted.spread import pb 
17  from twisted.internet import reactor 
18  from twisted.cred import credentials 
19  from socket import getfqdn 
20   
21  import Globals 
22  from Products.ZenUtils.Driver import drive 
23  from Products.ZenEvents.Event import Event 
24   
25  from zenhub import PB_PORT 
26   
27 -class Listener(pb.Referenceable):
28
29 - def remote_beat(self, ts):
30 import time 31 print time.time() - ts
32
33 -def error(reason):
34 reason.printTraceback() 35 reactor.stop()
36
37 -def main():
38 def go(driver): 39 factory = pb.PBClientFactory() 40 reactor.connectTCP("localhost", PB_PORT, factory) 41 42 yield factory.login(credentials.UsernamePassword("zenoss", "zenoss")) 43 perspective = driver.next() 44 45 yield perspective.callRemote('getService', 'Beat', listener=Listener()) 46 service = driver.next()
47 48 drive(go).addErrback(error) 49 reactor.run() 50 51 if __name__ == '__main__': 52 main() 53