@@ 144-172 (lines=29) @@ | ||
141 | self.calc = Differential() |
|
142 | ||
143 | ||
144 | def poll(self): |
|
145 | """Query Redis for metrics. |
|
146 | ||
147 | :rtype: ResultSet |
|
148 | """ |
|
149 | result = plumd.Result("Redis") |
|
150 | ||
151 | stats = self.get_metrics() |
|
152 | ts = time.time() |
|
153 | name = self.name |
|
154 | ||
155 | # record gauges |
|
156 | for stat in self.gauges: |
|
157 | if stat in stats: |
|
158 | mname = "{0}.{1}".format(name, stat) |
|
159 | result.add(plumd.Float(mname, stats[stat])) |
|
160 | ||
161 | # record rates |
|
162 | for stat in self.rates: |
|
163 | if stat in stats: |
|
164 | mname = "{0}.{1}".format(name, stat) |
|
165 | mval = self.calc.per_second(mname, float(stats[stat]), ts) |
|
166 | result.add(plumd.Float(mname, mval)) |
|
167 | ||
168 | # replication |
|
169 | if "slave0" in stats: |
|
170 | self.record_slave(stats, result) |
|
171 | ||
172 | return plumd.ResultSet([result]) |
|
173 | ||
174 | ||
175 | def record_slave(self, stats, result): |
@@ 125-149 (lines=25) @@ | ||
122 | self.calc = Differential() |
|
123 | ||
124 | ||
125 | def poll(self): |
|
126 | """Query memcache for stats. |
|
127 | ||
128 | :rtype: ResultSet |
|
129 | """ |
|
130 | result = plumd.Result("memcache") |
|
131 | ||
132 | name = self.name |
|
133 | stats = self.get_stats() |
|
134 | ts = time.time() |
|
135 | ||
136 | # record gauges |
|
137 | for stat in self.gauges: |
|
138 | if stat in stats: |
|
139 | mname = "{0}.{1}".format(name, stat) |
|
140 | result.add(plumd.Float(mname, stats[stat])) |
|
141 | ||
142 | # record rates |
|
143 | for stat in self.rates: |
|
144 | if stat in stats: |
|
145 | mname = "{0}.{1}".format(name, stat) |
|
146 | mval = self.calc.per_second(mname, float(stats[stat]), ts) |
|
147 | result.add(plumd.Float(mname, mval)) |
|
148 | ||
149 | return plumd.ResultSet([result]) |
|
150 | ||
151 | ||
152 | def get_stats(self): |