Retrieving Uptime of Virtual Machines
Using the eG REST API, administrators can retrieve the uptime/downtime of the virtual machines/virtual desktops provisioned in a virtual environment for a chosen time period. The table below specifies the URL and the parameters that should be used to retrieve the measures of the tests.
URL: http://<eG manager IP:port>/api/eg/analytics/getUptimeForVMs
Method: POST
Content-Type: application/json
Parameters | Key values | Example |
---|---|---|
Headers |
managerurl: Base URL of the eG Manager i.e., http://<IP address of the eG console:Port> user: eG username or domain/eG username pwd: Base64 encoded password |
Example to retrieve uptime of virtual machines for a week: { "timeline":"1 week" } Example to retrieve uptime of virtual machines associated with a chosen component: { "timeline":" 1 month", "componentType":"cloud_esx", } Example to retrieve uptime of a chosen virtual machine: { "vmName":"EGDP156", "componentType":"Cloud Desktops", "timeline":"1 week" } Example to retrieve uptime of virtual machines/virtual desktops associated with a chosen component type: { "componentType":"VMware vSphere VDI", "timeline":"1 month" } Example to retrieve uptime of components for a chosen time duration: {
"componentName":"VDI_HDenv", "timeline":"any", "startDate": "January 01, 2023 00:00:00", "endDate": "January 05, 2023 01:00:00" } |
Body |
Default: { "timeline":"time period specified in hours/days/months/LastWeek/LastMonth/Any" } |
|
Optional: { "componentName":"Hostname of the component:Port", "componentType:":"Component Type", "vmName":"name of the VM/virtual desktop", "startDate":"start_date", "endDate":"end_date" } |
Type | Code | Content |
---|---|---|
JSON |
200 |
[ { "componentName": "VDI-manually", "vmName": "TEZ-WIN10-C2112TS2XD3KOR-(10.102)", "componentType": "Citrix Hypervisor - VDI", "uptime": 294180, "downtime": 310620, "percentUptime": "48.6409", "percentDowntime": "51.3591" }, { "componentName": "VDI-manually", "vmName": "TEZ-WIN10-C2112TS2XD1ENG-(10.64)", "componentType": "Citrix Hypervisor - VDI", "uptime": 294480, "downtime": 310320, "percentUptime": "48.6905", "percentDowntime": "51.3095" }, . . . ] |
Type | Code | Content |
---|---|---|
JSON |
401 UNAUTHORIZED |
{"code": 401,"error": "Invalid username or password"} |
JSON |
400 BAD REQUEST |
You may receive one of the following responses: {"code": 400,"error": "Bad Request. Header parameters : Username or Password or Manager URL is missing"} (or) {"code": 400,"error": "Bad Request. Header parameters : Manager URL, Username or Password is not provided"} (or) {"code": 400,"error": "Unable to connect manager. Please verify manager URL and make sure that eG manager is running"} (or) {"code": 400,"error": "Bad Request. Please refer eG REST API documentation and add required parameters for this API"} (or) {"code": 400,"error": "Component not associated with the user"} (or) {"code": 400,"error": Please provide valid/associated componentType"} (or) {"code": 400,"error": "Uptime - OS Test is not applicable for given Component"} (or) {"code": 400,"error": "Please provide valid timeline"} (or) {"code": 400,"error": "Bad Request. Please give Start date and End date if timeline is Any. Please refer eG REST API documentation for this API"} |
JSON |
500 Server Error |
{"code": 500,"error": " Server Error. Please check REST API parameter values and also check /manager/logs/error_log or managererr.log in the eG manager installation directory for more information."} |
Figure 1 : Retrieving uptime of VMs for a chosen time period using Postman REST Client
Retrieving Uptime of Components using cURL
To retrieve the uptime of components managed in the target environment using cURL, the command should be specified in the following format:
curl -L -X POST "http://<eG Manager IP:Port>/api/eg/analytics/getUptimeForVMs" -H "user:<eG username or domain/eG username>" -H "pwd:Base64 encoded password" -H "managerurl:http://<eG Manager IP:Port>" -H"Content-Type:application/json" --data-raw "{\"timeline\":\"time duration in hours/days/months/LastWeek/LastMonth/Any\",\"componentType\": \"name of the component Type\",\"vmName\": \"name of the virtual machine\",\"componentName\": \"name of the component:Port\"}"
Figure 2 shows an example and a sample output that retrieves the uptime of the components managed in the target environment during a chosen time duration using cURL.
Figure 2 : An example cURL command to retrieve theuptime of components using cURL