Show group session count in the groups RPC call

This commit is contained in:
Neil Booth 2016-12-10 11:05:57 +09:00
parent c181f8df82
commit d1e314a48b

View File

@ -520,10 +520,9 @@ class ServerManager(util.LoggedClass):
session.socket.shutdown(socket.SHUT_RDWR) session.socket.shutdown(socket.SHUT_RDWR)
except socket.error: except socket.error:
pass pass
else: elif session.last_recv < stale_cutoff:
if session.last_recv < stale_cutoff: self.close_session(session)
self.close_session(session) stale.append(session.id_)
stale.append(session.id_)
if stale: if stale:
self.logger.info('closing stale connections {}'.format(stale)) self.logger.info('closing stale connections {}'.format(stale))
@ -572,13 +571,14 @@ class ServerManager(util.LoggedClass):
data is the return value of rpc_groups().''' data is the return value of rpc_groups().'''
fmt = ('{:<6} {:>9} {:>6} {:>6} {:>8}' fmt = ('{:<6} {:>9} {:>9} {:>6} {:>6} {:>8}'
'{:>7} {:>9} {:>7} {:>9}') '{:>7} {:>9} {:>7} {:>9}')
yield fmt.format('ID', 'Bw Qta KB', 'Reqs', 'Txs', 'Subs', yield fmt.format('ID', 'Sessions', 'Bw Qta KB', 'Reqs', 'Txs', 'Subs',
'Recv', 'Recv KB', 'Sent', 'Sent KB') 'Recv', 'Recv KB', 'Sent', 'Sent KB')
for (id_, bandwidth, reqs, txs_sent, subs, for (id_, session_count, bandwidth, reqs, txs_sent, subs,
recv_count, recv_size, send_count, send_size) in data: recv_count, recv_size, send_count, send_size) in data:
yield fmt.format(id_, yield fmt.format(id_,
'{:,d}'.format(session_count),
'{:,d}'.format(bandwidth // 1024), '{:,d}'.format(bandwidth // 1024),
'{:,d}'.format(reqs), '{:,d}'.format(reqs),
'{:,d}'.format(txs_sent), '{:,d}'.format(txs_sent),
@ -594,6 +594,7 @@ class ServerManager(util.LoggedClass):
for group_id in sorted(self.groups.keys()): for group_id in sorted(self.groups.keys()):
sessions = self.groups[group_id] sessions = self.groups[group_id]
result.append([group_id, result.append([group_id,
len(sessions),
sum(s.bandwidth_used for s in sessions), sum(s.bandwidth_used for s in sessions),
sum(s.requests_remaining() for s in sessions), sum(s.requests_remaining() for s in sessions),
sum(s.txs_sent for s in sessions), sum(s.txs_sent for s in sessions),