Skip to content

Commit f036027

Browse files
committed
Couple improvements imported from monitor-core
1 parent 5049eda commit f036027

1 file changed

Lines changed: 42 additions & 6 deletions

File tree

memcached/python_modules/memcached.py

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ def shutdown(self):
5252
self.shuttingdown = True
5353
if not self.running:
5454
return
55-
self.join()
55+
try:
56+
self.join()
57+
except:
58+
pass
5659

5760
def run(self):
5861
self.running = True
@@ -115,6 +118,9 @@ def metric_of(self, name):
115118
_Lock.acquire()
116119
val = self.metric[name]
117120
_Lock.release()
121+
# Value should never be negative. If it is counters wrapper due to e.g. memcached restart
122+
if val < 0:
123+
val = 0
118124
return val
119125

120126
def metric_init(params):
@@ -209,16 +215,34 @@ def metric_init(params):
209215
"description": "Number of open connections",
210216
}))
211217
descriptors.append(create_desc(Desc_Skel, {
212-
"name" : mp+"_evictions",
218+
"name" : mp+"_decr_hits",
213219
"units" : "items",
214-
"slope" : "both",
215-
"description": "Number of valid items removed from cache to free memory for new items",
220+
"slope" : "positive",
221+
"description": "Number of keys that have been decremented and found present ",
222+
}))
223+
descriptors.append(create_desc(Desc_Skel, {
224+
"name" : mp+"_decr_misses",
225+
"units" : "items",
226+
"slope" : "positive",
227+
"description": "Number of items that have been decremented and not found",
216228
}))
217229
descriptors.append(create_desc(Desc_Skel, {
218-
"name" : mp+"_evictions_rate",
230+
"name" : mp+"_delete_hits",
231+
"units" : "items",
232+
"slope" : "positive",
233+
"description": "Number of keys that have been deleted and found present ",
234+
}))
235+
descriptors.append(create_desc(Desc_Skel, {
236+
"name" : mp+"_delete_misses",
237+
"units" : "items",
238+
"slope" : "positive",
239+
"description": "Number of items that have been deleted and not found",
240+
}))
241+
descriptors.append(create_desc(Desc_Skel, {
242+
"name" : mp+"_evictions",
219243
"units" : "items",
220244
"slope" : "both",
221-
"description": "Evictions per second",
245+
"description": "Number of valid items removed from cache to free memory for new items",
222246
}))
223247
descriptors.append(create_desc(Desc_Skel, {
224248
"name" : mp+"_get_hits",
@@ -244,6 +268,18 @@ def metric_init(params):
244268
"slope" : "both",
245269
"description": "Misses per second",
246270
}))
271+
descriptors.append(create_desc(Desc_Skel, {
272+
"name" : mp+"_incr_hits",
273+
"units" : "items",
274+
"slope" : "positive",
275+
"description": "Number of keys that have been incremented and found present ",
276+
}))
277+
descriptors.append(create_desc(Desc_Skel, {
278+
"name" : mp+"_incr_misses",
279+
"units" : "items",
280+
"slope" : "positive",
281+
"description": "Number of items that have been incremented and not found",
282+
}))
247283
descriptors.append(create_desc(Desc_Skel, {
248284
"name" : mp+"_cmd_get_rate",
249285
"units" : "commands",

0 commit comments

Comments
 (0)