How to avoid truncating in ps output ?

Hello,
This is Solaris 10 (x86)

bash-3.2# cat /etc/release
                        Solaris 10 5/09 s10x_u7wos_08 X86
           Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                             Assembled 30 March 2009
bash-3.2#

I am not able to figure out, how to avoid trucating in ps output. I want full path, but is is cutting lines in the last. Even if I redirect output to a file, it is same.
I tried multiple ways, but still same

bash-3.2# /usr/ucb/ps -wwwwwaux | grep syslog-ng | egrep -v grep
root     13862  1.6  0.1 8420 4388 ?        S   Apr 11 330:37 /usr/local/sbin/syslog-ng --cfgfile /logs/c720/syslog-ng.conf --pidfile /var/ru
root     21187  0.1  0.1 7756 3728 ?        S   Apr 13 100:51 /usr/local/sbin/syslog-ng --cfgfile /logs/neteng/syslog-ng.conf --pidfile /var/
root      4804  0.0  0.0 6404 1432 ?        S   Apr 25  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root      4805  0.0  0.0 6404 1432 ?        S   Apr 25  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/test/syslog-ng.conf --pidfile /var/ru
root      4806  0.0  0.1 6800 2812 ?        S   Apr 25  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root      4807  0.0  0.1 6828 2796 ?        S   Apr 25  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/test/syslog-ng.conf --pidfile /var/ru
root     10595  0.0  0.0 6404 1432 ?        S   Sep 24  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root     10596  0.0  0.1 8376 4380 ?        S   Sep 24  0:08 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root     13844  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/nss/syslog-ng.conf --pidfile /var/run
root     13845  0.0  0.1 8212 4184 ?        S   Apr 11  0:02 /usr/local/sbin/syslog-ng --cfgfile /logs/nss/syslog-ng.conf --pidfile /var/run
root     13858  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/lbs/syslog-ng.conf --pidfile /var/run
root     13859  0.0  0.1 8228 4200 ?        S   Apr 11  0:02 /usr/local/sbin/syslog-ng --cfgfile /logs/lbs/syslog-ng.conf --pidfile /var/run
root     13861  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/c720/syslog-ng.conf --pidfile /var/ru
root     13894  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/sbsd/syslog-ng.conf --pidfile /var/ru
root     13896  0.0  0.1 8428 4380 ?        S   Apr 11  1:15 /usr/local/sbin/syslog-ng --cfgfile /logs/sbsd/syslog-ng.conf --pidfile /var/ru
root     13897  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/v720/syslog-ng.conf --pidfile /var/ru
root     13898  0.0  0.1 8332 4304 ?        S   Apr 11  1:14 /usr/local/sbin/syslog-ng --cfgfile /logs/v720/syslog-ng.conf --pidfile /var/ru
root     13906  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/wks/syslog-ng.conf --pidfile /var/run
root     13907  0.0  0.1 8228 4200 ?        S   Apr 11  0:02 /usr/local/sbin/syslog-ng --cfgfile /logs/wks/syslog-ng.conf --pidfile /var/run
root     13936  0.0  0.0 6404 1432 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root     13937  0.0  0.1 6864 2876 ?        S   Apr 11  0:00 /usr/local/sbin/syslog-ng --cfgfile /etc/syslog-ng.conf --pidfile /var/run/sysl
root     18153  0.0  0.0 6404 1432 ?        S   Jul 18  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/ng720/syslog-ng.conf --pidfile /var/r
root     18154  0.0  0.23867634604 ?        S   Jul 18  9:46 /usr/local/sbin/syslog-ng --cfgfile /logs/ng720/syslog-ng.conf --pidfile /var/r
root     21186  0.0  0.0 6404 1432 ?        S   Apr 13  0:00 /usr/local/sbin/syslog-ng --cfgfile /logs/neteng/syslog-ng.conf --pidfile /var/
bash-3.2# which ps
/usr/bin/ps
bash-3.2# /usr/bin/ps -wwwwwaux | grep syslog-ng | egrep -v grep
/usr/bin/ps: illegal option -- w
/usr/bin/ps: illegal option -- w
/usr/bin/ps: illegal option -- w
/usr/bin/ps: illegal option -- w
/usr/bin/ps: illegal option -- w
usage: ps [ -aAdeflcjLPyZ ] [ -o format ] [ -t termlist ]
        [ -u userlist ] [ -U userlist ] [ -G grouplist ]
        [ -p proclist ] [ -g pgrplist ] [ -s sidlist ] [ -z zonelist ]
  'format' is one or more of:
        user ruser group rgroup uid ruid gid rgid pid ppid pgid sid taskid ctid
        pri opri pcpu pmem vsz rss osz nice class time etime stime zone zoneid
        f s c lwp nlwp psr tty addr wchan fname comm args projid project pset
