tag 0.0.0 for Proc-ProcessTable-Colorizer
git-svn-id: svn://127.0.0.1/Perl/Proc-ProcessTable-Colorizer/tags/0.0.0@973 0c1c3402-1be1-de11-8092-0022686faf23
This commit is contained in:
parent
758ddb956b
commit
a4d0caa324
|
@ -1,5 +1,5 @@
|
||||||
Revision history for Proc-ProcessTable-Colorizer
|
Revision history for Proc-ProcessTable-Colorizer
|
||||||
|
|
||||||
0.01 Date/time
|
0.0.0 2017-11-06/00:00
|
||||||
First version, released on an unsuspecting world.
|
-Initial release.
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,16 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use ExtUtils::MakeMaker;
|
use ExtUtils::MakeMaker;
|
||||||
|
|
||||||
|
my %PREREQ_PM = (
|
||||||
|
'Error::Helper'=>'1.0.0',
|
||||||
|
'Proc::ProcessTable'=>'0.53',
|
||||||
|
'Term::ANSIColor'=>'4.06',
|
||||||
|
'Text::Table'=>'1.133',
|
||||||
|
);
|
||||||
|
if ( $^O =~ /bsd/ ){
|
||||||
|
$PREREQ_PM{'BSD::Process'}='0.07';
|
||||||
|
}
|
||||||
|
|
||||||
WriteMakefile(
|
WriteMakefile(
|
||||||
NAME => 'Proc::ProcessTable::Colorizer',
|
NAME => 'Proc::ProcessTable::Colorizer',
|
||||||
AUTHOR => q{Zane C. Bowers-Hadley <vvelox@vvelox.net>},
|
AUTHOR => q{Zane C. Bowers-Hadley <vvelox@vvelox.net>},
|
||||||
|
@ -11,16 +21,14 @@ WriteMakefile(
|
||||||
LICENSE => 'freebsd',
|
LICENSE => 'freebsd',
|
||||||
PL_FILES => {},
|
PL_FILES => {},
|
||||||
MIN_PERL_VERSION => '5.006',
|
MIN_PERL_VERSION => '5.006',
|
||||||
|
INST_SCRIPT => 'bin',
|
||||||
CONFIGURE_REQUIRES => {
|
CONFIGURE_REQUIRES => {
|
||||||
'ExtUtils::MakeMaker' => '0',
|
'ExtUtils::MakeMaker' => '0',
|
||||||
},
|
},
|
||||||
BUILD_REQUIRES => {
|
BUILD_REQUIRES => {
|
||||||
'Test::More' => '0',
|
'Test::More' => '0',
|
||||||
},
|
},
|
||||||
PREREQ_PM => {
|
PREREQ_PM => \%PREREQ_PM,
|
||||||
#'ABC' => '1.6',
|
|
||||||
#'Foo::Bar::Module' => '5.0401',
|
|
||||||
},
|
|
||||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||||
clean => { FILES => 'Proc-ProcessTable-Colorizer-*' },
|
clean => { FILES => 'Proc-ProcessTable-Colorizer-*' },
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
Proc-ProcessTable-Colorizer
|
Proc-ProcessTable-Colorizer
|
||||||
|
|
||||||
The README is used to introduce the module and provide instructions on
|
This colorizes the output from Proc::ProcessTable.
|
||||||
how to install the module, any machine dependencies it may have (for
|
|
||||||
example C compilers and installed libraries) and any other information
|
|
||||||
that should be provided before the module is installed.
|
|
||||||
|
|
||||||
A README file is required for CPAN modules since CPAN extracts the README
|
This is largely meant to be used from the command line instead of
|
||||||
file from a module distribution so that people browsing the archive
|
as a module via the included bin script.
|
||||||
can use it to get an idea of the module's uses. It is usually a good idea
|
|
||||||
to provide version information here so that people can decide whether
|
|
||||||
fixes for the module are worth downloading.
|
|
||||||
|
|
||||||
|
Among other fun things, it allows searching of the process table.
|
||||||
|
|
||||||
|
Searching is currently possible against the folowing criteria.
|
||||||
|
|
||||||
|
zombie
|
||||||
|
swapped out
|
||||||
|
regex command line matching
|
||||||
|
CPU seconds used by a process
|
||||||
|
percent of memory usage
|
||||||
|
percent of CPU usage
|
||||||
|
wait channel in use
|
||||||
|
|
||||||
INSTALLATION
|
INSTALLATION
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,168 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
#Copyright (c) 2017, Zane C. Bowers-Hadley
|
||||||
|
#All rights reserved.
|
||||||
|
#
|
||||||
|
#Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
#are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
#IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
#INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
#LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
#OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||||
|
#THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Getopt::Std;
|
||||||
|
use Proc::ProcessTable::Colorizer;
|
||||||
|
|
||||||
|
$Getopt::Std::STANDARD_HELP_VERSION = 1;
|
||||||
|
|
||||||
|
#print help
|
||||||
|
sub main::HELP_MESSAGE {
|
||||||
|
print "\n".
|
||||||
|
"-z Show zombies procs.\n".
|
||||||
|
"-s Show swapped out procs.\n".
|
||||||
|
"-p <regex> Search procs using the matching regex.\n".
|
||||||
|
"-u <users> A string search for users.\n".
|
||||||
|
"-t <time search> A numeric search for CPU time".
|
||||||
|
"-c <pctcpu search> A numeric search for CPU usage percent\n".
|
||||||
|
"-m <pctmem search> A numeric search for memory usage percent\n".
|
||||||
|
"-w <wait channels> A string search for wait channels.\n".
|
||||||
|
"\n".
|
||||||
|
"\n".
|
||||||
|
"String Search:\n".
|
||||||
|
"This is a comma seperated list of strings to search for.\n".
|
||||||
|
"Any items starting with ! will be inverted.\n".
|
||||||
|
"\n".
|
||||||
|
"foo Checks if it matches foo.\n".
|
||||||
|
"!foo Checks if it does not match foo.\n".
|
||||||
|
"foo,bar Checks if it matches foo or bar.\n".
|
||||||
|
"\n".
|
||||||
|
"\n".
|
||||||
|
"Numeric Search:\n".
|
||||||
|
"This is a comma seperated list of values to search for.\n".
|
||||||
|
"Each item must start with a equality. <, <=, >=, > are all recognized.\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
sub main::VERSION_MESSAGE {
|
||||||
|
print "cps v. 0.0.0\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
#gets the options
|
||||||
|
my %opts=();
|
||||||
|
getopts('p:u:zw:st:c:m:', \%opts);
|
||||||
|
|
||||||
|
|
||||||
|
use Proc::ProcessTable::Colorizer;
|
||||||
|
my $cps = Proc::ProcessTable::Colorizer->new;
|
||||||
|
$cps->procSearchSet( $opts{p} );
|
||||||
|
$cps->zombieSearchSet( $opts{z} );
|
||||||
|
$cps->swappedOutSearchSet( $opts{s} );
|
||||||
|
if ( defined( $opts{u} ) ){
|
||||||
|
$cps->userSearchSetString( $opts{u} );
|
||||||
|
}
|
||||||
|
if ( defined( $opts{w} ) ){
|
||||||
|
$cps->waitSearchSetString( $opts{w} );
|
||||||
|
}
|
||||||
|
if ( defined( $opts{t} ) ){
|
||||||
|
$cps->timeSearchSetString( $opts{t} );
|
||||||
|
if ($cps->error){
|
||||||
|
exit $cps->error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( defined( $opts{c} ) ){
|
||||||
|
$cps->pctcpuSearchSetString( $opts{c} );
|
||||||
|
if ($cps->error){
|
||||||
|
exit $cps->error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( defined( $opts{m} ) ){
|
||||||
|
$cps->pctcpuSearchSetString( $opts{m} );
|
||||||
|
if ($cps->error){
|
||||||
|
exit $cps->error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
print $cps->colorize;
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
cps - A colorized version of ps with various extra useful options.
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
cps [B<-z>] [B<-s>] [B<-p> <regex>] [B<-u> <users>] [B<-t> <time>] [B<-m> <pctmem>] [B<-c> <pctcpu>] [B<-w> <wait channels>]
|
||||||
|
|
||||||
|
=head1 USAGE
|
||||||
|
|
||||||
|
By default this prints out all processes, minus the idle process.
|
||||||
|
|
||||||
|
This may be changed via setting various switches to limit the procs shown. If more than one is specified,
|
||||||
|
only the processes matching all of them are shown.
|
||||||
|
|
||||||
|
=head1 SWITCHES
|
||||||
|
|
||||||
|
=head2 B<-z>
|
||||||
|
|
||||||
|
Only show zombie processes.
|
||||||
|
|
||||||
|
=head2 B<-s>
|
||||||
|
|
||||||
|
Show only swapped out processes.
|
||||||
|
|
||||||
|
=head2 B<-p> <regex>
|
||||||
|
|
||||||
|
The command line of the processes is matched against the provided regex.
|
||||||
|
|
||||||
|
=head2 B<-u> <users>
|
||||||
|
|
||||||
|
A string search for users.
|
||||||
|
|
||||||
|
=head2 B<-t> <time>
|
||||||
|
|
||||||
|
A numeric search based on the total amount of CPU seconds used by the processes.
|
||||||
|
|
||||||
|
=head2 B<-m> <pctmem>
|
||||||
|
|
||||||
|
A numeric search based on the percent of memory processes are using.
|
||||||
|
|
||||||
|
=head2 B<-c> <pctcpu>
|
||||||
|
|
||||||
|
A numeric search based on the percent of CPU usage a process is using.
|
||||||
|
|
||||||
|
=head2 B<-w> <wait channels>
|
||||||
|
|
||||||
|
A string search based on the wait channel a processes are using.
|
||||||
|
|
||||||
|
=head1 STRING SEARCHES
|
||||||
|
|
||||||
|
This is a comma seperated list of strings to search for.
|
||||||
|
|
||||||
|
Any items starting with ! will be inverted.
|
||||||
|
|
||||||
|
foo Checks if it matches foo.
|
||||||
|
!foo Checks if it does not match foo.
|
||||||
|
foo,bar Checks if it matches foo or bar.
|
||||||
|
|
||||||
|
=head1 NUMERIC SEARCHES
|
||||||
|
|
||||||
|
This is a comma seperated list of values to search for.
|
||||||
|
|
||||||
|
Each item must start with a equality.
|
||||||
|
|
||||||
|
<, <=, >=, > are all recognized.
|
||||||
|
|
||||||
|
=cut
|
File diff suppressed because it is too large
Load Diff
|
@ -1,57 +0,0 @@
|
||||||
#!perl -T
|
|
||||||
use 5.006;
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use Test::More;
|
|
||||||
|
|
||||||
plan tests => 3;
|
|
||||||
|
|
||||||
sub not_in_file_ok {
|
|
||||||
my ($filename, %regex) = @_;
|
|
||||||
open( my $fh, '<', $filename )
|
|
||||||
or die "couldn't open $filename for reading: $!";
|
|
||||||
|
|
||||||
my %violated;
|
|
||||||
|
|
||||||
while (my $line = <$fh>) {
|
|
||||||
while (my ($desc, $regex) = each %regex) {
|
|
||||||
if ($line =~ $regex) {
|
|
||||||
push @{$violated{$desc}||=[]}, $.;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (%violated) {
|
|
||||||
fail("$filename contains boilerplate text");
|
|
||||||
diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
|
|
||||||
} else {
|
|
||||||
pass("$filename contains no boilerplate text");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub module_boilerplate_ok {
|
|
||||||
my ($module) = @_;
|
|
||||||
not_in_file_ok($module =>
|
|
||||||
'the great new $MODULENAME' => qr/ - The great new /,
|
|
||||||
'boilerplate description' => qr/Quick summary of what the module/,
|
|
||||||
'stub function definition' => qr/function[12]/,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TODO: {
|
|
||||||
local $TODO = "Need to replace the boilerplate text";
|
|
||||||
|
|
||||||
not_in_file_ok(README =>
|
|
||||||
"The README is used..." => qr/The README is used/,
|
|
||||||
"'version information here'" => qr/to provide version information/,
|
|
||||||
);
|
|
||||||
|
|
||||||
not_in_file_ok(Changes =>
|
|
||||||
"placeholder date/time" => qr(Date/time)
|
|
||||||
);
|
|
||||||
|
|
||||||
module_boilerplate_ok('lib/Proc/ProcessTable/Colorizer.pm');
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue