Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
Zane C. B-H | 27f1223c46 | |
Zane C. B-H | 98fa041549 | |
Zane C. B-H | 8e4b846614 | |
Zane C. B-H | d577047600 | |
Zane C. B-H | 33f86b0d46 | |
Zane C. B-H | 0cce4f43c0 | |
Zane C. B-H | d75bf8cb8d | |
Zane C. B-H | 689fa59bed | |
Zane C. B-H | a71e572d00 |
|
@ -1,5 +1,16 @@
|
|||
Revision history for Proc-ProcessTable-ncps
|
||||
|
||||
0.1.2 2020-12-30/05:00
|
||||
- Now use ColorThemes::Standard.
|
||||
- Fix --stats.
|
||||
|
||||
0.1.1 2020-10-04/03:30
|
||||
- Update so it plays nicely with Text::ANSITable 0.600
|
||||
|
||||
0.1.0 2019-08-28/02:00
|
||||
- Now use Proc::ProcessTable::InfoString.
|
||||
- Document information symbols.
|
||||
|
||||
0.0.1 2019-08-26/20:45
|
||||
- Handle time properly on linux now
|
||||
by converting it to seconds.
|
||||
|
|
|
@ -26,6 +26,8 @@ my %WriteMakefileArgs = (
|
|||
'Proc::ProcessTable::Match'=>'0.0.1',
|
||||
'Statistics::Basic'=>'1.6611',
|
||||
'List::Util'=>'0.0',
|
||||
'Proc::ProcessTable::InfoString' => '0.0.1',
|
||||
'ColorTheme::NoColor'=>'0.0',
|
||||
},
|
||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||
clean => { FILES => 'Proc-ProcessTable-ncps-*' },
|
||||
|
|
|
@ -90,6 +90,23 @@ the number.
|
|||
>=
|
||||
!
|
||||
|
||||
|
||||
The symbols in the information coloum are as below.
|
||||
|
||||
States Description
|
||||
Z Zombie
|
||||
S Sleep
|
||||
W Wait
|
||||
R Run
|
||||
|
||||
Flags Description
|
||||
O Swapped Output
|
||||
E Exiting
|
||||
s Session Leader
|
||||
L POSIX lock advisory
|
||||
+ has controlling terminal
|
||||
X traced by a debugger
|
||||
F being forked
|
||||
';
|
||||
}
|
||||
|
||||
|
@ -512,6 +529,25 @@ ncps [B<-c> <regex>] [B<--ci>] [B<--cf>] [B<--cF>] [B<--eg>] [B<--egi>]
|
|||
No flags needed passed to use. By default it will show all processes except
|
||||
for its own and the idle process.
|
||||
|
||||
The info column is provided by L<Proc::ProcessTable::InfoString>. That
|
||||
POD has the information on what they all mean. At the time of writing, this is
|
||||
as below.
|
||||
|
||||
States Description
|
||||
Z Zombie
|
||||
S Sleep
|
||||
W Wait
|
||||
R Run
|
||||
|
||||
Flags Description
|
||||
O Swapped Output
|
||||
E Exiting
|
||||
s Session Leader
|
||||
L POSIX lock advisory
|
||||
+ has controlling terminal
|
||||
X traced by a debugger
|
||||
F being forked
|
||||
|
||||
=head1 SWITCHES
|
||||
|
||||
=head2 -c <regex>
|
||||
|
|
|
@ -9,18 +9,19 @@ use Text::ANSITable;
|
|||
use Term::ANSIColor;
|
||||
use Statistics::Basic qw(:all);
|
||||
use List::Util qw( min max sum );
|
||||
use Proc::ProcessTable::InfoString;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Proc::ProcessTable::ncps - The great new Proc::ProcessTable::ncps!
|
||||
Proc::ProcessTable::ncps - New Colorized(optional) PS, a enhanced version of PS with advanced searching capabilities
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Version 0.0.1
|
||||
Version 0.1.2
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '0.0.1';
|
||||
our $VERSION = '0.1.2';
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
@ -45,6 +46,9 @@ our $VERSION = '0.0.1';
|
|||
|
||||
print $ncps->run
|
||||
|
||||
The info column is provided by L<Proc::ProcessTable::InfoString>. That
|
||||
POD has the information on what they all mean.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 new
|
||||
|
@ -226,8 +230,8 @@ sub run{
|
|||
}
|
||||
|
||||
my $tb = Text::ANSITable->new;
|
||||
$tb->border_style('Default::none_ascii');
|
||||
$tb->color_theme('Default::no_color');
|
||||
$tb->border_style('ASCII::None');
|
||||
$tb->color_theme('NoColor');
|
||||
|
||||
#
|
||||
# assemble the headers
|
||||
|
@ -374,109 +378,11 @@ sub run{
|
|||
#
|
||||
# handles the info
|
||||
#
|
||||
my $info;
|
||||
my %flags;
|
||||
$flags{is_session_leader}=0;
|
||||
$flags{is_being_forked}=0;
|
||||
$flags{working_on_exiting}=0;
|
||||
$flags{has_controlling_terminal}=0;
|
||||
$flags{is_locked}=0;
|
||||
$flags{traced_by_debugger}=0;
|
||||
$flags{is_stopped}=0;
|
||||
$flags{posix_advisory_lock}=0;
|
||||
# parses the flags for freebsd
|
||||
if ( $^O =~ /freebsd/ ) {
|
||||
if ( hex($proc->flags) & 0x00002 ) {
|
||||
$flags{controlling_tty_active}=1;
|
||||
}
|
||||
if ( hex($proc->flags) & 0x00000002 ) {
|
||||
$flags{is_session_leader}=1;
|
||||
}
|
||||
#if ( hex($proc->flags) & ){$flags{is_being_forked}=1; }
|
||||
if ( hex($proc->flags) & 0x02000 ) {
|
||||
$flags{working_on_exiting}=1;
|
||||
}
|
||||
if ( hex($proc->flags) & 0x00002 ) {
|
||||
$flags{has_controlling_terminal}=1;
|
||||
}
|
||||
if ( hex($proc->flags) & 0x00000004 ) {
|
||||
$flags{is_locked}=1;
|
||||
}
|
||||
if ( hex($proc->flags) & 0x00800 ) {
|
||||
$flags{traced_by_debugger}=1;
|
||||
}
|
||||
if ( hex($proc->flags) & 0x00001 ) {
|
||||
$flags{posix_advisory_lock}=1;
|
||||
}
|
||||
}
|
||||
# get the state
|
||||
$info=$proc->{state};
|
||||
if (
|
||||
$info eq 'sleep'
|
||||
) {
|
||||
$info='S';
|
||||
} elsif (
|
||||
$info eq 'zombie'
|
||||
) {
|
||||
$info='Z';
|
||||
} elsif (
|
||||
$info eq 'wait'
|
||||
) {
|
||||
$info='W';
|
||||
} elsif (
|
||||
$info eq 'run'
|
||||
) {
|
||||
$info='R';
|
||||
}
|
||||
$info=color($self->nextColor).$info;
|
||||
#checks if it is swapped out
|
||||
if (
|
||||
( $proc->{state} ne 'zombie' ) &&
|
||||
( $proc->{rss} == '0' )
|
||||
) {
|
||||
$info=$info.'O';
|
||||
}
|
||||
#handles the various flags
|
||||
if ( $flags{working_on_exiting} ) {
|
||||
$info=$info.'E';
|
||||
}
|
||||
;
|
||||
if ( $flags{is_session_leader} ) {
|
||||
$info=$info.'s';
|
||||
}
|
||||
;
|
||||
if ( $flags{is_locked} || $flags{posix_advisory_lock} ) {
|
||||
$info=$info.'L';
|
||||
}
|
||||
;
|
||||
if ( $flags{has_controlling_terminal} ) {
|
||||
$info=$info.'+';
|
||||
}
|
||||
;
|
||||
if ( $flags{is_being_forked} ) {
|
||||
$info=$info.'F';
|
||||
}
|
||||
;
|
||||
if ( $flags{traced_by_debugger} ) {
|
||||
$info=$info.'X';
|
||||
}
|
||||
;
|
||||
# adds the wchan
|
||||
$info=$info.' '.color($self->nextColor);
|
||||
if ( $^O =~ /linux/ ) {
|
||||
my $wchan='';
|
||||
if ( -e '/proc/'.$proc->{pid}.'/wchan') {
|
||||
open( my $wchan_fh, '<', '/proc/'.$proc->{pid}.'/wchan' );
|
||||
$wchan=readline( $wchan_fh );
|
||||
close( $wchan_fh );
|
||||
}
|
||||
$info=$info.$wchan;
|
||||
} else {
|
||||
$info=$info.$proc->{wchan};
|
||||
}
|
||||
$info=$info.color('reset');
|
||||
# finally actually add it to the new new line array
|
||||
push( @new_line, $info );
|
||||
my $is = Proc::ProcessTable::InfoString->new({
|
||||
flags_color=>$self->nextColor,
|
||||
wchan_color=>$self->nextColor,
|
||||
});
|
||||
push( @new_line, $is->info( $proc ) );
|
||||
|
||||
#
|
||||
# handle the nice column
|
||||
|
@ -572,8 +478,9 @@ sub run{
|
|||
my $stats='';
|
||||
if ( $self->{stats} ){
|
||||
my $stb = Text::ANSITable->new;
|
||||
$stb->border_style('Default::none_ascii');
|
||||
$stb->color_theme('Default::no_color');
|
||||
#$stb->border_style('Default::none_ascii');
|
||||
$stb->border_style('ASCII::None');
|
||||
$stb->color_theme('NoColor');
|
||||
|
||||
#
|
||||
# assemble the headers
|
||||
|
|
165
README.md
165
README.md
|
@ -1,3 +1,164 @@
|
|||
# Proc-ProcessTable-ncps
|
||||
# About
|
||||
New Colorized(optional) PS, a enhanced version of PS with advanced searching capabilities.
|
||||
|
||||
New Colorized PS, a enhanced version of PS with advanced searching capabilities.
|
||||
![ncps](ncps.png)
|
||||
|
||||
The search criteria can be any of the following.
|
||||
|
||||
* command
|
||||
* EUID set
|
||||
* EGID set
|
||||
* JID
|
||||
* is a kernel process
|
||||
* percent of memory usage
|
||||
* percent of CPU usage
|
||||
* RSS
|
||||
* VSZ
|
||||
* is swapped out
|
||||
* process state
|
||||
* CPU time in seconds
|
||||
* UID or username
|
||||
* wait channel
|
||||
* is a zombie process
|
||||
|
||||
# Command Line Options
|
||||
```
|
||||
-c <regex> Search procs using the matching regex.
|
||||
--ci Invert the command search.
|
||||
|
||||
--cf Show children minor faults.
|
||||
|
||||
--cF Show children major faults.
|
||||
|
||||
--eg Search for proccs with a EGID set.
|
||||
--egi Invert the EGID set search.
|
||||
|
||||
--eu Search for proccs with a EUID set.
|
||||
--eui Invert the EUID set search.
|
||||
|
||||
-f Show minor faults.
|
||||
|
||||
-F Show major faults.
|
||||
|
||||
-J Show jail IDs.
|
||||
-j <jids> A comma seperated list of JIDs to search for.
|
||||
--ji Invert the JIDs earch.
|
||||
|
||||
--idle Show the idle kernel process.
|
||||
|
||||
--kern Searches for kernel processes.
|
||||
--kerni Invert the kernel process search.
|
||||
|
||||
-m <pctmem> Memory usage percent to search for.
|
||||
--mi Invert the memory usage search.
|
||||
|
||||
-n Show number of threads.
|
||||
|
||||
--nc disable color.
|
||||
|
||||
-p <pctcpu> CPU usage percent to search for.
|
||||
--pi Invert the CPU usage search.
|
||||
|
||||
--pid <pids> PIDs to search for.
|
||||
--pidi Invert the PID search.
|
||||
|
||||
-r <RSSs> A comma seperated list of RSS values to search for.
|
||||
--ri Invert the RSS search.
|
||||
|
||||
-s Show swapped out procs.
|
||||
--si Invert the swapped out search.
|
||||
|
||||
--self Show the the ncps process as well.
|
||||
|
||||
--st <states> A comma seperated list of states to search for.
|
||||
--sti Invert the state search.
|
||||
|
||||
--stats Print some general states about CPU usage and memory usage.
|
||||
|
||||
-t <times> A comma seperated value of time, in seconds, to search for.
|
||||
--ti Invert the time search.
|
||||
|
||||
--tty Show TTYs.
|
||||
|
||||
-u <UIDs> A comma seperated list of UIDs or usernames.
|
||||
--ui Invert the UID/username search.
|
||||
|
||||
-vs <VSZs> A comma seperated list of VSZs to search for.
|
||||
--vsi Invert the VSZ search.
|
||||
|
||||
-w <wchans> A string search for wait channels.
|
||||
--wi Invert the wait channel search.
|
||||
|
||||
-z Show zombies procs.
|
||||
|
||||
|
||||
For the various switches above that can take numeric values,
|
||||
the equalities below can be used, by directly prepending them to
|
||||
the number.
|
||||
<
|
||||
<=
|
||||
>
|
||||
>=
|
||||
!
|
||||
```
|
||||
|
||||
# Enviromental Variables
|
||||
|
||||
The enviromental variables below may be set to set the default for the
|
||||
flag in question.
|
||||
|
||||
Unless set to defined ands set to 1, these will default to 0.
|
||||
|
||||
|
||||
| Variable | Description |
|
||||
| -------- | ---------------- |
|
||||
| NCPS_jid | Sets the default for the -J flag. |
|
||||
| NCPS_numthr | Sets the default for the -n flag.|
|
||||
| NCPS_cmajflt | Sets the default for the --cF flag. |
|
||||
| NCPS_majflt | Sets the default for the -F flag. |
|
||||
| NCPS_cminflt | Sets the default for the --cf flag. |
|
||||
| NCPS_minflt | Sets the default for the -f flag. |
|
||||
| NCPS_tty | Sets the default for the --tty flag. |
|
||||
| NCPS_self | Sets the default for the --self flag. |
|
||||
| NCPS_idle | Sets the default for the --idle flag. |
|
||||
| NO_COLOR | Don't colorize the output. |
|
||||
|
||||
|
||||
# EXAMPLES
|
||||
ncps -J -j 0 --ji
|
||||
|
||||
Display all processes with a jail ID other than zero.
|
||||
|
||||
ncps -c firefox --stats
|
||||
|
||||
Show all firefox processes and the stats for them.
|
||||
|
||||
ncps -F -f -cF -cf
|
||||
|
||||
Show all minor/major values for processes.
|
||||
|
||||
ncps -p '>1'
|
||||
|
||||
Show all processes using more than 1% of the CPU time.
|
||||
|
||||
|
||||
# Installing
|
||||
|
||||
## FreeBSD
|
||||
|
||||
pkg install perl5 p5-App-cpanminus
|
||||
cpanm Proc::ProcessTable::ncps
|
||||
|
||||
## Linux
|
||||
|
||||
### CentOS
|
||||
|
||||
yum install cpanm
|
||||
cpanm Proc::ProcessTable::ncps
|
||||
|
||||
### Debian
|
||||
|
||||
This has been tested as working on Debian 9 minimal.
|
||||
|
||||
apt install perl perl-base perl-modules make cpanminus gcc
|
||||
cpanm Proc::ProcessTable::ncps
|
||||
|
|
Loading…
Reference in New Issue