Proc-ProcessTable-ncps

 view release on metacpan or  search on metacpan

lib/Proc/ProcessTable/ncps.pm  view on Meta::CPAN

		if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
		$tb->set_column_style($header_int, pad => $padding ); $header_int++;
	}
	# add children major faults if needed
	if ( $self->{cmajor_faults} ){
		push( @headers, 'cMajF' );
		if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
		$tb->set_column_style($header_int, pad => $padding ); $header_int++;
	}
	# add children minor faults if needed
	if ( $self->{cminor_faults} ){
		push( @headers, 'cminF' );
		if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
		$tb->set_column_style($header_int, pad => $padding ); $header_int++;
	}
	# add children minor faults if needed
	if ( $self->{numthr} ){
		push( @headers, 'Thr' );
		if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
		$tb->set_column_style($header_int, pad => $padding ); $header_int++;
	}
	# add children minor faults if needed
	if ( $self->{tty} ){
		push( @headers, 'TTY' );
		if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
		$tb->set_column_style($header_int, pad => $padding ); $header_int++;
	}
	# add jail ID if needed
	if ( $self->{jid} ){
		push( @headers, 'JID' );
		if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
		$tb->set_column_style($header_int, pad => $padding ); $header_int++;
	}
	if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
	$tb->set_column_style($header_int, pad => $padding ); $header_int++;
	push( @headers, 'Start' );
	if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
	$tb->set_column_style($header_int, pad => $padding ); $header_int++;
	push( @headers, 'Time' );
	if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
	$tb->set_column_style($header_int, pad => $padding ); $header_int++;
	push( @headers, 'Command' );
	if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
	$tb->set_column_style($header_int, pad => $padding, formats=>[[wrap => {ansi=>1, mb=>1}]]);

	$tb->columns( \@headers );

	my @stats_rss;
	my @stats_vsz;
	my @stats_time;
	my @stats_pctcpu;
	my @stats_pctmem;

	my @td;
	foreach my $proc ( @{ $procs } ) {
		my @new_line;

		#
		# handle username column
		#
		my $user=getpwuid($proc->{uid});
		if ( ! defined( $user ) ) {
			$user=$proc->{uid};
		}
		$user=color($self->nextColor).$user.color('reset');
		push( @new_line, $user );

		#
		# handles the PID
		#
		push( @new_line,  color($self->nextColor).$proc->{pid}.color('reset') );

		#
		# handles the %CPU
		#
		push( @new_line,  color($self->nextColor).$proc->{pctcpu}.color('reset') );
		if ( $self->{stats} ){ push( @stats_pctcpu, $proc->{pctcpu} ); }

		#
		# handles the %MEM
		#
		if ( $^O =~ /bsd/ ) {
			my $mem=(($proc->{rssize} * 1024 * 4 ) / $physmem) * 100;
			push( @new_line,  color($self->nextColor).sprintf('%.2f', $mem).color('reset') );
			if ( $self->{stats} ){ push( @stats_pctmem, $mem ); }
		} else {
			push( @new_line,  color($self->nextColor).sprintf('%.2f', $proc->{pctmem}).color('reset') );
			if ( $self->{stats} ){ push( @stats_pctmem, $proc->{pctmem} ); }
		}

		#
		# handles VSZ
		#
		push( @new_line,  $self->memString( $proc->{size}, 'vsz') );
		if ( $self->{stats} ){ push( @stats_vsz, $proc->{size} ); }

		#
		# handles the rss
		#
		push( @new_line, $self->memString( $proc->{rss}, 'rss')  );
		if ( $self->{stats} ){ push( @stats_rss, $proc->{rss} ); }

		#
		# handles the info
		#
		my $is = Proc::ProcessTable::InfoString->new({
													  flags_color=>$self->nextColor,
													  wchan_color=>$self->nextColor,
													 });
		push( @new_line, $is->info( $proc ) );

		#
		# handle the nice column
		#
		if ( $have_nice ) {
			push( @new_line, color($self->nextColor).$proc->{nice}.color('reset') );
		}

		#
		# handle the priority column
		#



( run in 0.503 second using v1.01-cache-2.11-cpan-d7f47b0818f )