Collapse All
Parallels Virtualization SDK
ContentsIndex
PreviousUpNext
PrlSrv_GetStatistics Function
PHT_SERVER  Example

Obtains a handle of type PHT_SYSTEM_STATISTICS containing the host resource usage statistics.

Syntax
PRL_HANDLE PrlSrv_GetStatistics(
    PRL_HANDLE hServer
);
File

PrlApiStat.h

Parameters

hServer
A handle of type PHT_SERVER identifying the Parallels Service.

Returns

A handle of type PHT_JOB containing the results of this asynchronous operation or PRL_INVALID_HANDLE if there's not enough memory to instantiate the job object. 

 

Remarks

 

To get the return code from the PHT_JOB object, use the PrlJob_GetRetCode function. Possible values are: 

PRL_ERR_INVALID_ARG - invalid handle was passed. 

PRL_ERR_SUCCESS - function completed successfully. 

To get the result from the PHT_JOB object:

  1. Use the PrlJob_GetResult function to obtain a handle to the PHT_RESULT object.
  2. Use the PrlResult_GetParam function to obtain a handle of type PHT_SYSTEM_STATISTICS.
Example

The following example illustrates how to obtain a handle of type PHT_SYSTEM_STATISTICS.

PRL_RESULT err = PRL_ERR_UNINITIALIZED;
PRL_RESULT rc = PRL_ERR_UNINITIALIZED;
PRL_HANDLE hJob = PRL_INVALID_HANDLE;
PRL_HANDLE hJobResult = PRL_INVALID_HANDLE;
PRL_HANDLE hServer = PRL_INVALID_HANDLE;

// Initialize API library.
err = PrlApi_Init(PARALLELS_API_VER);
if (PRL_FAILED(err))
{
    // Error handling goes here...
    return -1;
}

// Create server handle.
err = PrlSrv_Create(&hServer);

// if (err != PRL_ERR_SUCCESS), process the error here.

hJob = PrlSrv_Login(
    hServer, // Server handle
    "10.30.21.243", // Server IP address
    "jdoe", // User
    "secret", // Password
    0, // Previous session ID
    0, // Port number
    0, // Timeout
    PSL_LOW_SECURITY); // Security

// Wait for the job to complete.
err = PrlJob_Wait(hJob, 1000);

// if (err != PRL_ERR_SUCCESS), process the error here.

// Get job return code.
err = PrlJob_GetRetCode(hJob, &rc);

// if (err != PRL_ERR_SUCCESS), process the error here.
// if (rc != PRL_ERR_SUCCESS), process the error here.

// Free job handle.
PrlHandle_Free(hJob);

// Get statistics.
hJob = PrlSrv_GetStatistics(hServer);
err = PrlJob_Wait(hJob, 10000);

// if (err != PRL_ERR_SUCCESS), process the error here.

err = PrlJob_GetRetCode(hJob, &rc);

// if (err != PRL_ERR_SUCCESS), process the error here.
// if (rc != PRL_ERR_SUCCESS), process the error here.

err = PrlJob_GetResult(hJob, &hJobResult);
PrlHandle_Free(hJob);

// Get the PHT_SYSTEM_STATISTICS handle.
PRL_HANDLE hHandle = PRL_INVALID_HANDLE;
err = PrlResult_GetParam(hJobResult, &hHandle);

// if (err != PRL_ERR_SUCCESS), process the error here.

PrlHandle_Free(hJobResult);
Links
© 2021 Parallels International GmbH. All rights reserved.