Tru64 ps -o args column length

Here is an issue I recently met. One of my colleagues wrote some years ago a script to manage oracle instances. The same script is used on AIX , Tru64 and HP-UX.

The problem is with the following function when on Tru64:

function f_psg {
typeset -x UNIX95=xpg4
ps -ef -o args=" " -o pid="" -o ppid="" | egrep "${1:-^}"

The first line of the function (line 2) is used to declare and export to the environment variable UNIX95 to xpg4, in order to get the same compatibilities on every system.

On AIX and HP-UX the function is efficient in every case, but with Tru64 if you want to use “args” and some other commands (pid and ppid), the output will be truncated to 16 characters:

# ps -ef -o args|grep ora_pmon



# ps -ef -o args -o pid|grep ora_pmon

ora_pmon_BDDPRD0       6713

ora_pmon_BDDPRD0       6753

As you can see, there is no way to know if the 1st line is BDDPRD05 or BDDPRD04 on the 2nd command. The script was working, but only if your oracle instance name is less than 8 characters.

I found 2 workarounds that are compatible with my other UNIX (so the same script can be used on every system).

The first one is to increase the column default length by labeling the column (I chose 20 characters) :

ps -ef -o args=”XXXXXXXXXXXXXXXXXXXX” -o pid=”” -o ppid=””

# ps -ef -o args="XXXXXXXXXXXXXXXXXXXX" -o pid="" -o ppid=""|grep ora_pmon
ora_pmon_BDDPRD05          6713          1
ora_pmon_BDDPRD04          6753          1

The second is the use arfgs at the end, so no limitation of 16 characters, the with awk I put the columns in the right order:

ps -ef  -o pid=”” -o ppid=”” -o args|awk ‘{print $3″\t”$1″\t”$2}’

# ps -ef  -o pid="" -o ppid="" -o args|awk '{print $3"\t"$1"\t"$2}' |grep ora_pmon
ora_pmon_BDDPRD05       6713    1
ora_pmon_BDDPRD04       6753    1

If you happen to know a easier way please post a comment.