Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added scrolling functionality #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions uwsgitop
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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']:
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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)