Zane C. Bowers-Hadley

NAME

Proc::ProcessTable::Colorizer - Like ps, but with colored columns and enhnaced functions for searching.

VERSION

Version 0.4.0

SYNOPSIS

    use Proc::ProcessTable::Colorizer;

    my $cps = Proc::ProcessTable::Colorizer->new;
    print $cps->colorize;

This module uses Error::Helper for error reporting.

As of right now this module is not really user friend and will likely be going through lots of changes as it grows.

METHODS

new

Creates a new object. This method will never error.

    my $cps=Proc::ProcessTable::Colorizer->new;

colorize

This colorizes it and returns a setup Text::Table object with everything already setup.

    use Proc::ProcessTable::Colorizer;
    my $cps = Proc::ProcessTable::Colorizer->new;
    print $cps->colorize;

fields

Gets a hash of possible fields from Proc::ProcessTable as an hash.

This is really meant as a internal function.

fieldsGet

Gets the currently set fields.

Returns a array ref of current fields to be printed.

    my $fields=$cps->fieldsGet;

nextColor

Returns the next color.

    my $nextColor=$cps->nextColor;

nextColor

Resets the next color to the first one.

    my $nextColor=$cps->nextColor;

fieldsSet

Gets the currently set fields.

Returns a list of current fields to be printed.

    my @fields=$cps->fieldsGet;

pctcpuSearchGet

Returns the current value for the PCT CPU search.

The return is a array ref.

    my $pctcpu_search=$cps->pctcpuSearchGet;

pctcpuSearchSetString

Search for procs based on the CPU usage.

The following equalities are understood.

    <=
    <
    >
    >=

The string may contain multiple values seperated by a comma. Checking will stop after the first hit.

If the string is undef, all procs will be shown.

    #search for procs with less than 60% of CPU usage
    $cps->pctcpuSearchSetString('<60');
    #shows procs with greater than 60% of CPU usage
    $cps->pctcpuSearchSetString('>60');

pctmemSearchGet

Returns the current value for the PCT MEM search.

The return is a array ref.

    my $pctmem_search=$cps->pctmemSearchGet;

pctmemSearchSetString

Search for procs based on the memory usage.

The following equalities are understood.

    <=
    <
    >
    >=

The string may contain multiple values seperated by a comma. Checking will stop after the first hit.

If the string is undef, all procs will be shown.

    #search for procs with less than 60% of the memory
    $cps->pctmemSearchSetString('<60');
    #shows procs with greater than 60% of the memory
    $cps->pctmemSearchSetString('>60');

processColorGet

    my $timeColors=$cps->processColorGet;

procSearchGet

This returns the search string value that will be used for matching the proc column.

The return is undefined if one is not set.

    my $search_regex=$cps->procSearchGet;
    if ( defined( $search_regex ) ){
        print "search regex: ".$search_regex."\n";
    }else{
        print "No search regex.\n";
    }

procSearchSet

This sets the proc column search regex to use.

If set to undef(the default), then it will show all procs.

    #shows everything
    $cps->procSearchSet( undef );

    #search for only those matching musicpd
    $cps->procSeearchSet( 'musicpd' );

    #search for those that match /[Zz]whatever/
    $cps->procSearchSet( '[Zz]whatever' );

selfIgnoreGet

selfIgnoreSet

Wether or not to show the PID of this processes in the list.

undef

Resets it to the default, 2.

0

Always show self PID in the list.

1

Never show self PID in the list.

2

Don't show self PID if it is a search.

This is the default.

startString

Generates a short time string based on the supplied unix time.

swappedOutSearchGet

Returns the current value for the swapped out search.

The return is a Perl boolean.

    my $swappedOut_search=$cps->swappedOutSearchGet;
    if ( $swappedOut_search ){
        print "only swapped out procs will be shown";
    }

swappedOutSearchSet

Sets the swapped out search value.

The value taken is a Perl boolean.

    $cps->swappedOutSearchSet( 1 );

timeColorsGet

    my $timeColors=$cps->timeColorsGet;

timeSearchGet

Returns the current value for the time search.

The return is a array ref.

    my $time_search=$cps->waitSearchGet;

timeSearchSetString

Search for procs based on the CPU time value.

The following equalities are understood.

    <=
    <
    >
    >=

The string may contain multiple values seperated by a comma. Checking will stop after the first hit.

If the string is undef, all wait channels will be shown.

    #search for procs with less than 60 seconds of CPU time
    $cps->waitSearchSetString('<69');
    #shows procs with less than 60 seconds and greater 120 seconds
    $cps->waitSearchSetString('<60,>120');

timeString

Turns the raw run string into something usable.

This returns a colorized item.

    my $time=$cps->timeString( $seconds );

userSearchGet

This gets the user to be searched for and if it should be inverted or not.

This returns an array reference of users to search for.

An selection can be inverted via !.

    my $user_search=$cps->userSearchGet;

userSearchSetString

This takes a string to set the user search for.

An selection can be inverted via !.

The string may contain multiple users seperated by a comma.

If the string is undef, all users will be shown.

    #search for user foo and bar
    $cps->userSearchSetString('foo,bar');
    #show users not matching foo
    $cps->userSearchSetString('!foo');
    #show all users, clearing any previous settings
    $cps->userSearchSetString;

waitSearchGet

Returns the current value for the wait search.

The return is a array ref.

    my $wait_search=$cps->waitSearchGet;

waitSearchSetString

This takes a string to set the wait channel search for.

An selection can be inverted via !.

The string may contain multiple users seperated by a comma.

If the string is undef, all wait channels will be shown.

    #search for wait channel wait and sleep
    $cps->waitSearchSetString('wait,sleep');
    #shows wait channels not matching sbwait
    $cps->waitSearchSetString('!sbwait');
    #show all users, clearing any previous settings
    $cps->waitSearchSetString;

zombieSearchGet

Returns the current value for the zombie search.

The return is a Perl boolean.

    my $zombie_search=$cps->zombieSearchGet;
    if ( $zombie_search ){
        print "only zombie procs will be shown";
    }

zombieSearchSet

Sets the zombie search value.

The value taken is a Perl boolean.

    $cps->zombieSearchSet( 1 );

COLORS

These corresponds to Term::ANSIColor colors.

Time

The color column is not a single color, but multiple depending on the amount of time.

The default is as below.

    'GREEN', seconds
    'BRIGHT_GREEN', minutes
    'RED', hours
    'BRIGHT_RED', 10+ hours

Columns

The non-proc/time columns are colored in a rotating color sequence.

The default is as below.

    BRIGHT_YELLOW
    BRIGHT_CYAN
    BRIGHT_MAGENTA
    BRIGHT_BLUE

ERROR CODES/FLAGS

1 / badTimeString

The time search string contains errors.

2 / badPctcpuString

The PCT CPU search string contains errors.

3 / badPctmemString

The PCT MEM search string contains errors.

AUTHOR

Zane C. Bowers-Hadley, <vvelox at vvelox.net>

BUGS

Please report any bugs or feature requests to bug-proc-processtable-colorizer at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Proc-ProcessTable-Colorizer. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Proc::ProcessTable::Colorizer

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2017 Zane C. Bowers-Hadley.

This program is distributed under the (Simplified) BSD License: http://www.opensource.org/licenses/BSD-2-Clause

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.