]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - misc/munin/tahoe_stats
quickstart.html: link to snapshots page, sorted with most recent first.
[tahoe-lafs/tahoe-lafs.git] / misc / munin / tahoe_stats
1 #!/usr/bin/env python
2
3 import os
4 import pickle
5 import re
6 import sys
7 import time
8
9 STAT_VALIDITY = 300 # 5min limit on reporting stats
10
11 PLUGINS = {
12     # LOAD AVERAGE
13     'tahoe_runtime_load_avg':
14         { 'statid': 'load_monitor.avg_load',
15           'category': 'stats',
16           'configheader': '\n'.join(['graph_title Tahoe Runtime Load Average',
17                                      'graph_vlabel load',
18                                      'graph_category tahoe',
19                                      'graph_info This graph shows average reactor delay',
20                                      ]),
21           'graph_config': '\n'.join(['%(name)s.label %(name)s',
22                                      '%(name)s.draw LINE1',
23                                      ]),
24           'graph_render': '\n'.join(['%(name)s.value %(value)s',
25                                      ]),
26         },
27
28     'tahoe_runtime_load_peak':
29         { 'statid': 'load_monitor.max_load',
30           'category': 'stats',
31           'configheader': '\n'.join(['graph_title Tahoe Runtime Load Peak',
32                                      'graph_vlabel load',
33                                      'graph_category tahoe',
34                                      'graph_info This graph shows peak reactor delay',
35                                      ]),
36           'graph_config': '\n'.join(['%(name)s.label %(name)s',
37                                      '%(name)s.draw LINE1',
38                                      ]),
39           'graph_render': '\n'.join(['%(name)s.value %(value)s',
40                                      ]),
41         },
42
43     # STORAGE ALLOCATION (BYTES)
44     'tahoe_storage_consumed':
45         { 'statid': 'storage_server.consumed',
46           'category': 'stats',
47           'configheader': '\n'.join(['graph_title Tahoe Storage Server Space Consumed',
48                                      'graph_vlabel bytes',
49                                      'graph_category tahoe_storage_server',
50                                      'graph_info This graph shows space consumed',
51                                      'graph_args --base 1024',
52                                      ]),
53           'graph_config': '\n'.join(['%(name)s.label %(name)s',
54                                      '%(name)s.draw LINE1',
55                                      ]),
56           'graph_render': '\n'.join(['%(name)s.value %(value)s',
57                                      ]),
58         },
59
60     'tahoe_storage_allocated':
61         { 'statid': 'storage_server.allocated',
62           'category': 'stats',
63           'configheader': '\n'.join(['graph_title Tahoe Storage Server Space Allocated',
64                                      'graph_vlabel bytes',
65                                      'graph_category tahoe_storage_server',
66                                      'graph_info This graph shows space allocated',
67                                      'graph_args --base 1024',
68                                      ]),
69           'graph_config': '\n'.join(['%(name)s.label %(name)s',
70                                      '%(name)s.draw LINE1',
71                                      ]),
72           'graph_render': '\n'.join(['%(name)s.value %(value)s',
73                                      ]),
74         },
75
76     'tahoe_storage_bytes_added':
77         { 'statid': 'storage_server.bytes_added',
78           'category': 'counters',
79           'configheader': '\n'.join(['graph_title Tahoe Storage Server Bytes Added',
80                                      'graph_vlabel bytes',
81                                      'graph_category tahoe_storage_server',
82                                      'graph_info This graph shows cummulative bytes added',
83                                      ]),
84           'graph_config': '\n'.join(['%(name)s.label %(name)s',
85                                      '%(name)s.draw LINE1',
86                                      ]),
87           'graph_render': '\n'.join(['%(name)s.value %(value)s',
88                                      ]),
89         },
90
91     'tahoe_storage_bytes_freed':
92         { 'statid': 'storage_server.bytes_freed',
93           'category': 'counters',
94           'configheader': '\n'.join(['graph_title Tahoe Storage Server Bytes Removed',
95                                      'graph_vlabel bytes',
96                                      'graph_category tahoe_storage_server',
97                                      'graph_info This graph shows cummulative bytes removed',
98                                      ]),
99           'graph_config': '\n'.join(['%(name)s.label %(name)s',
100                                      '%(name)s.draw LINE1',
101                                      ]),
102           'graph_render': '\n'.join(['%(name)s.value %(value)s',
103                                      ]),
104         },
105
106     'tahoe_storage_operations_allocate':
107         { 'statid': 'storage_server.allocate',
108           'category': 'counters',
109           'configheader': '\n'.join(['graph_title Tahoe Storage Server Allocate_Bucket Operations',
110                                      'graph_vlabel operations per second',
111                                      'graph_category tahoe_storage_server',
112                                      'graph_info This graph shows how many allocate_buckets operations occured per second. Each immutable file upload causes one such operation per server.',
113                                      ]),
114           'graph_config': '\n'.join(['%(name)s.label %(name)s',
115                                      '%(name)s.type DERIVE',
116                                      '%(name)s.min 0',
117                                      '%(name)s.draw LINE1',
118                                      ]),
119           'graph_render': '\n'.join(['%(name)s.value %(value)s',
120                                      ]),
121         },
122
123     'tahoe_storage_operations_get':
124         { 'statid': 'storage_server.get',
125           'category': 'counters',
126           'configheader': '\n'.join(['graph_title Tahoe Storage Server get_bucket Operations',
127                                      'graph_vlabel operations per second',
128                                      'graph_category tahoe_storage_server',
129                                      'graph_info This graph shows how many get_bucket operations occured per second. Each immutable file download/check causes one such operation per server.',
130                                      ]),
131           'graph_config': '\n'.join(['%(name)s.label %(name)s',
132                                      '%(name)s.type DERIVE',
133                                      '%(name)s.min 0',
134                                      '%(name)s.draw LINE1',
135                                      ]),
136           'graph_render': '\n'.join(['%(name)s.value %(value)s',
137                                      ]),
138         },
139
140     'tahoe_storage_operations_writev':
141         { 'statid': 'storage_server.writev',
142           'category': 'counters',
143           'configheader': '\n'.join(['graph_title Tahoe Storage Server writev Operations',
144                                      'graph_vlabel operations per second',
145                                      'graph_category tahoe_storage_server',
146                                      'graph_info This graph shows how many writev operations occured per second. Each mutable file / dirnode write causes one such operation per server.',
147                                      ]),
148           'graph_config': '\n'.join(['%(name)s.label %(name)s',
149                                      '%(name)s.type DERIVE',
150                                      '%(name)s.min 0',
151                                      '%(name)s.draw LINE1',
152                                      ]),
153           'graph_render': '\n'.join(['%(name)s.value %(value)s',
154                                      ]),
155         },
156
157     'tahoe_storage_operations_readv':
158         { 'statid': 'storage_server.readv',
159           'category': 'counters',
160           'configheader': '\n'.join(['graph_title Tahoe Storage Server readv Operations',
161                                      'graph_vlabel operations per second',
162                                      'graph_category tahoe_storage_server',
163                                      'graph_info This graph shows how many readv operations occured per second. Each dirnode read causes one such operation per server.',
164                                      ]),
165           'graph_config': '\n'.join(['%(name)s.label %(name)s',
166                                      '%(name)s.type DERIVE',
167                                      '%(name)s.min 0',
168                                      '%(name)s.draw LINE1',
169                                      ]),
170           'graph_render': '\n'.join(['%(name)s.value %(value)s',
171                                      ]),
172         },
173
174
175     # HELPER
176     'tahoe_helper_incoming_files':
177         { 'statid': 'chk_upload_helper.incoming_count',
178           'category': 'stats',
179           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Incoming File Count',
180                                      'graph_vlabel n files',
181                                      'graph_category tahoe_helper',
182                                      'graph_info This graph shows number of incoming files',
183                                      ]),
184           'graph_config': '\n'.join(['%(name)s.label %(name)s',
185                                      '%(name)s.draw LINE1',
186                                      ]),
187           'graph_render': '\n'.join(['%(name)s.value %(value)s',
188                                      ]),
189         },
190     'tahoe_helper_incoming_filesize':
191         { 'statid': 'chk_upload_helper.incoming_size',
192           'category': 'stats',
193           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Incoming File Size',
194                                      'graph_vlabel bytes',
195                                      'graph_category tahoe_helper',
196                                      'graph_info This graph shows total size of incoming files',
197                                      ]),
198           'graph_config': '\n'.join(['%(name)s.label %(name)s',
199                                      '%(name)s.draw LINE1',
200                                      ]),
201           'graph_render': '\n'.join(['%(name)s.value %(value)s',
202                                      ]),
203         },
204     'tahoe_helper_incoming_files_old':
205         { 'statid': 'chk_upload_helper.incoming_size_old',
206           'category': 'stats',
207           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Incoming Old Files',
208                                      'graph_vlabel bytes',
209                                      'graph_category tahoe_helper',
210                                      'graph_info This graph shows total size of old incoming files',
211                                      ]),
212           'graph_config': '\n'.join(['%(name)s.label %(name)s',
213                                      '%(name)s.draw LINE1',
214                                      ]),
215           'graph_render': '\n'.join(['%(name)s.value %(value)s',
216                                      ]),
217         },
218
219     'tahoe_helper_encoding_files':
220         { 'statid': 'chk_upload_helper.encoding_count',
221           'category': 'stats',
222           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Encoding File Count',
223                                      'graph_vlabel n files',
224                                      'graph_category tahoe_helper',
225                                      'graph_info This graph shows number of encoding files',
226                                      ]),
227           'graph_config': '\n'.join(['%(name)s.label %(name)s',
228                                      '%(name)s.draw LINE1',
229                                      ]),
230           'graph_render': '\n'.join(['%(name)s.value %(value)s',
231                                      ]),
232         },
233     'tahoe_helper_encoding_filesize':
234         { 'statid': 'chk_upload_helper.encoding_size',
235           'category': 'stats',
236           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Encoding File Size',
237                                      'graph_vlabel bytes',
238                                      'graph_category tahoe_helper',
239                                      'graph_info This graph shows total size of encoding files',
240                                      ]),
241           'graph_config': '\n'.join(['%(name)s.label %(name)s',
242                                      '%(name)s.draw LINE1',
243                                      ]),
244           'graph_render': '\n'.join(['%(name)s.value %(value)s',
245                                      ]),
246         },
247     'tahoe_helper_encoding_files_old':
248         { 'statid': 'chk_upload_helper.encoding_size_old',
249           'category': 'stats',
250           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Encoding Old Files',
251                                      'graph_vlabel bytes',
252                                      'graph_category tahoe_helper',
253                                      'graph_info This graph shows total size of old encoding files',
254                                      ]),
255           'graph_config': '\n'.join(['%(name)s.label %(name)s',
256                                      '%(name)s.draw LINE1',
257                                      ]),
258           'graph_render': '\n'.join(['%(name)s.value %(value)s',
259                                      ]),
260         },
261
262     'tahoe_helper_active_uploads':
263         { 'statid': 'chk_upload_helper.active_uploads',
264           'category': 'stats',
265           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Active Files',
266                                      'graph_vlabel n files',
267                                      'graph_category tahoe_helper',
268                                      'graph_info This graph shows number of files actively being processed by the helper',
269                                      ]),
270           'graph_config': '\n'.join(['%(name)s.label %(name)s',
271                                      '%(name)s.draw LINE1',
272                                      ]),
273           'graph_render': '\n'.join(['%(name)s.value %(value)s',
274                                      ]),
275         },
276
277     'tahoe_helper_upload_requests':
278         { 'statid': 'chk_upload_helper.upload_requests',
279           'category': 'counters',
280           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Upload Requests',
281                                      'graph_vlabel requests',
282                                      'graph_category tahoe_helper',
283                                      'graph_info This graph shows the number of upload requests arriving at the helper',
284                                      ]),
285           'graph_config': '\n'.join(['%(name)s.label %(name)s',
286                                      '%(name)s.type DERIVE',
287                                      '%(name)s.min 0',
288                                      '%(name)s.draw LINE1',
289                                      ]),
290           'graph_render': '\n'.join(['%(name)s.value %(value)s',
291                                      ]),
292         },
293     'tahoe_helper_upload_already_present':
294         { 'statid': 'chk_upload_helper.upload_already_present',
295           'category': 'counters',
296           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Uploads Already Present',
297                                      'graph_vlabel requests',
298                                      'graph_category tahoe_helper',
299                                      'graph_info This graph shows the number of uploads whose files are already present in the grid',
300                                      ]),
301           'graph_config': '\n'.join(['%(name)s.label %(name)s',
302                                      '%(name)s.type DERIVE',
303                                      '%(name)s.min 0',
304                                      '%(name)s.draw LINE1',
305                                      ]),
306           'graph_render': '\n'.join(['%(name)s.value %(value)s',
307                                      ]),
308         },
309     'tahoe_helper_upload_need_upload':
310         { 'statid': 'chk_upload_helper.upload_need_upload',
311           'category': 'counters',
312           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Uploads Needing Upload',
313                                      'graph_vlabel requests',
314                                      'graph_category tahoe_helper',
315                                      'graph_info This graph shows the number of uploads whose files are not already present in the grid',
316                                      ]),
317           'graph_config': '\n'.join(['%(name)s.label %(name)s',
318                                      '%(name)s.type DERIVE',
319                                      '%(name)s.min 0',
320                                      '%(name)s.draw LINE1',
321                                      ]),
322           'graph_render': '\n'.join(['%(name)s.value %(value)s',
323                                      ]),
324         },
325     'tahoe_helper_encoded_bytes':
326         { 'statid': 'chk_upload_helper.encoded_bytes',
327           'category': 'counters',
328           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Encoded Bytes',
329                                      'graph_vlabel bytes',
330                                      'graph_category tahoe_helper',
331                                      'graph_info This graph shows the number of bytes encoded by the helper',
332                                      ]),
333           'graph_config': '\n'.join(['%(name)s.label %(name)s',
334                                      '%(name)s.type DERIVE',
335                                      '%(name)s.min 0',
336                                      '%(name)s.draw LINE1',
337                                      ]),
338           'graph_render': '\n'.join(['%(name)s.value %(value)s',
339                                      ]),
340         },
341     'tahoe_helper_fetched_bytes':
342         { 'statid': 'chk_upload_helper.fetched_bytes',
343           'category': 'counters',
344           'configheader': '\n'.join(['graph_title Tahoe Upload Helper Fetched Bytes',
345                                      'graph_vlabel bytes',
346                                      'graph_category tahoe_helper',
347                                      'graph_info This graph shows the number of bytes fetched by the helper',
348                                      ]),
349           'graph_config': '\n'.join(['%(name)s.label %(name)s',
350                                      '%(name)s.type DERIVE',
351                                      '%(name)s.min 0',
352                                      '%(name)s.draw LINE1',
353                                      ]),
354           'graph_render': '\n'.join(['%(name)s.value %(value)s',
355                                      ]),
356         },
357
358     # WEBAPI
359     'tahoe_uploader_bytes_uploaded':
360         { 'statid': 'uploader.bytes_uploaded',
361           'category': 'counters',
362           'configheader': '\n'.join(['graph_title Tahoe Uploader Bytes Uploaded',
363                                      'graph_vlabel bytes',
364                                      'graph_category tahoe_traffic',
365                                      'graph_info This graph shows the number of bytes uploaded',
366                                      ]),
367           'graph_config': '\n'.join(['%(name)s.label %(name)s',
368                                      '%(name)s.type DERIVE',
369                                      '%(name)s.min 0',
370                                      '%(name)s.draw LINE1',
371                                      ]),
372           'graph_render': '\n'.join(['%(name)s.value %(value)s',
373                                      ]),
374         },
375     'tahoe_uploader_files_uploaded':
376         { 'statid': 'uploader.files_uploaded',
377           'category': 'counters',
378           'configheader': '\n'.join(['graph_title Tahoe Uploader Bytes Uploaded',
379                                      'graph_vlabel files',
380                                      'graph_category tahoe_traffic',
381                                      'graph_info This graph shows the number of files uploaded',
382                                      ]),
383           'graph_config': '\n'.join(['%(name)s.label %(name)s',
384                                      '%(name)s.type DERIVE',
385                                      '%(name)s.min 0',
386                                      '%(name)s.draw LINE1',
387                                      ]),
388           'graph_render': '\n'.join(['%(name)s.value %(value)s',
389                                      ]),
390         },
391     'tahoe_mutable_files_published':
392         { 'statid': 'mutable.files_published',
393           'category': 'counters',
394           'configheader': '\n'.join(['graph_title Tahoe Mutable Files Published',
395                                      'graph_vlabel files',
396                                      'graph_category tahoe_traffic',
397                                      'graph_info This graph shows the number of mutable files published',
398                                      ]),
399           'graph_config': '\n'.join(['%(name)s.label %(name)s',
400                                      '%(name)s.type DERIVE',
401                                      '%(name)s.min 0',
402                                      '%(name)s.draw LINE1',
403                                      ]),
404           'graph_render': '\n'.join(['%(name)s.value %(value)s',
405                                      ]),
406         },
407     'tahoe_mutable_files_retrieved':
408         { 'statid': 'mutable.files_retrieved',
409           'category': 'counters',
410           'configheader': '\n'.join(['graph_title Tahoe Mutable Files Retrieved',
411                                      'graph_vlabel files',
412                                      'graph_category tahoe_traffic',
413                                      'graph_info This graph shows the number of files retrieved',
414                                      ]),
415           'graph_config': '\n'.join(['%(name)s.label %(name)s',
416                                      '%(name)s.type DERIVE',
417                                      '%(name)s.min 0',
418                                      '%(name)s.draw LINE1',
419                                      ]),
420           'graph_render': '\n'.join(['%(name)s.value %(value)s',
421                                      ]),
422         },
423
424     }
425
426 def smash_name(name):
427     return re.sub('[^a-zA-Z0-9]', '_', name)
428
429 def open_stats(fname):
430     f = open(fname, 'rb')
431     stats = pickle.load(f)
432     f.close()
433     return stats
434
435 def main(argv):
436     graph_name = os.path.basename(argv[0])
437     if graph_name.endswith('.py'):
438         graph_name = graph_name[:-3]
439
440     plugin_conf = PLUGINS.get(graph_name)
441
442     for k,v in os.environ.items():
443         if k.startswith('statsfile'):
444             stats_file = v
445             break
446     else:
447         raise RuntimeError("No 'statsfile' env var found")
448
449     stats = open_stats(stats_file)
450
451     now = time.time()
452     def output_nodes(output_section, check_time):
453         for tubid, nodestats in stats.items():
454             if check_time and (now - nodestats.get('timestamp', 0)) > STAT_VALIDITY:
455                 continue
456             name = smash_name("%s_%s" % (nodestats['nickname'], tubid[:4]))
457             #value = nodestats['stats'][plugin_conf['category']].get(plugin_conf['statid'])
458             category = plugin_conf['category']
459             statid = plugin_conf['statid']
460             value = nodestats['stats'][category].get(statid)
461             if value is not None:
462                 args = { 'name': name, 'value': value }
463                 print plugin_conf[output_section] % args
464
465     if len(argv) > 1:
466         if sys.argv[1] == 'config':
467             print plugin_conf['configheader']
468             output_nodes('graph_config', False)
469             sys.exit(0)
470
471     output_nodes('graph_render', True)
472
473 if __name__ == '__main__':
474     main(sys.argv)