module is good and produces nice output... start work on the script
This commit is contained in:
parent
f0cfff29dd
commit
9a57aa122a
|
@ -0,0 +1,38 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Getopt::Long;
|
||||||
|
use Proc::ProcessTable::ncps;
|
||||||
|
|
||||||
|
sub version{
|
||||||
|
print "ncps v. 0.0.0\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub help{
|
||||||
|
print '
|
||||||
|
|
||||||
|
-z Show zombies procs.
|
||||||
|
-s Show swapped out procs.
|
||||||
|
|
||||||
|
-p <regex> Search procs using the matching regex.
|
||||||
|
|
||||||
|
-u <users> A string search for users.
|
||||||
|
|
||||||
|
-t <time search> A numeric search for CPU time-c <pctcpu search> A numeric search for CPU usage percent
|
||||||
|
|
||||||
|
-m <pctmem search> A numeric search for memory usage percent
|
||||||
|
|
||||||
|
-w <wait channels> A string search for wait channels.
|
||||||
|
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
my $args={
|
||||||
|
invert=>0,
|
||||||
|
};
|
||||||
|
|
||||||
|
my $ncps=Proc::ProcessTable::ncps->new( $args );
|
||||||
|
print $ncps->run;
|
||||||
|
exit 0;
|
|
@ -137,32 +137,32 @@ sub run{
|
||||||
#
|
#
|
||||||
# handles the %CPU
|
# handles the %CPU
|
||||||
#
|
#
|
||||||
push( @new_line, color('bright_green').$proc->{pctcpu}.color('reset') );
|
push( @new_line, color('bright_magenta').$proc->{pctcpu}.color('reset') );
|
||||||
|
|
||||||
#
|
#
|
||||||
# handles the %MEM
|
# handles the %MEM
|
||||||
#
|
#
|
||||||
if ( $^O =~ /bsd/ ) {
|
if ( $^O =~ /bsd/ ) {
|
||||||
my $mem=(($proc->{rssize} * 1024 * 4 ) / $physmem) * 100;
|
my $mem=(($proc->{rssize} * 1024 * 4 ) / $physmem) * 100;
|
||||||
push( @new_line, color('bright_green').sprintf('%.2f', $mem).color('reset') );
|
push( @new_line, color('bright_blue').sprintf('%.2f', $mem).color('reset') );
|
||||||
} else {
|
} else {
|
||||||
push( @new_line, color('bright_green').sprintf('%.2f', $proc->{pctcpu}).color('reset') );
|
push( @new_line, color('bright_blue').sprintf('%.2f', $proc->{pctcpu}).color('reset') );
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# handles VSZ
|
# handles VSZ
|
||||||
#
|
#
|
||||||
push( @new_line, color('bright_green').$proc->{size}.color('reset') );
|
push( @new_line, color('bright_yellow').$proc->{size}.color('reset') );
|
||||||
|
|
||||||
#
|
#
|
||||||
# handles the rss
|
# handles the rss
|
||||||
#
|
#
|
||||||
push( @new_line, color('bright_green').$proc->{rss}.color('reset') );
|
push( @new_line, color('bright_cyan').$proc->{rss}.color('reset') );
|
||||||
|
|
||||||
#
|
#
|
||||||
# handles the info
|
# handles the info
|
||||||
#
|
#
|
||||||
my $info=color('bright_magenta');
|
my $info;
|
||||||
my %flags;
|
my %flags;
|
||||||
$flags{is_session_leader}=0;
|
$flags{is_session_leader}=0;
|
||||||
$flags{is_being_forked}=0;
|
$flags{is_being_forked}=0;
|
||||||
|
@ -216,6 +216,7 @@ sub run{
|
||||||
) {
|
) {
|
||||||
$info='R';
|
$info='R';
|
||||||
}
|
}
|
||||||
|
$info=color('bright_magenta').$info;
|
||||||
#checks if it is swapped out
|
#checks if it is swapped out
|
||||||
if (
|
if (
|
||||||
( $proc->{state} ne 'zombie' ) &&
|
( $proc->{state} ne 'zombie' ) &&
|
||||||
|
@ -268,7 +269,7 @@ sub run{
|
||||||
#
|
#
|
||||||
# handles the start column
|
# handles the start column
|
||||||
#
|
#
|
||||||
push( @new_line, color('bright_cyan').$self->startString( $proc->{start} ).color('reset') );
|
push( @new_line, color('bright_yellow').$self->startString( $proc->{start} ).color('reset') );
|
||||||
|
|
||||||
#
|
#
|
||||||
# handles the time column
|
# handles the time column
|
||||||
|
|
Loading…
Reference in New Issue