PowerCLI NVMe TBW push to vROps API

Idea – Homelab, wanted to push the GBW and TBW (Terabytes Written) metric on an ESXi 7.0 host NVMe drive to vROps. SATA drives need smartctl to be install in where there is not an ESXi 7.0 VIB https://www.virten.net/2016/05/determine-tbw-from-ssds-with-s-m-a-r-t-values-in-esxi-smartctl/

The PowerCLI script will login to vCenter, use get-esxcli -V2 to pull the NVMe drive metrics and then run a POST to the vROps API for the single ESXi host in scope with those metics to create a new NVMe propery in vROps.

The Model will not have a new plot point since the model will not change. The GBW will have more plots points vs the TBW since you need 100 Gigabyes to change the first decimal point.

Limitations – Only one ESXi host is specified in the script and you have to fill in the host resource object ID from vROps. Securty and scripting best practives are not used. No warrenty 🙂

Make sure to run these two powershell commands in the same folder as the script for the vROps and VCSA login accounts.
(get-credential).password | ConvertFrom-SecureString | set-content vrops.pass
(get-credential).password | ConvertFrom-SecureString | set-content vcsa.pass

In the ps1, Fill in the Six Variables.

 

Setup –
VMware.PowerCLI Version: 12.3.0.17860403
vRealize Operations Manager Version: 8.4.0 (17863947)
vROps has an internal CA signed cert using XCA – https://vmscribble.com/vcenter/vmware-vcsa-use-xca-for-root-and-intermediate-certificate-authority/

If the vROps cert is the out of the box self signed one, you will run into this error:
System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. —> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
Workaround is to add the “using System.Security.Cryptography.X509Certificates;” section to the script from https://michaelryom.dk/vrops-api-consumed-with-powershell/

Tip –
Add to the script to run via the Windows Server Task Scheduler (repeat task every 5 minutes) https://vmscribble.com/powercli/automate-powercli-scripts-via-the-windows-server-2012-task-scheduler/

Idea

Idea – Homelab, wanted to push the GBW and TBW (Terabytes Written) metric on an ESXi 7.0 host NVMe drive to vROps. SATA drives need smartctl to be install in where there is not an ESXi 7.0 VIB https://www.virten.net/2016/05/determine-tbw-from-ssds-with-s-m-a-r-t-values-in-esxi-smartctl/

The PowerCLI script will login to vCenter, use get-esxcli -V2 to pull the NVMe drive metrics and then run a POST to the vROps API for the single ESXi host in scope with those metics to create a new NVMe propery in vROps.

The Model will not have a new plot point since the model will not change. The GBW will have more plots points vs the TBW since you need 100 Gigabyes to change the first decimal point.

Limitations – Only one ESXi host is specified in the script and you have to fill in the host resource object ID from vROps. Securty and scripting best practives are not used. No warrenty 🙂

Prerequisites

Make sure to run these two powershell commands in the same folder as the script for the vROps and VCSA login accounts.
(get-credential).password | ConvertFrom-SecureString | set-content vrops.pass
(get-credential).password | ConvertFrom-SecureString | set-content vcsa.pass

In the ps1, Fill in the Six Variables.

The Script

[crayon-61486709dd948689489890/]

 

Reading/Testing
ENV/SSL Tip

Setup –
VMware.PowerCLI Version: 12.3.0.17860403
vRealize Operations Manager Version: 8.4.0 (17863947)
vROps has an internal CA signed cert using XCA – https://vmscribble.com/vcenter/vmware-vcsa-use-xca-for-root-and-intermediate-certificate-authority/

If the vROps cert is the out of the box self signed one, you will run into this error:
System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. —> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
Workaround is to add the “using System.Security.Cryptography.X509Certificates;” section to the script from https://michaelryom.dk/vrops-api-consumed-with-powershell/

Tip –
Add to the script to run via the Windows Server Task Scheduler (repeat task every 5 minutes) https://vmscribble.com/powercli/automate-powercli-scripts-via-the-windows-server-2012-task-scheduler/

Menu