The following lists contain some of the commonly used performance classes and the counters from the counters_vz_cpu class
as an exmple. You can get the complete list of classes and their counters from the Agent vocabulary. See Parallels Agent XML Programmer's Reference guide for more information on how to retrieve the performance classes and counters information.
Virtuozzo Containers-specific Performance Classes:
counters_vz_cpu
counters_vz_net
counters_vz_loadavg
counters_vz_process
counters_vz_slm
counters_vz_system
counters_vz_memory
counters_vz_hw_net
counters_vz_quota
counters_vz_ubc
Counters from the counters_vz_cpu class:
counter_cpu_system
counter_cpu_user
counter_cpu_idle
counter_cpu_nice
counter_cpu_starvation
counter_cpu_system_states
counter_cpu_user_states
counter_cpu_idle_states
The following is an example of two functions working together that retrieve the latest performance report using the specified Server ID, performance class, and performance counter. The function initializes and populates the necessary input parameters, gets the performance data from Agent, and then calls the getData
function (described below) that extracts the data and puts it into a string that can be displayed on the screen.
Sample Function Parameters:
Name |
Description |
|
Server ID of the Container for which to retrieve the performance data. |
|
The name of the performance class. |
|
The name of the performance counter. |
Sample Function:
/// <summary>
/// Sample function GetPerfData.
/// Gets the Container or the Hardware Node performance data.
/// </summary>
/// <param name="eid"></param>
/// <param name="class_name"></param>
/// <param name="counter_name"></param>
/// <returns>A string containing the performance data.</returns>
///
public string GetPerfData(string eid, string class_name, string counter_name, string class_instance)
{
string perf_data = "";
try {
// Create binding object.
perf_monBinding perf_mon = (perf_monBinding)binder.InitBinding(typeof(perf_monBinding));
// The main input object.
get5 get_input = new get5();
// Set Server ID.
get_input.eid_list = new string[1];
get_input.eid_list[0] = eid;
/* Set the performance class name.
* Multiple classes can be set if desired.
*/
get_input.@class = new classType1[1];
get_input.@class[0] = new classType1();
get_input.@class[0].name = class_name;
// Set class instance.
get_input.@class[0].instance = new classTypeInstance[1];
get_input.@class[0].instance[0] = new classTypeInstance();
if (class_instance.Length != 0) {
get_input.@class[0].instance[0].name = class_instance;
}
// Set counter. Multiple counters can be set if desired.
get_input.@class[0].instance[0].counter = new string[1];
get_input.@class[0].instance[0].counter[0] = counter_name;
/* Get the performance data. The returned data is
* extracted using the GetData helper function, which
* is defined below.
*/
GetData(perf_mon.get(get_input), out perf_data);
}
catch (Exception e) {
perf_data += "Exception: " + e.Message;
}
return perf_data;
}
/// <summary>
/// Sample function GetData.
/// This is a helper function that extracts the performance
/// data retrieved by the getPerfData function defined above.
/// </summary>
/// <param name="counters_dat">
/// Contains the data for each class, instance, and counter that
/// were specified in the request that returned this object (the
/// perf_mon.get() call above). To extract the data, we have to iterate through all
/// of them.
/// </param>
/// <param name="counters_info">
/// Output. A string containing the extracted data.
/// </param>
///
public void GetData(perf_dataType[] counters_dat, out string counters_info)
{
counters_info = "";
if (counters_dat.Length != 0) {
foreach (perf_dataType counter_dat in counters_dat) {
if (counter_dat.@class != null) {
foreach (perf_dataTypeClass dat in counter_dat.@class) {
counters_info += "\n Class name: " + dat.name + "\n" +
"Instances:\n";
if (dat.instance != null) {
foreach (perf_dataTypeClassInstance instance in dat.instance) {
counters_info += " DataClassInstance: " + instance.name + "\n";
if (instance.counter != null) {
foreach (perf_dataTypeClassInstanceCounter counter in instance.counter) {
counters_info += " \nName:" + counter.name + "\n" +
" avg: " + counter.value.avg + "\n" +
" cur: " + counter.value.cur + "\n" +
" max: " + counter.value.max + "\n" +
" min: " + counter.value.min;
}
}
else {
counters_info += " No counters." + "\n";
}
}
}
else {
counters_info += "No instances." + "\n";
}
}
}
else {
counters_info += "No classes." + "\n";
}
counters_info += "Intervals:\n" +
"Start time: " + counter_dat.interval.start_time + "\n" +
"End time: " + counter_dat.interval.end_time + "\n" +
"Server ID: " + counter_dat.eid + "\n";
}
}
else {
counters_info += "No data returned.";
}
}