diff --git a/uwsgitop b/uwsgitop index bddbb25..ca6f0ef 100644 --- a/uwsgitop +++ b/uwsgitop @@ -118,12 +118,15 @@ last_reqnumber_per_core = defaultdict(int) # 1 - merge core statistics with worker statistics # 2 - display active cores under workers async_mode = 0 +scroll_shift = 0 while True: screen.clear() + (screen_height, screen_width) = screen.getmaxyx() js = '' + count_entries = 0 try: s = socket.socket(sfamily, socket.SOCK_STREAM) @@ -184,6 +187,9 @@ while True: dt = time.time() - last_tot_time total_rps = 0 for worker in dd['workers']: + if async_mode != 1: + count_entries += 1 + wid = worker['id'] curr_reqnumber = worker['requests'] last_reqnumber = last_reqnumber_per_worker[wid] @@ -196,6 +202,8 @@ while True: if not core['requests']: # ignore unused cores continue + count_entries += 1 + wcid = (wid, core['id']) curr_reqnumber = core['requests'] last_reqnumber = last_reqnumber_per_core[wcid] @@ -213,7 +221,7 @@ while True: tx = human_size(sum( [worker['tx'] for worker in dd['workers']] )) screen.addstr(0, 0, "uwsgi%s - %s - req: %d - RPS: %d - lq: %d - tx: %s" % (uversion, time.ctime(), tot, int(round(total_rps)), dd['listen_queue'], tx)) screen.addstr(2, 0, " WID\t%\tPID\tREQ\tRPS\tEXC\tSIG\tSTATUS\tAVG\tRSS\tVSZ\tTX\tRunT\t", curses.A_REVERSE) - pos = 3 + pos = 3 + scroll_shift dd['workers'].sort(key=reqcount) for worker in dd['workers']: @@ -242,14 +250,15 @@ while True: rps = int(round(rps_per_worker[wid])) - try: - screen.addstr(pos, 0, " %s\t%.1f\t%d\t%d\t%d\t%d\t%d\t%s\t%dms\t%s\t%s\t%s\t%s" % ( - wid, calc_percent(tot, worker['requests']), worker['pid'], worker['requests'], rps, worker['exceptions'], sigs, worker['status'], - worker['avg_rt']/1000, human_size(worker['rss']), human_size(worker['vsz']), - wtx, wrunt - ), color) - except: - pass + if pos >= 3: + try: + screen.addstr(pos, 0, " %s\t%.1f\t%d\t%d\t%d\t%d\t%d\t%s\t%dms\t%s\t%s\t%s\t%s" % ( + wid, calc_percent(tot, worker['requests']), worker['pid'], worker['requests'], rps, worker['exceptions'], sigs, worker['status'], + worker['avg_rt']/1000, human_size(worker['rss']), human_size(worker['vsz']), + wtx, wrunt + ), color) + except: + pass pos += 1 if async_mode != 2: continue @@ -263,12 +272,13 @@ while True: cid = core['id'] rps = int(round(rps_per_core[wid, cid])) - try: - screen.addstr(pos, 0, " :%s\t%.1f\t-\t%d\t%d\t-\t-\t%s\t-\t-\t-\t-\t-" % ( - cid, calc_percent(tot, core['requests']), core['requests'], rps, status, - ), color) - except: - pass + if pos >= 3: + try: + screen.addstr(pos, 0, " :%s\t%.1f\t-\t%d\t%d\t-\t-\t%s\t-\t-\t-\t-\t-" % ( + cid, calc_percent(tot, core['requests']), core['requests'], rps, status + ), color) + except: + pass pos += 1 screen.refresh() @@ -280,5 +290,15 @@ while True: break elif ch == ord('a'): async_mode = (async_mode + 1) % 3 + scroll_shift = 0 + elif ch == curses.KEY_PPAGE or ch == ord('n'): + scroll_shift += screen_height / 2 + if scroll_shift > 0: + scroll_shift = 0 + elif ch == curses.KEY_NPAGE or ch == ord('m'): + if count_entries > screen_height - 3: + scroll_shift -= screen_height / 2 + if scroll_shift + count_entries + 3 < screen_height: + scroll_shift = -1 * (count_entries - screen_height + 3)