bash-3.2#

Please suggest the correct way

Not too familiar with Solaris, I would have had proposed to make use of ( man ps ):

BUT I'm afraid you're out of luck in that special case:

which is exactly the length of your output fields...

In Solaris the public args, as shown with /usr/bin/ps, are truncated after 80 characters.
The full args are stored in the process environment.
/usr/ucb/ps wwwaux tries to access the full args of each process. It should succeed if you own the process or if you are root.
This is a bit slowish though.

The recommended way is to use /usr/bin/ps and then pargs to only dig out the full args if needed.

/usr/bin/ps -eo pid= -o comm= | awk '$2~/syslog-ng/ { print $1 }' | xargs -l pargs

or

/usr/bin/ps -eo pid= -o args= | awk '$2~/syslog[-]ng/ { print $1 }' | xargs -l pargs

In the latter the own arguments must be excluded from args, most elegant by using a [ ] character set in the regular expression.

2 Likes

Seems like, this also doesn't work. Am I running it correctly ?

bash-3.2# /usr/ucb/ps wwwaux | grep syslog-ng | egrep -v grep | head -2
root     13862  0.3  0.1 8428 4528 ?        S   Apr 11 337:37 /usr/local/sbin/syslog-ng --cfgfile /logs/c911/syslog-ng.conf --pidfile /var/ru
root     21187  0.1  0.1 7764 3868 ?        S   Apr 13 101:39 /usr/local/sbin/syslog-ng --cfgfile /logs/neteng/syslog-ng.conf --pidfile /var/
bash-3.2#
bash-3.2# /usr/bin/ps -eo pid= -o comm= | awk '$2~/syslog-ng/ { print $1 }' | xargs -l pargs | head
13897:  /usr/local/sbin/syslog-ng --cfgfile /logs/v911/syslog-ng.conf --pidfile /var/ru
argv[0]: supervising syslog-ng
argv[1]: <NULL>
argv[2]: <NULL>
argv[3]: <NULL>
argv[4]: <NULL>
13859:  /usr/local/sbin/syslog-ng --cfgfile /logs/lbs/syslog-ng.conf --pidfile /var/run
argv[0]: /usr/local/sbin/syslog-ng
argv[1]: <NULL>
argv[2]: <NULL>
xargs: Child killed with signal 13
bash-3.2#
bash-3.2# /usr/bin/ps -eo pid= -o args= | awk '$2~/syslog[-]ng/ { print $1 }' | xargs -l pargs | head
13897:  /usr/local/sbin/syslog-ng --cfgfile /logs/v911/syslog-ng.conf --pidfile /var/ru
argv[0]: supervising syslog-ng
argv[1]: <NULL>
argv[2]: <NULL>
argv[3]: <NULL>
argv[4]: <NULL>
13859:  /usr/local/sbin/syslog-ng --cfgfile /logs/lbs/syslog-ng.conf --pidfile /var/run
argv[0]: /usr/local/sbin/syslog-ng
argv[1]: <NULL>
argv[2]: <NULL>
xargs: Child killed with signal 13
bash-3.2#

It seems syslog-ng overwrote/cleared its arguments array. You are out of luck.

You might use a dtrace script to intercept the arguments when the commands are exec'd and log them to a file.

2 Likes

Yes, I will go alternate way.
Thanks you all. I will mark this thread as solved.