WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Uncategorized / How to obtain GID and LWID from esxtop?

How to obtain GID and LWID from esxtop?

11.20.2010 by William Lam // 11 Comments

Last week I remember seeing a tweet from Duncan Epping regarding the use of VMware vsish to obtain the VMX Cartel ID, also known as the LWID (Leader World Id) for a virtual machine world. This VMX Cartel ID is then used to obtain the GID (Group Id) which was documented by Duncan on his esxtop page to limit the view in esxtop to a particular VM of interest:

VMWID=`vm-support -x | grep |awk '{gsub("wid=", "");print $1}'`
VMXCARTEL=`vsish -e cat /vm/$VMWID/vmxCartelID`
vsish -e cat /sched/memClients/$VMXCARTEL/SchedGroupID

As you can see from the above, Duncan utilizes the vm-support to obtain the WID (World ID) and then using vsish to query for the VMX Cartel ID (LWID). Finally, using LWID, he was able to obtain the GID (Group ID). This example only applies to ESXi, since classic ESX does not include vsish tool.

Here is an example of where to locate the values in esxtop under CPU section:

I remember during some of my skunk work adventures, there were other methods of obtaining these IDs. Due to my VCAP-DCD cramming last week, I did not get a change to further investigate. Now that I have some time, I thought share some of these other methods for obtaining the GID and LWID in both ESX and ESXi.

ESXi

Obtaining VMX Cartel ID (LWID)

vmdumper - This will list all running VMs including the path to the .vmx configuration file, the display name of your VM and the VMX Cartel ID

~ # /sbin/vmdumper -l
wid=16881 pid=-1 cfgFile="/vmfs/volumes/4cdeeb09-1ad4c18a-5ff9-003048d9586a/scofield/scofield.vmx" uuid="42 34 e6 bc f1 83 c2 db-fb fb 08 73 b7 0c 26 40" displayName="scofield" vmxCartelID=16880

ps - The VMX Cartel ID is actually both the PID and CID within process status in ESXi

~ # ps -Cc | grep "scofield" | grep -v grep | awk '{print $2}'
16880

vscsiStats - The VMX Cartel ID is also used in identifying the VMs when displaying vscsi information

~ # /sbin/vscsiStats -l | grep "scofield" | awk '{print $4}' | sed 's/,//g'
16880

esxcli - You can obtain pretty much the same information as in vmdumper using the new "vm" option in esxcli

~ # /sbin/esxcli vms vm list | grep -A3 "scofield" | grep Cartel | awk '{gsub("VMX Cartel ID:", "");print $1}'
16880

Obtaining GID

Method1 - Using vscsiStats and esxcfg-info to extract VM's GID

~ # VM_NAME=scofield;VMX_CARTEL=$(/sbin/vscsiStats -l | grep "${VM_NAME}" | awk '{print $4}' | sed 's/,//g');esxcfg-info -r -F perl > /tmp/esxcfg-info.txt;grep -B1 "vm.${VMX_CARTEL}" /tmp/esxcfg-info.txt | head -1 | awk '{print $3}' | sed 's/,//g'
4639

Method2 - Using esxcli and esxcfg-info to extract VM's GID

~ # VM_NAME=scofield;VMX_CARTEL=$(/sbin/esxcli vms vm list | grep -A3 ${VM_NAME} | grep Cartel | awk '{gsub("VMX Cartel ID:", "");print $1}');esxcfg-info -r -F perl > /tmp/esxcfg-info.txt;grep -B1 "vm.${VMX_CARTEL}" /tmp/esxcfg-info.txt | head -1 | awk '{print $3}' | sed 's/,//g'
4639

Method3 - Using esxcli and vsish to extract VM's GID

~ # VM_NAME=scofield;VMX_CARTEL=$(/sbin/esxcli vms vm list | grep -A3 ${VM_NAME} | grep Cartel | awk '{gsub("VMX Cartel ID:", "");print $1}');/sbin/vsish -e cat /sched/memClients/${VMX_CARTEL}/SchedGroupID
4639

Note: You just need to substitute VM_NAME variable with the display name of of the virtual machine you are interested in. There are actually multiple commands being executed in this one line. If your VM has spaces, make sure you put quotes around it

ESX

Obtaining VMX Cartel ID (LWID)

vmdumper - This will list all running VMs including the path to the .vmx configuration file, the display name of your VM and the VMX Cartel ID

[root@himalaya ~]# /usr/lib/vmware/bin/vmdumper -l
wid=29250 pid=-1 cfgFile="/vmfs/volumes/4a48004d-f9af7fa0-5bbf-003048d9586b/STA202G/STA202G.vmx" uuid="42 30 d1 75 c5 3e 81 2a-14 15 1f 86 bb 5b b9 e5" displayName="STA202G" vmxCartelID=29249

vscsiStats - The VMX Cartel ID is also used in identifying the VMs when displaying vscsi information

[root@himalaya ~]# /usr/lib/vmware/bin/vscsiStats -l | grep "STA202G" | awk '{print $4}' | sed 's/,//g'
29249

esxcli - You can obtain pretty much the same information as in vmdumper using the new "vm" option in esxcli

[root@himalaya ~]# /usr/sbin/esxcli vms vm list | grep -A3 STA202G | grep Cartel | awk '{gsub("VMX Cartel ID:", "");print $1}'
29249

Obtaining GID

Method1 - Using esxcli and esxcfg-info to extract VM's GID

