提交 32f4022f 编写于 作者: X xj0 提交者: LINGuanRen

[dooba] support tableapi monitor

上级 c2c7336b
......@@ -1200,9 +1200,15 @@ class oceanbase(object):
else:
s_join = """ %s or (svr_ip = '%s' and svr_port = %s ) """ % ( s_join, a[0], a[1])
stat_ids = "stat_id in (10000,10004,10005,10006,30007,30008,30009,40000,40001,40002,40003,40004,40005,40006,40007,40008,40009,40010,40011,40012,40013,50000,50001,50002,50003,50004,50005,50006,50007,50008,50009,50010,50011,60000,60002,60003,60005,130000,130001,130002,130004) "
stat_ids = "stat_id in (10000,10004,10005,10006,30007,30008,30009,"\
"40000,40001,40002,40003,40004,40005,40006,40007,40008,40009,40010,40011,40012,40013,"\
"50000,50001,50002,50003,50004,50005,50006,50007,50008,50009,50010,50011,"\
"60000,60002,60003,60005,130000,130001,130002,130004,"\
"190001,190005,190405,190401,190205,190201,190105,190101,190305,190301,190505,190501,190903,190003,190403,190203,"\
"190103,190303,190503,190901,190004,190404,190204,190104,190304,190504,190902"\
") "
sql2 = """ select current_time(), stat.con_id, stat.svr_ip, stat.svr_port, stat.name, stat.value from gv\$sysstat stat where stat.class IN (1,4,8,16,32) and con_id = %s and (%s) """ % ( str(self.get_current_tenant()) , stat_ids)
sql2 = """ select current_time(), stat.con_id, stat.svr_ip, stat.svr_port, stat.name, stat.value from gv\$sysstat stat where stat.class IN (1,4,8,16,32,4096) and con_id = %s and (%s) """ % ( str(self.get_current_tenant()) , stat_ids)
DEBUG(self.__check_schema, "oceanbase.check schema sql : ", sql2)
......@@ -2981,6 +2987,86 @@ def DEBUG(*args):
if Options.debug :
print >> DEV, "line %s :%s in [%s] %s %s" % (sys._getframe().f_lineno, time.asctime(), args[0].func_name, args[1], args[2])
class TableApiPage(Page):
def __add_widgets(self):
tid = oceanbase.get_current_tenant()
DEBUG(self.__add_widgets, "cur_tenant_id", tid)
time_widget = ColumnWidget("TIME-TENANT", [
Column("timestamp", lambda stat:
stat["timestamp"].strftime("%H:%m:%S"),
10, True),
Column("tenant", lambda stat:
tid,
10, True
),
], self.win())
tableapi_widget = ColumnWidget("TABLE API ROWS", [
Column("get", lambda stat:(sum([ item["multi retrieve rows"] for item in stat[str(tid)].values() ])
+ sum([ item["single retrieve execute count"] for item in stat[str(tid)].values() ])), 6, True),
Column("put", lambda stat:(sum([ item["multi insert_or_update rows"] for item in stat[str(tid)].values()])
+ sum([ item["single insert_or_update execute count"] for item in stat[str(tid)].values() ])), 6, True),
Column("del", lambda stat:(sum([ item["multi delete rows"] for item in stat[str(tid)].values() ])
+ sum([ item["single delete execute count"] for item in stat[str(tid)].values() ])), 6, True),
Column("ins", lambda stat:(sum([ item["multi insert rows"] for item in stat[str(tid)].values() ])
+ sum([ item["single insert execute count"] for item in stat[str(tid)].values() ])), 6, True),
Column("upd", lambda stat:(sum([ item["multi update rows"] for item in stat[str(tid)].values() ])
+ sum([ item["single update execute count"] for item in stat[str(tid)].values() ])), 6, True),
Column("repl", lambda stat:(sum([ item["multi replace rows"] for item in stat[str(tid)].values() ])
+ sum([ item["single replace execute count"] for item in stat[str(tid)].values() ])), 6, True),
Column("query", lambda stat:(sum([ item["query row count"] for item in stat[str(tid)].values() ])), 6, True),
], self.win())
tableapi_widget2 = ColumnWidget("TABLE API OPS", [
Column("get", lambda stat:(sum([ item["multi retrieve execute count"] for item in stat[str(tid)].values()])),6, True),
Column("put", lambda stat:(sum([ item["multi insert_or_update execute count"] for item in stat[str(tid)].values()])),6, True),
Column("del", lambda stat:(sum([ item["multi delete execute count"] for item in stat[str(tid)].values()])),6, True),
Column("ins", lambda stat:(sum([ item["multi insert execute count"] for item in stat[str(tid)].values()])),6, True),
Column("upd", lambda stat:(sum([ item["multi update execute count"] for item in stat[str(tid)].values()])),6, True),
Column("repl", lambda stat:(sum([ item["multi replace execute count"] for item in stat[str(tid)].values()])),6, True),
Column("query", lambda stat:(sum([ item["query count"] for item in stat[str(tid)].values()])),6, True),
], self.win())
tableapi_widget3 = ColumnWidget("Table API RT", [
Column("get", lambda stat:(sum([ item["multi retrieve execute time"] for item in stat[str(tid)].values() ])
/ float(sum([ item["multi retrieve execute count"] for item in stat[str(tid)].values() ]) or 1) / 1000), 6),
Column("put", lambda stat:(sum([ item["multi insert_or_update execute time"] for item in stat[str(tid)].values() ])
/ float(sum([ item["multi insert_or_update execute count"] for item in stat[str(tid)].values() ]) or 1) / 1000), 6),
Column("del", lambda stat:(sum([ item["multi delete execute time"] for item in stat[str(tid)].values() ])
/ float(sum([ item["multi delete execute count"] for item in stat[str(tid)].values() ]) or 1) / 1000), 6),
Column("ins", lambda stat:(sum([ item["multi insert execute time"] for item in stat[str(tid)].values() ])
/ float(sum([ item["multi insert execute count"] for item in stat[str(tid)].values() ]) or 1) / 1000), 6),
Column("upd", lambda stat:(sum([ item["multi update execute time"] for item in stat[str(tid)].values() ])
/ float(sum([ item["multi update execute count"] for item in stat[str(tid)].values() ]) or 1) / 1000), 6),
Column("repl", lambda stat:(sum([ item["multi replace execute time"] for item in stat[str(tid)].values() ])
/ float(sum([ item["multi replace execute count"] for item in stat[str(tid)].values() ]) or 1) / 1000), 6),
Column("query", lambda stat:(sum([ item["query time"] for item in stat[str(tid)].values() ])
/ float(sum([ item["query count"] for item in stat[str(tid)].values() ]) or 1) / 1000), 6),
], self.win())
self.add_widget(time_widget)
self.add_widget(tableapi_widget2)
self.add_widget(tableapi_widget)
self.add_widget(tableapi_widget3)
def __init__(self, y, x, h, w, parent):
Page.__init__(self, parent, Layout(), y, x, h, w)
try:
self.__add_widgets()
except curses.error:
pass
def title(self):
return "Table API"
def process_key(self, ch):
if ch == ord('j'):
pass
else:
Page.process_key(self, ch)
class SQLPage(Page):
def update_widgets(self):
DEBUG(self.update_widgets, "SQLPage.update_widgets() ", "")
......@@ -3556,10 +3642,10 @@ class Dooba(object):
self.__all_page.append(HelpPage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 1
self.__all_page.append(GalleryPage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 2
self.__all_page.append(SQLPage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 3
self.__all_page.append(HistoryPage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 4
self.__all_page.append(BianquePage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 5
self.__all_page.append(MachineStatPage(2, 0, self.maxy-4, self.maxx, self.stdscr)) # 6
self.__all_page.append(BlankPage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 7
self.__all_page.append(TableApiPage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 4
self.__all_page.append(HistoryPage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 5
self.__all_page.append(BianquePage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 6
self.__all_page.append(MachineStatPage(2, 0, self.maxy-4, self.maxx, self.stdscr)) # 7
self.__all_page.append(BlankPage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 8
self.__all_page.append(BlankPage(2, 0, self.maxy - 4, self.maxx, self.stdscr)) # 9
self.__run()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册