1
2
3
4
5
6
7
8
9
10
11
12 __doc__= """RRDDaemon
13
14 Common performance monitoring daemon code for performance daemons.
15 """
16
17 import socket
18
19 import Globals
20 from Products.ZenEvents import Event
21
22 from twisted.python import failure
23
24 from Products.ZenHub.PBDaemon import FakeRemote, PBDaemon
25 from Products.ZenRRD.Thresholds import Thresholds
26 from Products.ZenUtils.Utils import unused
27
28
29 BAD_SEVERITY=Event.Warning
30
31 BASE_URL = 'http://localhost:8080/zport/dmd'
32 DEFAULT_URL = BASE_URL + '/Monitors/Performance/localhost'
33
34
35 COMMON_EVENT_INFO = {
36 'manager': socket.getfqdn(),
37 }
38
39
41 """
42 Holds the code common to performance gathering daemons.
43 """
44
45 properties = ('configCycleInterval',)
46 configCycleInterval = 20
47 rrd = None
48 shutdown = False
49 thresholds = None
50
52 """
53 Initializer
54
55 @param name: name of the daemon
56 @type name: string
57 @param noopts: process command-line arguments?
58 @type noopts: boolean
59 """
60 self.events = []
61 PBDaemon.__init__(self, noopts, name=name)
62 self.thresholds = Thresholds()
63
64
66 """
67 Determine which devices we shouldn't expect to hear back from.
68
69 @return: list of devices
70 @rtype: list
71 """
72 return self.eventService().callRemote('getDevicePingIssues')
73
74
76 """
77 Set zProperties provided from zenhub.
78
79 @param items: list of zProperties to obtain
80 @type items: list
81 """
82 self.log.debug("Async update of collection properties")
83 self.setPropertyItems(items)
84
85
87 """
88 Callable from zenhub.
89
90 @param devices: list of devices (unused)
91 @type devices: list
92 """
93 unused(devices)
94 self.log.debug("Async update of device list")
95
96
98 """
99 Set zProperties
100
101 @param items: list of zProperties
102 @type items: list
103 """
104 table = dict(items)
105 for name in self.properties:
106 value = table.get(name, None)
107 if value is not None:
108 if getattr(self, name) != value:
109 self.log.debug('Updated %s config to %s' % (name, value))
110 setattr(self, name, value)
111
112
114 """
115 "Send the right event class for threshhold events"
116
117 @param kw: keyword arguments describing an event
118 @type kw: dictionary of keyword arguments
119 """
120 self.sendEvent({}, **kw)
121
122
124 """
125 Command-line options to add
126 """
127 PBDaemon.buildOptions(self)
128 self.parser.add_option('-d', '--device',
129 dest='device',
130 default='',
131 help="Specify a device ID to monitor")
132
133
151
152
154 """
155 Log an error, including any traceback data for a failure Exception
156 Stop if we got the --cycle command-line option.
157
158 @param error: the error message
159 @type error: string
160 """
161 self.logError('Error', error)
162 if not self.options.cycle:
163 self.stop()
164
165
167 """
168 Twisted callback to receive fatal messages.
169
170 @param why: the error message
171 @type why: string
172 """
173 self.error(why)
174 self.stop()
175
176
185