NAME

Proc::ProcessTable::InfoString - Creates a PS like stat string showing a symbolic representation of various flags/state as well as the wchan.

VERSION

Version 0.2.0

SYNOPSIS

use Proc::ProcessTable::InfoString;
use Proc::ProcessTable;

my $is = Proc::ProcessTable::InfoString->new();

my $p = Proc::ProcessTable->new( 'cache_ttys' => 1 );
my $pt = $p->table;

foreach my $proc ( @{ $pt } ){
    print $proc->pid.' '.$is->info( $proc )."\n";
}

The mapping for the left side of the output is as below.

States  Description
Z       Zombie
S       Sleep
W       Wait
R       Run
T       Stopped
t       Tracing stop
I       Idle
L       Blocked on a kernel lock
D       Uninterruptible sleep
X       Dead
K       Wakekill
P       Parked
?       Unknown state

Flags   Description
O       Swapped Output
E       Exiting
s       Session Leader
L       POSIX lock advisory
+       has controlling terminal
c       controlling tty is active
X       traced by a debugger
F       being forked

Flag support varies by OS, being limited by what Proc::ProcessTable reports there.

OS                    Flags
FreeBSD, MidnightBSD  O, E, s, L, +, c, F, X
Linux, GNU/kFreeBSD   O, E, s, +, F, X
OpenBSD               O, s, +
NetBSD, DragonFly     s, +
anything else         O

On NetBSD and DragonFly, both of which use a procfs based implementation, Proc::ProcessTable does not report a state, the state field holding the wait channel instead, so the state always shows as ?. Those two also do not report resident memory, so there is no swapped out flag. OpenBSD for its part reports no wait channel.

"proc_infostring_describe" returns the above as a printable description tailored to the OS in question, meant for use in help output.

use Proc::ProcessTable::InfoString qw(proc_infostring_describe);

print proc_infostring_describe();

METHODS

new

This initiates the object.

One argument is taken and that is an optional hash reference.

args hash

The values below are color names to be passed to the color function of Term::ANSIColor.

If a color is not specified, no ANSI color codes are used for that section. When a color is used, that section of the string is terminated by an ANSI color reset.

flags_color

The color to use for the flags section of the string.

wchan_color

The color to use for the wait channel section of the string.

info

Creates the info string for a process.

One argument is taken and that is a Proc::ProcessTable::Process object, as found in the table returned by Proc::ProcessTable.

If the passed value is undefined or not a Proc::ProcessTable::Process object, an empty string is returned.

print $proc->pid.' '.$is->info( $proc )."\n";

FUNCTIONS

proc_infostring_describe

Returns a human readable description of what the various parts of the info string mean. Meant for use by programs wanting to print a explanation of the info string as part of their help output.

This is a plain function and does not require calling "new" first. It may be optionally imported.

use Proc::ProcessTable::InfoString qw(proc_infostring_describe);

print proc_infostring_describe();

Or called without importing it.

print Proc::ProcessTable::InfoString::proc_infostring_describe();

The states and flags described are the ones this module is able to figure out for the OS in question, so what is printed for FreeBSD differs from what is printed for Linux, OpenBSD, NetBSD, or DragonFly.

args

Args are taken as a plain hash.

os

The OS to describe the info string for. If not specified, the OS perl is currently running on, $^O, is used.

print proc_infostring_describe( os => 'linux' );

AUTHOR

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

BUGS

Please report any bugs or feature requests to bug-proc-processtable-infostring at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Proc-ProcessTable-InfoString. 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::InfoString

You can also look for information at:

LICENSE AND COPYRIGHT

This software is Copyright (c) 2019 by Zane C. Bowers-Hadley.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)