Hi team ,
i am looking for a script where i can run "show system storage " command on NSX edges and get the output . Please let me know if it is possible or not . I know Edges have Vmware tools installed so we can invoke the script . The reason i asked this question is we are using NSX 6.3.2 and Edges disk get full specially /var/log partition . i want to run Script weekly and get the output .
I am aware that we can get disk capacity and free disk space of a Virtual machine , but it does not help where a Linux Virtual machine have multiple partions on a particalur disk .
Is there any way i can get the partitions inside the Virtual Machine and get their usage .
Thanks for help. this is what i am looking for
f9rzpcmne001.sushosted.com-0> show system storage
Filesystem Size Used Avail Use% Mounted on
/dev/root 444M 355M 66M 85% /
tmpfs 498M 3.5M 495M 1% /run
/dev/sda2 43M 1.1M 40M 3% /var/db
/dev/sda3 27M 413K 25M 2% /var/dumpfiles
/dev/sda4 32M 5.7M 25M 19% /var/log
Tarun Gupta
Did you already try running that command through Invoke-VMScript?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
No i have not . I just googled the same . Can you please share me the script if you can .
Thanks
Tarun Gupta
Basically it's nothing more than
$code = @'
show system storage
'@
$cred = Get-Credential -Message "Provide credentials for VM $($vmName)"
Invoke-VMScript -VM $vmName -ScriptText $code -ScriptType Bash -GuestCredential $cred
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
I am getting this error . I tried 3-4 times . I am using right admin credentials,able to ssh using those credentials as well in Edge .
PowerCLI C:\PowerCLIscripts> & '.\show system storage.ps1'
Invoke-VMScript : 08/03/2019 14:11:05 Invoke-VMScript The operation is not allowed in the current state.
At C:\PowerCLIscripts\Get free space.ps1:6 char:1
+ Invoke-VMScript -VM $vmName -ScriptText $code -ScriptType Bash -GuestCredential ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-VMScript], InvalidState
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript
Invoke-VMScript : 08/03/2019 14:11:07 Invoke-VMScript Failed to authenticate with the guest operating system using the supplied credentials.
At C:\PowerCLIscripts\Get free space.ps1:6 char:1
+ Invoke-VMScript -VM $vmName -ScriptText $code -ScriptType Bash -GuestCredential ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-VMScript], InvalidGuestLogin
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript
Are the VMware Tools running in the VM?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey Lucd,
Yes these are NSX edges.
VMWare tools : Running, Version 2147483647 (Guest Managed )
Could it be that access to the VM's ESXi node is blocked?
This requires port 902
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Lucd,
Yes it may be but i dont have access to Firewall's , so cant verify .
. Coming back to my original request , can you help me with any other way that i can get disk partitions of NSX edges and their % use.
NSX-edge-74-0> show system storage
Filesystem Size Used Avail Use% Mounted on
/dev/root 444M 355M 65M 85% /
tmpfs 498M 80K 498M 1% /run
/dev/sda2 43M 924K 40M 3% /var/db
/dev/sda3 27M 413K 25M 2% /var/dumpfiles
/dev/sda4 32M 4.4M 26M 15% /var/log
For example : above shows /dev/sd4 is 15% used .
Does this give you the required info?
It doesn't show the Use% directly, but the numbers to calculate are there
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference