add support for Linux environ

This commit is contained in:
Zane C. B-H 2019-09-03 23:46:09 -05:00
parent 674a591744
commit 935d8912da
3 changed files with 65 additions and 17 deletions

View File

@ -6,7 +6,7 @@ use Getopt::Long;
use Proc::ProcessTable::piddler;
sub version{
print "piddler v. 0.1.0\n";
print "piddler v. 0.2.0\n";
}
sub help{
@ -17,15 +17,16 @@ sub help{
-v Print the version info.
--version Print the version info.
-a Do show a_inodes.
-a Show a_inodes.
-d Do not dedup.
-f Do show FIFOs.
-f Show FIFOs.
-m Show memory mapped libraries of the REG type.
-n Do not resolve PTR addresses.
--nc Disable color.
-p Do show pipes.
-r Do show show VREG / files.
-t Do show shared libraries.
-u Do show unix sockets.
-p Show pipes.
-r Show show VREG / files.
-t Show shared libraries.
-u Show unix sockets.
';
}
@ -41,6 +42,7 @@ my $dont_resolv=0;
my $no_color=0;
my $a_inode=0;
my $fifo=0;
my $memreglib=0;
# get the commandline options
Getopt::Long::Configure ('no_ignore_case');
@ -59,6 +61,7 @@ GetOptions(
'nc' => \$no_color,
'f' => \$fifo,
'a' => \$a_inode,
'm' => \$memreglib,
);
# print the version info if requested
@ -102,6 +105,18 @@ if ( defined( $ENV{PIDDLER_pipe} ) ){
if ( defined( $ENV{PIDDLER_vregroot} ) ){
$vregroot = $vregroot ^ $ENV{PIDDLER_vregroot};
}
# XOR the -m if needed
if ( defined( $ENV{PIDDLER_memreglib} ) ){
$memreglib = $memreglib ^ $ENV{PIDDLER_memreglib};
}
# XOR the -a if needed
if ( defined( $ENV{PIDDLER_a_inode} ) ){
$a_inode = $a_inode ^ $ENV{PIDDLER_a_inode};
}
# XOR the -f if needed
if ( defined( $ENV{PIDDLER_fifo} ) ){
$fifo = $fifo ^ $ENV{PIDDLER_fifo};
}
# XOR the -d if needed
if ( defined( $ENV{PIDDLER_dont_dedup} ) ){
$dont_dedup = $dont_dedup ^ $ENV{PIDDLER_dont_dedup};
@ -130,6 +145,7 @@ my $ppp=Proc::ProcessTable::piddler->new(
vregroot=>$vregroot,
dont_dedup=>$dont_dedup,
dont_resolv=>$dont_resolv,
memreglib=>$memreglib,
}
);
@ -142,14 +158,26 @@ piddler - Display all process table, open files, and network connections for a P
=head1 SYNOPSIS
piddler [B<-d>] [B<-n>] [B<-p>] [B<-r>] [B<-r>] [B<-t>] [B<-u>]
piddler [B<-a>] [B<-d>] [B<-f>] [B<-m>] [B<-n>] [B<-p>] [B<-r>] [B<-r>] [B<-t>] [B<-u>]
=head1 FLAGS
=head2 -a
Show a_inodes.
=head2 -d
Do not dedup.
=head2 -f
Show FIFOs.
=head2 -m
Show memory mapped libraries of the REG type.
=head2 -n
Do not resolve PTR addresses
@ -160,19 +188,19 @@ Disable color..
=head2 -p
Do not show pipes.
Show pipes.
=head2 -r
Do not show show VREG / files.
Show show VREG / files.
=head2 -t
Do not show shared libraries.
Show shared libraries.
=head2 -u
Do not show unix sockets.
Show unix sockets.
=head1 ENVIROMENTAL VARIABLES
@ -183,9 +211,21 @@ flags.
If set to 1, color will be disabled.
=head2 PIDDLER_a_inode
If set to 1, a_inode types will be shown.
=head2 PIDDLER_fifo
If set to 1, FIFOs will not be shown.
=head2 PIDDLER_memreglib
If set to 1, memory mapped libraries with the type REG will be shown.
=head2 PIDDLER_txt
If set to 1, libraries will not be shown.
If set to 1, libraries with the TXT type will not be shown.
=head2 PIDDLER_pipe

View File

@ -16,11 +16,11 @@ Proc::ProcessTable::piddler - Display all process table, open files, and network
=head1 VERSION
Version 0.1.0
Version 0.2.0
=cut
our $VERSION = '0.1.0';
our $VERSION = '0.2.0';
=head1 SYNOPSIS
@ -195,6 +195,7 @@ sub new{
'BRIGHT_MAGENTA',
'BRIGHT_BLUE'
],
envrion=>'BRIGHT_MAGENTA',
txt=>0,
pipe=>0,
unix=>0,
@ -209,7 +210,7 @@ sub new{
my @arg_feed=(
'txt', 'pipe', 'unix', 'vregroot', 'dont_dedup', 'dont_resolv',
'fifo', 'a_inore'
'fifo', 'a_inore', 'memreglib'
);
foreach my $feed ( @arg_feed ){
@ -445,6 +446,13 @@ sub run{
$value=$self->timeString( $proc->{$key} );
}
if ( $key =~ /^environ$/ ){
$value=join( color( $self->{envrion} ).','.color('reset') , @{ $proc->{envrion} } );
if ( !defined( $value ) ){
$value='';
}
}
if (
( $key =~ /flt$/ ) &&
( $proc->{$key} eq 0 ) &&

View File

@ -26,7 +26,7 @@ Unless set to defined ands set to 1, these will default to 0.
| Variable | Description |
| -------- | ---------------- |
| NO_COLOR | If set to 1, color will be disabled. |
| PIDDLER_txt | If set to 1, libraries will not be shown. |
| PIDDLER_txt | If set to 1, libraries with the TXT type will not be shown. |
| PIDDLER_pipe | If set to 1, pipes will not be shown. |
| PIDDLER_unix | If set to 1, unix socket will not be shown. |
| PIDDLER_vregroot | If set to 1, VREG / will not be shown. |