def listps(num, order):
 cmd = 'ps max -o pid,ppid,pcpu,pmem,rss,vsz,lwp,nlwp,lstart,cmd'
 cmd += (' --sort -%s' % order)
 title = 'Process/Threads details:'
 ps_info = utils.system_output(cmd, verbose=False).splitlines()
 if (num != 0):
  (cnt, idx) = (0, 0)
  title = ('Top %d process/threads details, ' % num)
  title += ('order by %s:' % order)
  for line in ps_info:
   idx += 1
   if re.match('^\\s+\\d', line):
    cnt += 1
   if (cnt > num):
    break
  ps_info = ps_info[:idx]
 ps_info.insert(0, title)
 return ps_info

def listps ( num , order ) : cmd = 'ps max -o pid,ppid,pcpu,pmem,rss,vsz,lwp,nlwp,lstart,cmd' cmd += ( ' --sort -%s' % order ) title = 'Process/Threads details:' ps_info = utils . system_output ( cmd , verbose = False ) . splitlines ( ) if ( num != 0 ) : ( cnt , idx ) = ( 0 , 0 ) title = ( 'Top %d process/threads details, ' % num ) title += ( 'order by %s:' % order ) for line in ps_info : idx += 1 if re . match ( '^\\s+\\d' , line ) : cnt += 1 if ( cnt > num ) : break ps_info = ps_info [ : idx ] ps_info . insert ( 0 , title ) return ps_info
select top num process order by $order from system .