• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Yellow Bricks

by Duncan Epping

  • Home
  • Unexplored Territory Podcast
  • HA Deepdive
  • ESXTOP
  • Stickers/Shirts
  • Privacy Policy
  • About
  • Show Search
Hide Search

vimsh, what can I do with it?

Duncan Epping · Jan 5, 2009 ·

Vimsh(and vmware-vim-cm) is probably one of the worst documented commands out there. At the same time it’s one of the most powerful commands(I know it’s a shell…) out there. You name it and “vimsh” does it. Most of you ran into the “enabling vmotion” from the Service Console problem when first starting out with scripted install. Vimsh solves this:

/usr/bin/vmware-vim-cmd “hostsvc/vmotion/vnic_set vmk0″

As you can see “vimsh” is very powerful, but most of the other command-line stuff can be handled with the “esxcfg-*” commands. Well almost, for instance we talked about enabling autostart in my previous post. According to the KB article you must edit the file “/etc/vmware/hostd/vmAutoStart.xml”. Editing this file can be dangerous, I guess this goes for most ESX configuration files. During the Dutch VMUG I had a short chat with Wil van Antwerpen, Wil told me he was busy documenting the “vimsh” “command” in a wiki. After I published the enabling autostart blog Wil emailed me that this could and should be done with “vimsh”. I fully agree with Wil:

vmware-vim-cmd /hostsvc/autostartmanager/enable_autostart true

This enables the autostart functionality without manually editing the files. But I guess you would like to check if it’s enabled or disabled:

vmware-vim-cmd /hostsvc/autostartmanager/get_defaults

The big question remains, how do I know what I can and can’t do with “vimsh”. Well that’s the main reason for this post, as I said Wil has been very busy documenting “vimsh”. Wil created VI-Toolkit.com. VI-Toolkit.com contains a section on vimsh. Besides the the info that the vimsh command provices Wil added sample code. The sample code can be very usefull, but the search function is even more useful. Searching the vimsh documentation provides you with a fast way to check if a specific configuration action can be scripted with “vimsh”. For instance a search on “vimsh role” returns the following:

* Vimsvc/auth/role add
==== vimsh vimsvc/auth/role_add ==== Usage: role_add roleName [priv0] [priv1] [priv2] [priv3] [priv4]
171 B (24 words) – 14:32, 26 December 2008
* Vimsvc/auth/role permissions
==== vimsh vimsvc/auth/role_permissions ==== Usage: role_permissions roleName
1 KB (118 words) – 22:26, 28 December 2008
* Vimsvc/auth/role remove
==== vimsh vimsvc/auth/role_remove ==== Usage: role_remove roleName [failIfUsed]
123 B (16 words) – 14:34, 26 December 2008
* Vimsvc/auth/roles
==== vimsh vimsvc/auth/roles ==== Usage: roles
7 KB (550 words) – 21:50, 28 December 2008

I guess I can sum up this blog post in just one line:”Bookmark VI-Toolkit.com and add it to your RSS reader!”. Be sure to not miss out on anything regarding “vimsh” or any of the VI Toolkits that Wil be be describing and aggregating source code for. The “vimsh” section alone is already 345 pages large and it will continue to grow even more. Keep up the great work Wil and it was nice meeting you in person!

Related

Management & Automation, Server Blogging, ESX, esxi, Scripting, service console

Reader Interactions

Comments

  1. wila says

    5 January, 2009 at 13:30

    Thank you Duncan for the kind words.

    Also thanks for the vmotion tip, i’ve added your example to the command description.
    —
    Wil

  2. meuja says

    6 January, 2009 at 00:47

    For find the Vmotion vmknic interface, you can do it bu this way:
    pg_vmotion=$(esxcfg-vswitch -l|awk ‘/Vmotion/ {print $2}’)
    vimsh -n -e “/hostsvc/vmotion/vnic_set ${pg_vmotion}”

  3. kevinc says

    9 March, 2009 at 10:51

    Great help here. I’m a big fan of this site, thanks so much.

    I am trying to add some commands to my EDA postinstall script, specifically some to modify my LVM and Disk settings undre “Advanced” settings in vCenter.

    I see that /proc/vmware/config/Disk/SANDevicesWithAPFailover is where I query my current setting (5th field), but how do I change it?

    What vmware-vim-cmd or vimsh parameters would let me change the value for this?

    I’ve read and searched xtravirt’s great white paper, but have not been able to find or guess the syntax I need.

    Similarly, I want to change “LVMDisallowSnapshotlun”. under LVM advanced settings.

    cheers,
    Kevin

  4. Duncan Epping says

    9 March, 2009 at 11:50

    you should be able to set them with esxcfg-advcfg.

  5. kevinc says

    9 March, 2009 at 12:01

    Update: ah, Got it! There’s nothing like trial and error:

    # vmware-vim-cmd hostsvc/advopt/update Disk.SANDevicesWithAPFailover string “SANsymphony :”

    Duncan, I’ll see check out your suggestion as well.

    cheers muchly,
    Kevin

  6. kevinc says

    9 March, 2009 at 12:23

    okay,

    # esxcfg-advcfg –set “SANSymphony :” /Disk/SANDevicesWithAPFailover

    # esxcfg-advcfg –get /Disk/SANDevicesWithAPFailover
    Value of SANDevicesWithAPFailover is SANSymphony :

    cheers Duncan, you rock!

  7. TomC says

    19 October, 2009 at 14:48

    Has anyone ever tried to add a vm to the autstartseq? I always get a invalid argument with the following command:
    vmware-vim-cmd hostsvc/autostartmanager/update_autostartentry 48 PowerOn 60 1 GuestShutdown 60 true

    Problem seems to be the StartOrder number: 1

  8. TomC says

    19 October, 2009 at 17:29

    OK, already foud it.

    vmware-vim-cmd hostsvc/autostartmanager/update_autostartentry 28 PowerOn “60” 1 GuestShutdown 60 systemDefault

  9. Mark says

    4 December, 2009 at 06:49

    I think vimsh cant do (initiate) vmotion – anyone know any way from service console?. (other then powershell/vcenter gui).

    thanks

  10. Mats says

    29 December, 2009 at 18:01

    where do you find this in vSphere?
    /Disk/SANDevicesWithAPFailover

    I have it on my ESX3 hosts, but not esx4 ?

Primary Sidebar

About the Author

Duncan Epping is a Chief Technologist and Distinguished Engineering Architect at Broadcom. Besides writing on Yellow-Bricks, Duncan is the co-author of the vSAN Deep Dive and the vSphere Clustering Deep Dive book series. Duncan is also the host of the Unexplored Territory Podcast.

Follow Us

  • X
  • Spotify
  • RSS Feed
  • LinkedIn

Recommended Book(s)

Advertisements




Copyright Yellow-Bricks.com © 2025 · Log in