Browse Source

module is good and produces nice output... start work on the script

master
Zane C. B-H 2 years ago
parent
commit
9a57aa122a
  1. 38
      Proc-ProcessTable-ncps/bin/ncps
  2. 15
      Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm

38
Proc-ProcessTable-ncps/bin/ncps

@ -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;

15
Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm

@ -137,32 +137,32 @@ sub run{
#
# 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
#
if ( $^O =~ /bsd/ ) {
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 {
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
#
push( @new_line, color('bright_green').$proc->{size}.color('reset') );
push( @new_line, color('bright_yellow').$proc->{size}.color('reset') );
#
# 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
#
my $info=color('bright_magenta');
my $info;
my %flags;
$flags{is_session_leader}=0;
$flags{is_being_forked}=0;
@ -216,6 +216,7 @@ sub run{
) {
$info='R';
}
$info=color('bright_magenta').$info;
#checks if it is swapped out
if (
( $proc->{state} ne 'zombie' ) &&
@ -268,7 +269,7 @@ sub run{
#
# 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

Loading…
Cancel
Save