How can I get unlimited information from pstree?

1

I am using pstree to watch a sequence of scripts and even when using -pla, I get shortened versions of arguments and script names. As an example:

sshd,13431
  └─bash,13432
      └─runJobs.sh,18780 ./runJobs.sh
          └─job1.sh,18781 ./job1.sh /path/to/location/of/some/file/that/I/need/to/see/file1.txt /path/to/the/location/of/some/other/file/that/I/need/to/see/file2.txt /path/to/yet/another/location/of/some/other/file/that/I/also/need/to/see/file3.txt/yet/another/long/path/to/a/4th/locatio
              └─veryLongNameFor,18782 ./veryLongNameForJob2.sh Argument1_is_very_long arg2_is_also_quite_long The_name_for_arg3_is_even_longer
                  └─sleep,18783 1000

As you can see verLongNameForJob2.sh is trimmed, I don't get the full path for /yet/another/long/path/to/a/4th/location/that/I/need/to/lookAt/file4.txt and I also get /path/to/yet/another/location/of/some/other/file/that/I/also/need/to/see/file3.txt concatenated with /yet/another/long/path/to/a/4th/location/that/I/need/to/lookAt/file4.txt. How can I get full script names along with full argument names without concatenation even if they are very long?

Below are the scripts I used for this:

runJobs.sh:

#!/bin/bash
### contents of 'runJobs.sh'

arg1=/path/to/location/of/some/file/that/I/need/to/see/file1.txt
arg2=/path/to/the/location/of/some/other/file/that/I/need/to/see/file2.txt
arg3=/path/to/yet/another/location/of/some/other/file/that/I/also/need/to/see/file3.txt
arg4=/yet/another/long/path/to/a/4th/location/that/I/need/to/lookAt/file4.txt

./job1.sh $arg1 $arg2 $arg3 $arg4

job1.sh:

#!/bin/bash
### contents of job1.sh

arg1=Argument1_is_very_long 
arg2=arg2_is_also_quite_long
arg3=The_name_for_arg3_is_even_longer

./veryLongNameForJob2.sh $arg1 $arg2 $arg3

veryLongNameForJob2.sh:

#!/bin/bash
### contents of 'veryLongNameForJob2.sh'

sleep 1000

drjrm3

Posted 2017-04-11T13:21:19.783

Reputation: 1 164

Answers

0

I replicated the issue with pstree on my Ubuntu 16.04.2 LTS. I needed way longer paths, but still.

Tools like pstree use /proc to gather information, so read /proc/<PID>/cmdline. It's a bad luck if the information is truncated there. But it may be that you hit the limit of your pstree implementation only.

In my case /proc/<PID>/cmdline was not trimmed when I crossed the limit in pstree.

Another good news is the arguments in /proc/<PID>/cmdline are separated with NULL characters (0x00).

Kamil Maciorowski

Posted 2017-04-11T13:21:19.783

Reputation: 38 429