apps::vmware::connector::plugin --custommode=connector --mode=licenses : no licenses expires days return
Hello,
When I use apps::vmware::connector::plugin --custommode=connector --mode=licenses ; no licenses expires days return
/usr/lib/centreon/plugins/centreon_vmware_connector_client.pl --plugin=apps::vmware::connector::plugin --custommode=connector --connector-hostname='172.x.x.x' --connector-port='5700' --container='myvc01' --mode=licenses
OK: Number of licenses: 3 - All licenses are ok | 'licenses.total.count'=3;;;0; ' vCenter Server 8 Standard#license.usage.count'=1;;;0;324 'vCenter Server 8 Standard#license.free.count'=323;;;0;324 'vCenter Server 8 Standard#license.usage.percentage'=0.308641975308642%;;;0;100 'vCenter Server 8 Standard#license.expires.days'=0d;;;0; 'vSphere 8 Enterprise Plus#license.usage.count'=4;;;0;4 'vSphere 8 Enterprise Plus#license.free.count'=0;;;0;4 'vSphere 8 Enterprise Plus#license.usage.percentage'=100%;;;0;100 'vSphere 8 Enterprise Plus (Subscription)#license.usage.count'=324;;;0;324 'vSphere 8 Enterprise Plus (Subscription)#license.free.count'=0;;;0;324 'vSphere 8 Enterprise Plus (Subscription)#license.usage.percentage'=100%;;;0;100 'vSphere 8 Enterprise Plus (Subscription)#license.expires.days'=0d;;;0;
And if I look on the Vcenter directly :
Hello :)
As @omercier explained in the previous issue https://github.com/centreon/centreon-plugins/issues/5628
Since the Perl SDK (on which the connector relies) is not supported for this version of VMware, we don't plan on making it evolve. We're currently working on plugins using vSphere 8 API, though. The subject of license monitoring has not been started yet, but we'll try our best to cover all previous functionalities with the new plugins. If you have already found information about licenses in the VMware 8 automation API, that may help us handle this quicker 👍🏻
Hello, and thanks for your feedback.
This is what I have found about licenses :
https://developer.broadcom.com/xapis/vmware-cloud-foundation-api/latest/v1/license-keys/get/
https://{api_host}/v1/license-keys GET /v1/license-keys
licenseKeyUsage : total, used, remaining, et licence en unités (ex. INSTANCE) licenseKeyValidity.expiryDate : date d’expiration au format ISO 8601
"licenseKeyUsage": { "total": 5, "remaining": 4, "used": 1, "licenseUnit": "INSTANCE" }, "licenseKeyValidity": { "licenseKeyStatus": "ACTIVE", "expiryDate": "2029-05-23T16:12:53.001Z" }
Regards,
Hello @JBElect
It seems that this endpoint returns a 404 error according to our dev's tests :(
Hi,
Using the following documentation: https://developer.broadcom.com/xapis/virtual-infrastructure-json-api/8.0.3/sdk/vim25/release/LicenseManager/moId/licenses/get/index?scrollString=license
I wrote a Python script to query the API and retrieve license expiration dates. Here are the main functions I implemented:
def extract_expiration_dates(json_data):
results = []
def scan_properties(properties, license_key=None):
expiration = None
for prop in properties:
key = prop.get("key")
val = prop.get("value", {})
if key == "expirationDate" and val.get("_typeName") == "dateTime":
expiration = val.get("_value")
elif key == "LicenseInfo":
# Recurse dans la sous-structure imbriquée
sub_license = val
sub_props = sub_license.get("properties", [])
scan_properties(sub_props, license_key=license_key)
if expiration:
results.append((license_key, expiration))
for lic in json_data:
license_key = lic.get("licenseKey", "unknown")
props = lic.get("properties", [])
scan_properties(props, license_key)
return results
def get_vmware_licenses(vc_host, vc_user, vc_pwd):
base_url = f"https://{vc_host}"
# 1. POST /api/session avec Basic Auth pour récupérer le session id
session_url = f"{base_url}/api/session"
try:
session_resp = requests.post(session_url, auth=(vc_user, vc_pwd), verify=False)
session_resp.raise_for_status()
session_id = session_resp.json()
except Exception as e:
print(f"Erreur lors de la récupération de la session : {e}")
sys.exit(2)
# 2. GET licenses avec le header vmware-api-session-id = session_id
licenses_url = f"{base_url}/sdk/vim25/8.0.3.0/LicenseManager/LicenseManager/licenses"
headers = {
"vmware-api-session-id": str(session_id)
}
try:
licenses_resp = requests.get(licenses_url, headers=headers, verify=False)
licenses_resp.raise_for_status()
licenses_json = licenses_resp.json()
except Exception as e:
print(f"Erreur lors de la récupération des licences : {e}")
return
# 3. Extraction des dates d'expiration
exp_dates = extract_expiration_dates(licenses_json)
if not exp_dates:
print("Aucune date d'expiration trouvée.")
else:
print("Dates d'expiration des licences :")
for lic_key, date in exp_dates:
print(f" - Licence {lic_key} : expire le {date}")
I hope this helps you move forward. JB