Linux – Is it possible to change the cmdline of a running process (to more easily identify it in top, for example)

command-line-interfacelinuxprocesstop

I run a number of linux servers with VMware Server 2. When their response time is not so hot or the load average goes up, I open up top to see what's going on, or for our production servers I have top open all day long. The issue is, the cmdline of vmware-vmx processes is really long, for example:

/usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;version=2.0.2;buildnumber=203138;licensename=VMware GSX Server for Linux;licenseversion=3.0 build-203138; -@ pipe=/tmp/vmhsdaemon-0/vmxaf9a31943e9065f0;readyEvent=55 /var/lib/vmware/Virtual Machines/Kyle.vmwarevm/Kyle.vmx

So in top all I see is:

 4135 root      20   0  593m 324m 289m S   21  4.2   3038:04 /usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;
 4106 root      10 -10  997m 399m 346m S    9  5.1   1135:25 /usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;
 4074 root      20   0  833m 110m  97m S    2  1.4 722:19.38 /usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;

In VMWare Server 1, each VM would run as it's own user so I could easily tell which one was which. Not so with VMWare Server 2. In lieu of buying a really wide monitor or a triple monitor setup, is there any way I can alter the cmdline of these running processes so I can easily identify which one's which? I know the processes can alter the cmdline of themselves… and I can read (but not write to) /proc/nnn/cmdline

Is there any way (as root) to alter the cmdline of a running process?

Best Answer

Although probably noone is going to use VMWare Server any more, this problem would arise with other processes as well. You really should look at htop instead, it allows for side-scrolling to read the entire command line and displays process trees:

http://htop.sourceforge.net/htop-1.0-screenshot.png

As for your question, changing the command line of a process which is runnnig already is likely to be possible only by overwriting data at the memory address of its ARGV[0]. To my knowledge, no tool is yet available which just would do changecmdline 4652 "foo process". Further discussion: http://stupefydeveloper.blogspot.de/2008/10/linux-change-process-name.html