Less known Solaris Features: Getting the command line and environment of running processes
There is a really interesting tool to gather informations from a running process. Let´s assume a fellow admin is in her or his well-deserved vacation and now you have to reboot the new machine, because you have to service the memory. Of course you look into the documentation and you find a process that isn´t covered by the documentation and there doesn´t seem to be an startup script or SMF manifest that starts this application. D’oh … yet another last-minute pre-vacation change … shouldn’t happen, but it does happen.
Let´s assume you found an process called application in the process list:
You look into the application source code (it´s a perl script, so this isn´t a problem and you see, that the application uses environment variables for config information. Now you have a problem. What are the correct settings of the environment variables? How can you gather the correct information to startup the application again. Solaris can help here with a programm called
At first let´s check the environment of the application first. It´s important to know, that you just can lookup this informations for processes you own. You need to get root privileges to see this information for other processes. Okay, the
pargs command offers the
-e switch for this task.
There is another interesting switch. You can use
pargs with the
-l switch to get the full command line that was used to start the script, albeit this isn’t that interesting, as you could get similar information with
/usr/ucb/ps -auxwwww. But with a known process id
pargs is much more comfortable.
Now you should have all informations to restart the script and -by the way- to update the documentation for the fellow admin.