Skip to content
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
97 changes: 59 additions & 38 deletions kippo/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,51 +92,72 @@ def call(self):
args = ''
if len(self.args):
args = self.args[0].strip()
_user, _pid, _cpu, _mem, _vsz, _rss, _tty, _stat, \
_start, _time, _command = range(11)
_user, _uid, _pid, _ppid, _cpu, _mem, _vsz, _rss, \
_tty, _stat, _c, _start, _time, _command = range(14)
output = (
('USER ', ' PID', ' %CPU', ' %MEM', ' VSZ', ' RSS', ' TTY ', 'STAT ', 'START', ' TIME ', 'COMMAND',),
('root ', ' 1', ' 0.0', ' 0.1', ' 2100', ' 688', ' ? ', 'Ss ', 'Nov06', ' 0:07 ', 'init [2] ',),
('root ', ' 2', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[kthreadd]',),
('root ', ' 3', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[migration/0]',),
('root ', ' 4', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[ksoftirqd/0]',),
('root ', ' 5', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[watchdog/0]',),
('root ', ' 6', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:17 ', '[events/0]',),
('root ', ' 7', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[khelper]',),
('root ', ' 39', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[kblockd/0]',),
('root ', ' 41', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[kacpid]',),
('root ', ' 42', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[kacpi_notify]',),
('root ', ' 170', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[kseriod]',),
('root ', ' 207', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S ', 'Nov06', ' 0:01 ', '[pdflush]',),
('root ', ' 208', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S ', 'Nov06', ' 0:00 ', '[pdflush]',),
('root ', ' 209', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[kswapd0]',),
('root ', ' 210', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[aio/0]',),
('root ', ' 748', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[ata/0]',),
('root ', ' 749', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[ata_aux]',),
('root ', ' 929', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[scsi_eh_0]',),
('root ', '1014', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'D< ', 'Nov06', ' 0:03 ', '[kjournald]',),
('root ', '1087', ' 0.0', ' 0.1', ' 2288', ' 772', ' ? ', 'S<s ', 'Nov06', ' 0:00 ', 'udevd --daemon',),
('root ', '1553', ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', 'Nov06', ' 0:00 ', '[kpsmoused]',),
('root ', '2054', ' 0.0', ' 0.2', ' 28428', ' 1508', ' ? ', 'Sl ', 'Nov06', ' 0:01 ', '/usr/sbin/rsyslogd -c3',),
('root ', '2103', ' 0.0', ' 0.2', ' 2628', ' 1196', ' tty1 ', 'Ss ', 'Nov06', ' 0:00 ', '/bin/login -- ',),
('root ', '2105', ' 0.0', ' 0.0', ' 1764', ' 504', ' tty2 ', 'Ss+ ', 'Nov06', ' 0:00 ', '/sbin/getty 38400 tty2',),
('root ', '2107', ' 0.0', ' 0.0', ' 1764', ' 504', ' tty3 ', 'Ss+ ', 'Nov06', ' 0:00 ', '/sbin/getty 38400 tty3',),
('root ', '2109', ' 0.0', ' 0.0', ' 1764', ' 504', ' tty4 ', 'Ss+ ', 'Nov06', ' 0:00 ', '/sbin/getty 38400 tty4',),
('root ', '2110', ' 0.0', ' 0.0', ' 1764', ' 504', ' tty5 ', 'Ss+ ', 'Nov06', ' 0:00 ', '/sbin/getty 38400 tty5',),
('root ', '2112', ' 0.0', ' 0.0', ' 1764', ' 508', ' tty6 ', 'Ss+ ', 'Nov06', ' 0:00 ', '/sbin/getty 38400 tty6',),
('root ', '2133', ' 0.0', ' 0.1', ' 2180', ' 620', ' ? ', 'S<s ', 'Nov06', ' 0:00 ', 'dhclient3 -pf /var/run/dhclient.eth0.pid -lf /var/lib/dhcp3/dhclien',),
('root ', '4969', ' 0.0', ' 0.1', ' 5416', ' 1024', ' ? ', 'Ss ', 'Nov08', ' 0:00 ', '/usr/sbin/sshd: %s@pts/0' % user,),
('%s'.ljust(8) % user, '5673', ' 0.0', ' 0.2', ' 2924', ' 1540', ' pts/0 ', 'Ss ', '04:30', ' 0:00 ', '-bash',),
('%s'.ljust(8) % user, '5679', ' 0.0', ' 0.1', ' 2432', ' 928', ' pts/0 ', 'R+ ', '04:32', ' 0:00 ', 'ps %s' % ' '.join(self.args),)
)
('USER ','UID ', ' PID', ' PPID' , ' %CPU', ' %MEM', ' VSZ', ' RSS', ' TTY ', 'STAT ', ' C ', ' START ', ' TIME ', 'COMMAND',),
('root ','root ', ' 1', ' 0' , ' 0.0', ' 0.1', ' 2100', ' 688', ' ? ', 'Ss ', ' 0 ', ' May20 ', ' 0:09 ', 'init [2] ',),
('root ','root ', ' 2', ' 0' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kthreadd]',),
('root ','root ', ' 3', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[ksoftirqd/0]',),
('root ','root ', ' 5', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kworker/u:0]',),
('root ','root ', ' 6', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[migration/0]',),
('root ','root ', ' 7', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[watchdog/0]',),
('root ','root ', ' 8', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[migration/1]',),
('root ','root ', ' 9', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kworker/1:0]',),
('root ','root ', ' 10', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[ksoftirqd/1]',),
('root ','root ', ' 12', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[watchdog/0]',),
('root ','root ', ' 13', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[khelper]',),
('root ','root ', ' 14', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kdevtmpfs]',),
('root ','root ', ' 15', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[cpuset/0]',),
('root ','root ', ' 20', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:17 ', '[events/0]',),
('root ','root ', ' 23', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kblockd/0]',),
('root ','root ', ' 24', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kacpid]',),
('root ','root ', ' 25', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kacpi_notify]',),
('root ','root ', ' 100', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kseriod]',),
('root ','root ', ' 107', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S ', ' 0 ', ' May20 ', ' 0:01 ', '[pdflush]',),
('root ','root ', ' 108', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S ', ' 0 ', ' May20 ', ' 0:00 ', '[pdflush]',),
('root ','root ', ' 109', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kswapd0]',),
('root ','root ', ' 110', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[aio/0]',),
('root ','root ', ' 348', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[ata/0]',),
('root ','root ', ' 349', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[ata_aux]',),
('root ','root ', ' 629', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[scsi_eh_0]',),
('root ','root ', ' 707', ' 2' , ' 0.0', ' 0.1', ' 2290', ' 1308', ' ? ', 'S<s ', ' 0 ', ' May20 ', ' 0:00 ', 'udevd --daemon',),
('root ','root ', '1014', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'D< ', ' 0 ', ' May20 ', ' 0:03 ', '[kjournald]',),
('root ','root ', '1087', ' 707' , ' 0.0', ' 0.1', ' 2288', ' 1016', ' ? ', 'S<s ', ' 0 ', ' May20 ', ' 0:00 ', 'udevd --daemon',),
('root ','root ', '1087', ' 707' , ' 0.0', ' 0.1', ' 2288', ' 952', ' ? ', 'S<s ', ' 0 ', ' May20 ', ' 0:00 ', 'udevd --daemon',),
('root ','root ', '1553', ' 2' , ' 0.0', ' 0.0', ' 0', ' 0', ' ? ', 'S< ', ' 0 ', ' May20 ', ' 0:00 ', '[kpsmoused]',),
('root ','root ', '2054', ' 2' , ' 0.0', ' 0.2', ' 28428', ' 1508', ' ? ', 'Sl ', ' 0 ', ' May20 ', ' 0:01 ', '/usr/sbin/rsyslogd -c3',),
('root ','root ', '2103', ' 2' , ' 0.0', ' 0.2', ' 2628', ' 1196', ' tty1 ', 'Ss ', ' 0 ', ' May20 ', ' 0:00 ', '/bin/login -- ',),
('root ','root ', '2105', ' 2' , ' 0.0', ' 0.0', ' 1764', ' 504', ' tty2 ', 'Ss+ ', ' 0 ', ' May20 ', ' 0:00 ', '/sbin/getty 38400 tty2',),
('root ','root ', '2107', ' 2' , ' 0.0', ' 0.0', ' 1764', ' 504', ' tty3 ', 'Ss+ ', ' 0 ', ' May20 ', ' 0:00 ', '/sbin/getty 38400 tty3',),
('root ','root ', '2109', ' 2' , ' 0.0', ' 0.0', ' 1764', ' 504', ' tty4 ', 'Ss+ ', ' 0 ', ' May20 ', ' 0:00 ', '/sbin/getty 38400 tty4',),
('root ','root ', '2110', ' 2' , ' 0.0', ' 0.0', ' 1764', ' 504', ' tty5 ', 'Ss+ ', ' 0 ', ' May20 ', ' 0:00 ', '/sbin/getty 38400 tty5',),
('root ','root ', '2112', ' 2' , ' 0.0', ' 0.0', ' 1764', ' 508', ' tty6 ', 'Ss+ ', ' 0 ', ' May20 ', ' 0:00 ', '/sbin/getty 38400 tty6',),
('root ','root ', '2133', ' 2' , ' 0.0', ' 0.1', ' 2380', ' 620', ' ? ', 'S<s ', ' 0 ', ' May20 ', ' 0:00 ', '/sbin/rpcbind -w',),
('root ','root ', '2145', ' 2' , ' 0.0', ' 0.1', ' 2180', ' 1876', ' ? ', 'Ss ', ' 0 ', ' May20 ', ' 0:00 ', 'dhclient3 -pf /var/run/dhclient.eth0.pid -lf /var/lib/dhcp3/dhclien',),
('root ','root ', '2146', ' 1' , ' 0.0', ' 0.0', ' 2652', ' 360', ' ? ', 'S ', ' 0 ', ' May20 ', ' 0:00 ', '/sbin/rpcbind -w',),
('statd ','statd ', '2147', ' 1' , ' 0.0', ' 0.0', ' 28256', ' 2200', ' ? ', 'S ', ' 0 ', ' May20 ', ' 0:00 ', '/sbin/rpc.statd',),
('root ','root ', '2148', ' 2' , ' 0.0', ' 0.0', ' 1880', ' 620', ' ? ', 'Ss ', ' 0 ', ' May20 ', ' 0:00 ', '[rpciod]',),
('root ','root ', '2150', ' 2' , ' 0.0', ' 0.0', ' 2180', ' 592', ' ? ', 'Ss ', ' 0 ', ' May20 ', ' 0:00 ', '[nfsiod]',),
('root ','root ', '2151', ' 1' , ' 0.0', ' 0.0', ' 2156', ' 1100', ' ? ', 'Ss ', ' 0 ', ' May20 ', ' 0:00 ', '/usr/sbin/rpc.idmapd',),
('root ','root ', '2153', ' 1' , ' 0.0', ' 0.0', ' 3840', ' 1284', ' ? ', 'Ss ', ' 0 ', ' May20 ', ' 0:00 ', '/usr/sbin/rsyslogd -c5',),
('root ','root ', '2155', ' 1' , ' 0.0', ' 0.0', ' 1880', ' 976', ' ? ', 'S ', ' 0 ', ' May20 ', ' 0:00 ', '/usr/sbin/acpid',),
('root ','root ', '4969', ' 1' , ' 0.0', ' 0.1', ' 5416', ' 1024', ' ? ', 'Ss ', ' 0 ', ' May20 ', ' 0:00 ', '/usr/sbin/sshd: %s@pts/0' % user,),
('%s'.ljust(8) % user, '%s'.ljust(8) % user, '6567', ' 8132' , ' 0.0', ' 0.2', ' 2924', ' 1540', ' pts/0 ', 'Ss ', ' 0 ', ' 04:30 ', ' 0:00 ', '-bash',),
('%s'.ljust(8) % user, '%s'.ljust(8) % user, '7966', ' 9722' , ' 0.0', ' 0.1', ' 2432', ' 928', ' pts/0 ', 'R+ ', ' 0 ', ' 04:32 ', ' 0:00 ', 'ps %s' % ' '.join(self.args),)
)
for i in range(len(output)):
if i != 0:
if 'a' not in args and output[i][_user].strip() != user:
if 'a' not in args and 'e' not in args and output[i][_user].strip() != user:
continue
elif 'a' not in args and 'x' not in args \
elif 'a' not in args and 'x' not in args and 'e' not in args \
and output[i][_tty].strip() != 'pts/0':
continue
l = [_pid, _tty, _time, _command]
if 'e' in args:
l = [_pid, _tty, _time, _command]
if 'f' in args:
l = [_uid, _pid, _ppid, _c, _start, _tty, _time, _command]
if 'a' in args or 'x' in args:
l = [_pid, _tty, _stat, _time, _command]
if 'u' in args:
Expand Down