The get_data_ex API function lets you get all of the scenario information, such as the following:
The parameter manager_data is an xml format string. The data contains all of the scenario information. For example, the scenario status (running, stopped, and so on), events, scenario statistics, and so on. The xml format string resembles the following:
The following sections demonstrate how to use the xml string.
Arguments
The get_data_ex API includes the arguments described in the following table:
Name |
Type |
Description |
---|---|---|
session_id |
uint |
The session ID that was returned by calling the create_session API. |
scenarios_with_statistics |
uint |
The array of scenario IDs. Retreives the statistics for the scenarios. |
last_update_time |
ulong |
Last updated timestamp. |
request_flag |
uint |
Requests the data type. The values can be as follows: 1 - scenario data 2 - cdp data [not used] 4 - host management data 8 - snapshot data 15 - all above data |
manager_data |
out string |
Return the data for the scenario in xml format. |
Return Values
The return type is Boolean. When the return value is true, the command completed successfully. When the return value is false, the command did not complete successfully. If the return value is false, review the message to determine the reason the API failed.
Examples
Example 1:
public bool get_data_ex_example()
{
try
{
uint[] scenarios_with_statistics = new uint[] { _scenario_id };
uint request_flag = 1;
ulong last_update_time = 0;
string manager_data = "";
bool res = get_mng().get_data_ex(_session_id, scenarios_with_statistics, request_flag, ref last_update_time, out manager_data);
return res;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
return false;
}
Example 2:
This function parses the XML buffer data (manager_data) that was returned by the get_data_ex() function. The following example describes how to get the scenario state when it is running or stopped:
string get_scenario_state (string manager_data, string scenario_name_or_id) { string scenario_state = "unknown"; XmlDocument manager_data_doc = new XmlDocument(); manager_data_doc.LoadXml(manager_data); XmlNode root_node = manager_data_doc.SelectSingleNode(".//manager_data"); if (root_node == null) { return scenario_state; } //get all the scenario data information XmlNode scenario_nodes = root_node.SelectSingleNode(".//scenarios"); if (scenario_nodes == null) { return scenario_state; } foreach (XmlNode scenario_node in scenario_nodes.ChildNodes) { uint scenario_id = 0; string scenario_name = ""; XmlAttribute id_attr = scenario_node.Attributes["id"]; if (id_attr != null) scenario_id = Convert.ToUInt32(id_attr.Value); XmlAttribute name_attr = scenario_node.Attributes["name"]; if (name_attr != null) scenario_name = name_attr.Value; if (scenario_name_or_id != scenario_id.ToString() && scenario_name_or_id.ToLower() != scenario_name.ToLower()) continue; //get the scenario status, running or stopped foreach (XmlNode node in scenario_node.ChildNodes) { //get the scenario state, running or stop if (0 == string.Compare("state", node.Name, true)) { if (node.Attributes["val"] != null) { scenario_state = node.Attributes["val"].Value.ToLower(); } } } } return scenario_state; }
Example 3:
This function parses the XML buffer data (manager_data) that was returned by the get_data_ex() function. The following example describes how to get all of the events for the scenario:
void get_scenario_events(string manager_data, string scenario_name_or_id, ref ArrayList events) { XmlDocument manager_data_doc = new XmlDocument(); manager_data_doc.LoadXml(manager_data); XmlNode root_node = manager_data_doc.SelectSingleNode(".//manager_data"); if (root_node == null) { return ; } //get all the scenario data information XmlNode scenario_nodes = root_node.SelectSingleNode(".//scenarios"); if (scenario_nodes == null) { return ; } foreach (XmlNode scenario_node in scenario_nodes.ChildNodes) { uint scenario_id = 0; string scenario_name = ""; XmlAttribute id_attr = scenario_node.Attributes["id"]; if (id_attr != null) scenario_id = Convert.ToUInt32(id_attr.Value); XmlAttribute name_attr = scenario_node.Attributes["name"]; if (name_attr != null) scenario_name = name_attr.Value; if (scenario_name_or_id != scenario_id.ToString() && scenario_name_or_id.ToLower() != scenario_name.ToLower()) continue; //get the scenario status, running or stopped foreach (XmlNode node in scenario_node.ChildNodes) { //get the scenario state, running or stop if (0 == string.Compare("gen", node.Name, true)) { events.Add(new event_data_c(node)); } } } }
Example 4:
You define the scenarios_with_statistics parameter to get the synchronization and replication statistics for a scenario. The parameter is an array. To get the statistics for more than one scenario, you add the IDs of the scenarios to the array.
The get_data_ex gets the following statistics:
Note: The following screens illustrate the process of transferring and synchronization statistics information.
Code
This function parses the XML buffer data (manager_data) that was returned by the get_data_ex() function. The following code demonstrates how to get the statistics of transferring and synchronization. (See the previous screens.)
void get_scenario_sync_statistics(string manager_data, string scenario_name_or_id, ref ArrayList sync_statistics) { XmlDocument manager_data_doc = new XmlDocument(); manager_data_doc.LoadXml(manager_data); XmlNode root_node = manager_data_doc.SelectSingleNode(".//manager_data"); if (root_node == null) { return; } //get all the scenario data information XmlNode scenario_nodes = root_node.SelectSingleNode(".//scenarios"); if (scenario_nodes == null) { return; } foreach (XmlNode scenario_node in scenario_nodes.ChildNodes) { uint scenario_id = 0; string scenario_name = ""; XmlAttribute id_attr = scenario_node.Attributes["id"]; if (id_attr != null) scenario_id = Convert.ToUInt32(id_attr.Value); XmlAttribute name_attr = scenario_node.Attributes["name"]; if (name_attr != null) scenario_name = name_attr.Value; if (scenario_name_or_id != scenario_id.ToString() && scenario_name_or_id.ToLower() != scenario_name.ToLower()) continue; //get the scenario status, running or stopped foreach (XmlNode node in scenario_node.ChildNodes) { //get the scenario state, running or stop if (0 == string.Compare("statistics", node.Name, true)) { sync_statistics.Add(new host_statistics_c(node)); } } } }
Example 5:
The following code demonstrates how to retrieve sync statistics for scenarios.
ArrayList sync_statistics = new ArrayList(); get_scenario_sync_statistics(manager_data, "FileServer 1", ref sync_statistics); //show the statistics foreach (host_statistics_c stat in sync_statistics) { //host name string host_name = stat.host_name; //transmission statistics foreach (transfer_to_replica_c trans in stat.trans_to_reps) { //handle the transfer data such as speed. ulong speed = trans.transmission_speed; } //sync statistics foreach (sync_statistics_host_c sync_host in stat.children_hosts) { //root directory foreach(sync_statistics_root_dir_c root_dir in sync_host.sync_root_dirs) { //root_dir.total_size } } }
Copyright © 2015 Arcserve.
All rights reserved.
|
|