Last active
December 16, 2015 04:09
-
-
Save dotnwat/5375275 to your computer and use it in GitHub Desktop.
wip parser for 'ceph pg dump' output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import argparse | |
class PGDumpParser(object): | |
_OSDS = r'\[(?P<up>.+)\].*\[(?P<acting>.+)\]' | |
_PGSTAT = r'(?P<pool>\d+)\.(?P<pg>\d+)' | |
_PGINFO = r'^%s.*%s.*$' % (_PGSTAT, _OSDS) | |
_PGINFO_RE = re.compile(_PGINFO) | |
@staticmethod | |
def _split_ints(l): | |
return map(lambda d: int(d), l.split(',')) | |
@staticmethod | |
def pg_info(line): | |
m = PGDumpParser._PGINFO_RE.match(line) | |
if not m: | |
return m | |
g = m.groupdict() | |
up = PGDumpParser._split_ints(g['up']) | |
acting = PGDumpParser._split_ints(g['acting']) | |
assert(len(up) == len(acting)) | |
return int(g['pool']), int(g['pg']), up, acting | |
class PGInfo(object): | |
def __init__(self, fn): | |
self._fn = fn | |
self._osds = set() | |
self._load_file() | |
@property | |
def osds(self): | |
return self._osds | |
def _save_data(self, data): | |
pool, pg, up, acting = data | |
self._osds |= set(up) | |
print pool, pg, up | |
def _load_file(self): | |
with open(self._fn, 'r') as f: | |
for line in f.readlines(): | |
d = PGDumpParser.pg_info(line) | |
if d: | |
self._save_data(d) | |
pass | |
pass | |
pass | |
pass | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description='Ceph PG Visualizer') | |
parser.add_argument('-f', '--file') | |
args = parser.parse_args() | |
info = PGInfo(args.file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 8 [0, 2, 1] | |
3 9 [0, 2, 1] | |
3 4 [1, 2, 0] | |
2 5 [1, 2] | |
1 6 [1, 2] | |
0 7 [1, 2] | |
3 5 [2, 0, 1] | |
2 4 [2, 1] | |
1 7 [2, 0] | |
0 6 [2, 1] | |
3 6 [2, 1, 0] | |
2 7 [2, 1] | |
1 4 [0, 1] | |
0 5 [0, 1] | |
3 7 [0, 2, 1] | |
2 6 [2, 0] | |
1 5 [2, 1] | |
0 4 [1, 0] | |
3 0 [0, 1, 2] | |
2 1 [0, 1] | |
1 2 [0, 1] | |
0 3 [0, 1] | |
3 1 [1, 0, 2] | |
2 0 [1, 0] | |
1 3 [1, 0] | |
0 2 [1, 0] | |
3 2 [0, 1, 2] | |
2 3 [0, 1] | |
1 0 [0, 2] | |
0 1 [0, 2] | |
3 3 [2, 1, 0] | |
2 2 [1, 0] | |
1 1 [1, 0] | |
0 0 [0, 2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dumped all in format plain | |
version 139 | |
stamp 2013-04-12 12:56:27.749580 | |
last_osdmap_epoch 15 | |
last_pg_scan 12 | |
full_ratio 0.95 | |
nearfull_ratio 0.85 | |
pg_stat objects mip degr unf bytes log disklog state state_stamp v reported up acting last_scrub scrub_stamp last_deep_scrub deep_scrub_stamp | |
3.8 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:23.963100 0'0 12'17 [0,2,1] [0,2,1] 0'0 2013-04-12 12:36:23.963066 0'0 2013-04-12 12:36:23.963066 | |
3.9 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:28.963855 0'0 12'17 [0,2,1] [0,2,1] 0'0 2013-04-12 12:36:28.963815 0'0 2013-04-12 12:36:28.963815 | |
3.4 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:22.789040 0'0 12'17 [1,2,0] [1,2,0] 0'0 2013-04-12 12:36:08.804976 0'0 2013-04-12 12:36:08.804976 | |
2.5 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:44.239834 0'0 8'19 [1,2] [1,2] 0'0 2013-04-12 11:45:44.239786 0'0 2013-04-12 11:45:44.239786 | |
1.6 1 0 0 0 230 0 0 active+clean 2013-04-12 11:45:28.402122 9'1 8'22 [1,2] [1,2] 9'1 2013-04-12 11:45:21.313575 9'1 2013-04-12 11:45:21.313575 | |
0.7 1 0 0 0 2064 0 0 active+clean 2013-04-12 11:45:28.603486 11'2 8'24 [1,2] [1,2] 0'0 2013-04-12 11:45:28.603448 0'0 2013-04-12 11:45:28.603448 | |
3.5 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:22.788096 0'0 12'17 [2,0,1] [2,0,1] 0'0 2013-04-12 12:36:08.446015 0'0 2013-04-12 12:36:08.446015 | |
2.4 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:38.885325 0'0 10'12 [2,1] [2,1] 0'0 2013-04-12 11:45:38.885275 0'0 2013-04-12 11:45:38.885275 | |
1.7 5 0 0 0 1532 0 0 active+clean 2013-04-12 11:45:36.885958 9'5 10'18 [2,0] [2,0] 9'5 2013-04-12 11:45:36.885921 9'5 2013-04-12 11:45:36.885921 | |
0.6 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:28.881997 0'0 10'12 [2,1] [2,1] 0'0 2013-04-12 11:45:28.881970 0'0 2013-04-12 11:45:28.881970 | |
3.6 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:22.788330 0'0 12'17 [2,1,0] [2,1,0] 0'0 2013-04-12 12:36:09.446023 0'0 2013-04-12 12:36:09.446023 | |
2.7 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:40.885623 0'0 10'12 [2,1] [2,1] 0'0 2013-04-12 11:45:40.885578 0'0 2013-04-12 11:45:40.885578 | |
1.4 5 0 0 0 1896 0 0 active+clean 2013-04-12 11:45:41.441496 9'6 5'29 [0,1] [0,1] 9'6 2013-04-12 11:45:41.441451 9'6 2013-04-12 11:45:41.441451 | |
0.5 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:29.437638 0'0 5'23 [0,1] [0,1] 0'0 2013-04-12 11:45:29.437604 0'0 2013-04-12 11:45:29.437604 | |
3.7 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:22.789914 0'0 12'17 [0,2,1] [0,2,1] 0'0 2013-04-12 12:36:15.961401 0'0 2013-04-12 12:36:15.961401 | |
2.6 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:39.885410 0'0 10'12 [2,0] [2,0] 0'0 2013-04-12 11:45:39.885377 0'0 2013-04-12 11:45:39.885377 | |
1.5 3 0 0 0 506 0 0 active+clean 2013-04-12 11:45:30.883895 9'3 10'16 [2,1] [2,1] 9'3 2013-04-12 11:45:30.883851 9'3 2013-04-12 11:45:30.883851 | |
0.4 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:25.378094 0'0 8'14 [1,0] [1,0] 0'0 2013-04-12 11:45:25.378058 0'0 2013-04-12 11:45:25.378058 | |
3.0 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:22.790098 0'0 12'17 [0,1,2] [0,1,2] 0'0 2013-04-12 12:36:09.960831 0'0 2013-04-12 12:36:09.960831 | |
2.1 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:45.441143 0'0 5'23 [0,1] [0,1] 0'0 2013-04-12 11:45:45.441095 0'0 2013-04-12 11:45:45.441095 | |
1.2 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:35.439103 0'0 5'23 [0,1] [0,1] 0'0 2013-04-12 11:45:35.439059 0'0 2013-04-12 11:45:35.439059 | |
0.3 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:26.436777 0'0 5'23 [0,1] [0,1] 0'0 2013-04-12 11:45:26.436736 0'0 2013-04-12 11:45:26.436736 | |
3.1 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:22.788950 0'0 12'17 [1,0,2] [1,0,2] 0'0 2013-04-12 12:36:06.805004 0'0 2013-04-12 12:36:06.805004 | |
2.0 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:37.238527 0'0 8'14 [1,0] [1,0] 0'0 2013-04-12 11:45:37.238489 0'0 2013-04-12 11:45:37.238489 | |
1.3 3 0 0 0 4434 0 0 active+clean 2013-04-12 11:45:30.237452 9'3 8'20 [1,0] [1,0] 9'3 2013-04-12 11:45:30.237406 9'3 2013-04-12 11:45:30.237406 | |
0.2 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:23.235292 0'0 8'14 [1,0] [1,0] 0'0 2013-04-12 11:45:23.235255 0'0 2013-04-12 11:45:23.235255 | |
3.2 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:22.790167 0'0 12'17 [0,1,2] [0,1,2] 0'0 2013-04-12 12:36:11.961203 0'0 2013-04-12 12:36:11.961203 | |
2.3 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:49.441409 0'0 5'23 [0,1] [0,1] 0'0 2013-04-12 11:45:49.441374 0'0 2013-04-12 11:45:49.441374 | |
1.0 4 0 0 0 920 0 0 active+clean 2013-04-12 11:45:34.440227 9'4 5'36 [0,2] [0,2] 9'4 2013-04-12 11:45:34.440189 9'4 2013-04-12 11:45:34.440189 | |
0.1 1 0 0 0 576 0 0 active+clean 2013-04-12 11:45:24.323000 11'6 5'35 [0,2] [0,2] 0'0 2013-04-12 11:45:22.435926 0'0 2013-04-12 11:45:22.435926 | |
3.3 0 0 0 0 0 0 0 active+clean 2013-04-12 12:36:22.789856 0'0 12'17 [2,1,0] [2,1,0] 0'0 2013-04-12 12:36:05.614794 0'0 2013-04-12 12:36:05.614794 | |
2.2 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:38.238520 0'0 8'14 [1,0] [1,0] 0'0 2013-04-12 11:45:38.238488 0'0 2013-04-12 11:45:38.238488 | |
1.1 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:29.306275 0'0 8'14 [1,0] [1,0] 0'0 2013-04-12 11:45:29.306224 0'0 2013-04-12 11:45:29.306224 | |
0.0 0 0 0 0 0 0 0 active+clean 2013-04-12 11:45:24.651259 0'0 5'28 [0,2] [0,2] 0'0 2013-04-12 11:45:21.434650 0'0 2013-04-12 11:45:21.434650 | |
pool 0 2 0 0 0 2640 0 0 | |
pool 1 21 0 0 0 9518 0 0 | |
pool 2 0 0 0 0 0 0 0 | |
pool 3 0 0 0 0 0 0 0 | |
sum 23 0 0 0 12158 0 0 | |
osdstat kbused kbavail kb hb in hb out | |
0 45646716 398908012 468345368 [1,2] [] | |
1 45646944 398907784 468345368 [0,2] [] | |
2 45646932 398907796 468345368 [0,1] [] | |
sum 136940592 1196723592 1405036104 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment