Browse Source

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
0.0.0
Zane C. B-H 4 years ago
parent
commit
a4d0caa324
  1. 4
      Proc-ProcessTable-Colorizer/Changes
  2. 16
      Proc-ProcessTable-Colorizer/Makefile.PL
  3. 23
      Proc-ProcessTable-Colorizer/README
  4. 168
      Proc-ProcessTable-Colorizer/bin/cps
  5. 1572
      Proc-ProcessTable-Colorizer/lib/Proc/ProcessTable/Colorizer.pm
  6. 57
      Proc-ProcessTable-Colorizer/xt/boilerplate.t

4
Proc-ProcessTable-Colorizer/Changes

@ -1,5 +1,5 @@
Revision history for Proc-ProcessTable-Colorizer
0.01 Date/time
First version, released on an unsuspecting world.
0.0.0 2017-11-06/00:00
-Initial release.

16
Proc-ProcessTable-Colorizer/Makefile.PL

@ -3,6 +3,16 @@ use strict;
use warnings;
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(
NAME => 'Proc::ProcessTable::Colorizer',
AUTHOR => q{Zane C. Bowers-Hadley <vvelox@vvelox.net>},
@ -11,16 +21,14 @@ WriteMakefile(
LICENSE => 'freebsd',
PL_FILES => {},
MIN_PERL_VERSION => '5.006',
INST_SCRIPT => 'bin',
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '0',
},
BUILD_REQUIRES => {
'Test::More' => '0',
},
PREREQ_PM => {
#'ABC' => '1.6',
#'Foo::Bar::Module' => '5.0401',
},
PREREQ_PM => \%PREREQ_PM,
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Proc-ProcessTable-Colorizer-*' },
);

23
Proc-ProcessTable-Colorizer/README

@ -1,16 +1,21 @@
Proc-ProcessTable-Colorizer
The README is used to introduce the module and provide instructions on
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.
This colorizes the output from Proc::ProcessTable.
A README file is required for CPAN modules since CPAN extracts the README
file from a module distribution so that people browsing the archive
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.
This is largely meant to be used from the command line instead of
as a module via the included bin script.
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

168
Proc-ProcessTable-Colorizer/bin/cps

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

1572
Proc-ProcessTable-Colorizer/lib/Proc/ProcessTable/Colorizer.pm
File diff suppressed because it is too large
View File

57
Proc-ProcessTable-Colorizer/xt/boilerplate.t

@ -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…
Cancel
Save