[root@himalaya ~]# VM_NAME=STA202G ;VMX_CARTEL=$(/usr/sbin/esxcli vms vm list | grep -A3 ${VM_NAME} | grep Cartel | awk '{gsub("VMX Cartel ID:", "");print $1}');esxcfg-info -r -F perl > /tmp/esxcfg-info.txt;grep -B1 "vm.${VMX_CARTEL}" /tmp/esxcfg-info.txt | head -1 | awk '{print $3}' | sed 's/,//g'
197

Method2 - Using sched-stats to extract GID

[root@himalaya ~]# VM_NAME=STA202G;VMX_CARTEL=$(/usr/lib/vmware/bin/vscsiStats -l | grep "${VM_NAME}" | awk '{print $4}' | sed 's/,//g');/usr/bin/sched-stats -t groups | grep "vm.${VMX_CARTEL}" | awk '{print $1}'
197

Method3 - Using /proc information from sched

[root@himalaya ~]# VM_NAME=STA202G ;grep "${VM_NAME}" /proc/vmware/sched/drm-stats | awk '{print $1}'
197

As you can see, there are more than one way to obtain the same exact values and I am sure there are probably a few others. For command simplicity, I would probably recommend method #3 for ESXi and method #3 for ESX. As with anything, be careful when you using these methods as they are not really supported by VMware unless directed by their support organization.

More from my site

  • Using the vSphere API in vCenter Server to collect ESXTOP & vscsiStats metrics
  • How to clear the ARP cache in ESXi prior to vSphere 5.5
  • Minimum vSphere privileges to install or remove patch from ESXi
  • Quick Tip - Using ESXCLI to upgrade ESXi 8.x throws MemoryError or Got no data from process
  • Quick Tip - New method to mark HDD to SSD in ESXi 7.x and 8.x using ESXCLI

Categories // Uncategorized Tags // esxcli, esxtop, gid, lwid, vmdumper, vscsiStats, vsish

Comments

  1. *protectedSebastian Kayser says

    12/03/2010 at 12:48 pm

    William, thanks for the write up. I was the one who initially queried Duncan on the GID topic, thus I am glad to see it being picked up so well by the two of you!

    Are you aware of any way to query the GID remotely via the vSphere API? This would be really neat. Use case: login to vMA, query GID via a script, fire up resxtop and limit the view to the GID. That way one wouldn't have to worry about the ESX/ESXi command line differences either.

    One-liner-wise, two minor additions related to the use of grep (which people might want to add to their reportoire).

    ~ # ps -Cc | grep "scofield" | grep -v grep | awk '{print $2}'

    Could be re-written as

    ~ # ps -Cc | grep "[s]cofield" | awk '{print $2}'

    No "grep -v" required. Or even shorter as

    ~ # ps -Cc | awk '/scofield/ {print $2}'

    Reply
  2. *protectedWilliam says

    12/03/2010 at 2:09 pm

    @Sebastian,

    Afaik, this information is not exposed via the vSphere APIs

    Reply
  3. *protectedakamac says

    10/24/2013 at 1:58 pm

    Hi, William!
    What does VMX Cartel ID stand for? Can you share where to get some info on this topic?
    TIA

    Reply
  4. *protectedActCAD Polska says

    08/11/2021 at 2:05 am

    Not all information is disclosed in this way by the API

    Reply

Trackbacks

  1. GOLD FEELING トランクバッカン(フタ?ベルト付):釣具の通販 南 says:
    07/31/2015 at 9:56 am

    GOLD FEELING トランクバッカン(フタ?ベルト付):釣具の通販…

    * Youreのようにクール!私は、アイブ氏は前にこのようなものを読んでと…

    Reply
  2. ★Sweet&Sheep ツィードリボンバナナクリップ  リボン バナナクリップ ツ says:
    08/04/2015 at 11:40 am

    ★Sweet&Sheep ツィードリボンバナナクリップ  リボン バナナクリップ …

    このポストをありがとう、私はこれの大ファンインターネットサイト…

    Reply
  3. かもせ~!ドラマ「もやしもん」最終回記念!請福もやしもん梅酒720ml 12 says:
    08/04/2015 at 3:29 pm

    かもせ~!ドラマ「もやしもん」最終回記念!請福もやしもん梅酒720ml…

    デッド ペント 記事、感謝エントロピー|選択情報| についてはそれを感…

    Reply
  4. ESXTOP | nq1320 says:
    08/22/2015 at 12:25 pm

    […] use the outcome within esxtop to limit(l) your view to that single GID. William Lam has written an article a couple of days after I added the GID section. The following is a lot simpler than what I came up […]

    Reply
  5. 【NORTH cafe & craft(ノースカフェ&クラフト)】リアルクロス ペンダントヘッドN-62 50 says:
    08/29/2015 at 2:11 pm

    【NORTH cafe & craft(ノースカフェ&クラフト)】リアルクロス ペンダントヘッドN-…

    はこれ本当にこれがありますマーケット。インターフェイスは、カラ…

    Reply
  6. 【自転車用前カゴ】ダホン DAHON 純正オプションパーツ フロントバスケッ says:
    09/24/2015 at 4:07 pm

    【自転車用前カゴ】ダホン DAHON 純正オプションパーツ フロントバスケ…

    必要 支援。あなたの特殊へのコミットメント 答え全体で非常に有益だ…

    Reply
  7. Hitchhiker's Guide to Get-EsxTop - Part 1 - LucD notes says:
    04/08/2020 at 3:21 am

    […] we can read in lamw's post called How to obtain GID and LWID from esxtop? it's quite easy to get the  IDs with the esxcli command. And with the information in […]

    Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025