process naming for virtualbox guest instances.

Here you can provide suggestions on how to improve the product, website, etc.
Post Reply
zuluechopapa
Posts: 2
Joined: 22. Oct 2013, 19:55

process naming for virtualbox guest instances.

Post by zuluechopapa »

I'll first apologize if this is duplicated and has been deemed unnecessary or not useful enough or some such. I did a quick, not exhaustive search of the forum and found nothing, so I thought I'd ask.

I have a few machines acting as hypervisors or host machines, or whatever you'd like to call them, they run N number of guest virtualbox (usually headless) instances. on occasion, I end up running a top and see some number of processes at or near the top, something like:

top - 15:50:56 up 2 days, 48 min, 5 users, load average: 3.54, 3.48, 3.45
Tasks: 544 total, 2 running, 542 sleeping, 0 stopped, 0 zombie
%Cpu(s): 6.1 us, 8.2 sy, 0.2 ni, 79.9 id, 4.0 wa, 0.0 hi, 1.8 si, 0.0 st
MiB Mem : 72464.8 total, 31393.6 free, 31438.3 used, 9632.9 buff/cache
MiB Swap: 20974.0 total, 20974.0 free, 0.0 used. 40106.9 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1196676 zep 20 0 9845.7m 1.0g 1.0g S 78.0 1.5 2465:35 VBoxHeadless
1237835 zep 20 0 5590468 951436 407400 S 50.5 1.3 2411:37 firefox
1309851 zep 20 0 3309604 548024 140772 S 43.6 0.7 12:13.83 Isolated Web Co
1206149 zep 20 0 3054096 186628 154164 S 6.9 0.3 314:24.59 VBoxHeadless
1217518 zep 20 0 2166796 72700 53776 S 4.9 0.1 88:19.37 VBoxHeadless
1198403 zep 20 0 6854236 495832 478808 S 4.3 0.7 454:42.78 VBoxHeadless
1209089 zep 20 0 2166796 71952 53164 S 3.0 0.1 88:28.81 VBoxHeadless
1213010 zep 20 0 2109524 552840 533956 S 2.6 0.7 62:20.50 VBoxHeadless
1215379 zep 20 0 2168412 73208 53204 S 2.0 0.1 88:35.91 VBoxHeadless
1216555 zep 20 0 2167896 73332 53452 S 2.0 0.1 88:12.20 VBoxHeadless

it'd be quite nice if those 'VBoxHeadless' processes showed up as the actual name I've given to the vm instead of needing to break out of top and run ps auxww | grep pid, etc.

or for a ... I guess bonus points option, some sort of 'advanced' feature that I could set strings/variables to include in the process name would be awesome.
e.g. set something like "VBprocname=VBH-%n-%M-%C" in the gui settings to get processes named 'VBH-(name)-(memorysize)-(numberOfCpu)' as the process name in ps, top, et al.

but beyond the ask, thanks for making a very useful virtual host tool, I've (possibly over)used it for many years.

thanks.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: process naming for virtualbox guest instances.

Post by fth0 »

Not exactly what you're asking for, but did you consider htop? Or top -c or pressing "c" while top is running?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: process naming for virtualbox guest instances.

Post by scottgus1 »

Not a Linux guru, but this sounds like a good enhancement request for a 'top' forum. The VMs are actually data files that Virtualbox runs in one of its host programs. Virtualbox doesn't have control of how top lists its command lines.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: process naming for virtualbox guest instances.

Post by fth0 »

scottgus1 wrote:Not a Linux guru, but this sounds like a good enhancement request for a 'top' forum.
Like many standard Linux commands, top doesn't need any enhancement, it's already there. Try my suggestions to see for yourself. ;)
zuluechopapa
Posts: 2
Joined: 22. Oct 2013, 19:55

Re: process naming for virtualbox guest instances.

Post by zuluechopapa »

scottgus1 wrote:Not a Linux guru, but this sounds like a good enhancement request for a 'top' forum. The VMs are actually data files that Virtualbox runs in one of its host programs. Virtualbox doesn't have control of how top lists its command lines.
I suspect top would never be able to do such a thing; it'd have no idea how to change things around/make it display and anything done specifically for virtualbox processes would be incompatible with every other process in the world.

it's entirely possible for virtualbox to change it's process name on start up; c programs are capable and have long used the ability to change their process names on startup; I believe they rewrite argv[0], but I'd have to dig around to be sure.

the top -c suggestion sort of works, although it forces expanding windows to crazy sizes and isn't really usable on fixed, non x based terminals.

it just seemed like it could be a handy sort of thing to have for more than a few people, but if nobody else has any interest or sees any value, that's fine.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: process naming for virtualbox guest instances.

Post by scottgus1 »

zuluechopapa wrote:it's entirely possible for virtualbox to change it's process name on start up
If 'top' is anything like Windows' Task Manager or Process Explorer, then it is showing the executable that runs the data file, based on the command line. Are you suggesting that Virtualbox clone & rename its executable to the VM's name for every running VM? That's about the only way I see that this could be done and fit in with the usual task managers.
javispedro
Posts: 58
Joined: 29. Jan 2022, 15:31
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: Old & New Windows, Linux

Re: process naming for virtualbox guest instances.

Post by javispedro »

scottgus1 wrote: If 'top' is anything like Windows' Task Manager or Process Explorer, then it is showing the executable that runs the data file, based on the command line. Are you suggesting that Virtualbox clone & rename its executable to the VM's name for every running VM? That's about the only way I see that this could be done and fit in with the usual task managers.
Under Linux and many related OSes there is a way to rename the "task name" that is shown in top (see PR_SET_NAME ), and that's what Firefox is doing the example above ("Isolated Web Process" is a firefox thing). There is a ridiculous 16-char limit though. I remember VirtualBox already does that for some threads (like EMT).

Therefore this is a valid feature request, just Linux specific...

The workaround suggested by fth0, top -c , will switch top from showing the task name to showing the full process command line, which in the case of VirtualBoxVM process it is likely to contain --startvm "TheVMName" or the like. So it should also allow for easy distinction of VM processes.

Now that I think of it, this is likely to be easily doable from an extpack.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: process naming for virtualbox guest instances.

Post by scottgus1 »

javispedro wrote:Under Linux and many related OSes there is a way to rename the "task name" that is shown in top (see PR_SET_NAME )
Ah, very interesting! Would have been good info in the first post, so non-Linux gurus like myself would know it's possible. FWIW the web-searching I did shows the name can only be 16 bytes max, but it apparently can be done.

Enhancement requests can be posted on the Bugtracker, and user code is considerd for inclusion. Another forum contributor has made an extension pack or two, so that's also a possibility.
Post Reply