@@ 119-149 (lines=31) @@ | ||
116 | 'retry_cnt': 3 # retry connection n times |
|
117 | } |
|
118 | ||
119 | def __init__(self, log, config): |
|
120 | """Plugin to record redis metrics. |
|
121 | ||
122 | :param log: A logger |
|
123 | :type log: logging.RootLogger |
|
124 | :param config: a plumd.config.Conf configuration helper instance. |
|
125 | :type config: plumd.config.Conf |
|
126 | """ |
|
127 | super(Redis, self).__init__(log, config) |
|
128 | self.config.defaults(Redis.defaults) |
|
129 | ||
130 | # metrics to record |
|
131 | self.gauges = self.config.get('gauges') |
|
132 | self.rates = self.config.get('rates') |
|
133 | ||
134 | # Redis connection - either unix socket or tcp |
|
135 | spath = self.config.get('socket') |
|
136 | if spath is None: |
|
137 | host = self.config.get('host') |
|
138 | port = self.config.get('port') |
|
139 | self.addr = (host, port) |
|
140 | self.sfamily = socket.AF_INET |
|
141 | else: |
|
142 | self.addr = spath |
|
143 | self.sfamily = socket.AF_UNIX |
|
144 | ||
145 | self.socket = None |
|
146 | self.timeout = config.get('timeout') |
|
147 | self.retry_time = config.get('retry_time') |
|
148 | self.retry_cnt = config.get('retry_cnt') |
|
149 | self.calc = Differential() |
|
150 | ||
151 | ||
152 | def poll(self): |
@@ 80-108 (lines=29) @@ | ||
77 | 'timeout': 10 # connection timeouts |
|
78 | } |
|
79 | ||
80 | def __init__(self, log, config): |
|
81 | """Plugin to record memcache stats. |
|
82 | ||
83 | :param log: A logger |
|
84 | :type log: logging.RootLogger |
|
85 | :param config: a plumd.config.Conf configuration helper instance. |
|
86 | :type config: plumd.config.Conf |
|
87 | """ |
|
88 | super(Memcache, self).__init__(log, config) |
|
89 | self.config.defaults(Memcache.defaults) |
|
90 | ||
91 | # metrics to record |
|
92 | self.gauges = self.config.get('gauges') |
|
93 | self.rates = self.config.get('rates') |
|
94 | ||
95 | # memcached connection - either unix socket or tcp |
|
96 | spath = self.config.get('socket') |
|
97 | if spath is None: |
|
98 | host = self.config.get('host') |
|
99 | port = self.config.get('port') |
|
100 | self.addr = (host, port) |
|
101 | self.sfamily = socket.AF_INET |
|
102 | else: |
|
103 | self.addr = spath |
|
104 | self.sfamily = socket.AF_UNIX |
|
105 | ||
106 | self.socket = None |
|
107 | self.timeout = config.get('timeout') |
|
108 | self.calc = Differential() |
|
109 | ||
110 | ||
111 | def poll(self): |