1
2
3
4
5
6
7
8
9
10
11
12
13
14 import Globals
15
16 from twisted.internet import reactor
17 from twisted.cred import credentials
18 from twisted.spread import pb
19
20 from Products.ZenEvents.Event import Event
21 from zenhub import PB_PORT
22
23 evt = Event()
24 evt.device = 'zenoss03'
25 evt.summary = 'sdfs pb event class'
26 evt.severity = 5
27 evt.eventClass = '/'
28
29
31
34
36 factory = pb.PBClientFactory()
37 reactor.connectTCP("localhost", PB_PORT, factory)
38 d = factory.login(credentials.UsernamePassword("admin", "zenoss"),
39 client=self)
40 d.addCallback(self.connected)
41 d.addErrback(self.bad)
42 reactor.run()
43
44
46 print "got perspective ref:", perspective
47 d = perspective.callRemote('getService', "RRDService", 'localhost', self)
48 d.addCallback(self.sendValue)
49 d.addErrback(self.bad)
50
51
53 self.svc = svc
54 print "Sending value"
55 d = self.svc.callRemote('writeRRD', 'localhost', None, None, 'MailTx_totalTime', self.value)
56 d.addBoth(self.shutdown)
57
58
60 print unused
61 reactor.stop()
62
63
64 - def bad(self, reason):
65 print reason
66 print 'error: '+str(reason.value)
67
68
71
72
76
77 if __name__ == '__main__':
78 import sys
79 try:
80 value = float(sys.argv[1])
81 except:
82 print 'Unable to use value', sys.argv
83 value = 20.
84 rc = RRDClient(value)
85 rc.run()
86