Bug #1673: Add support for 64-bit net_tx/net_rx counters. Contributed by Simon Boulet.

(cherry picked from commit 5d54095119)
This commit is contained in:
Ruben S. Montero committed 2013-02-21 23:08:32 +01:00
1 parent a9244e9caf
commit 6b93d0899e
4 files changed
+99 -7

No files matched your search

+24
View File
@@ -94,6 +94,30 @@ public:
int xpath(unsigned int& value, const char * xpath_expr,
const unsigned int& def);
/**
* Gets and sets a xpath attribute, if the attribute is not found a default
* is used
* @param value to set
* @param xpath_expr of the xml element
* @param def default value if the element is not found
*
* @return -1 if default was set
*/
int xpath(long long& value, const char * xpath_expr,
const long long& def);
/**
* Gets and sets a xpath attribute, if the attribute is not found a default
* is used
* @param value to set
* @param xpath_expr of the xml element
* @param def default value if the element is not found
*
* @return -1 if default was set
*/
int xpath(unsigned long long& value, const char * xpath_expr,
const unsigned long long& def);
/**
* Gets and sets a xpath attribute, if the attribute is not found a default
* is used
+5 -5
View File
@@ -173,13 +173,13 @@ public:
* @param _memory Kilobytes used by the VM (total)
* @param _cpu used by the VM (rate)
* @param _net_tx transmitted bytes (total)
* @param _net_tx received bytes (total)
* @param _net_rx received bytes (total)
*/
void update_info(
const int _memory,
const int _cpu,
const int _net_tx,
const int _net_rx)
const long long _net_tx,
const long long _net_rx)
{
if (_memory != -1)
{
@@ -950,12 +950,12 @@ private:
/**
* Network usage, transmitted bytes
*/
int net_tx;
long long net_tx;
/**
* Network usage, received bytes
*/
int net_rx;
long long net_rx;
/**
* History record, for the current host
+2 -2
View File
@@ -386,8 +386,8 @@ void VirtualMachineManagerDriver::protocol(
int cpu = -1;
int memory = -1;
int net_tx = -1;
int net_rx = -1;
long long net_tx = -1;
long long net_rx = -1;
char state = '-';
string monitor_str = is.str();
+68
View File
@@ -222,6 +222,74 @@ int ObjectXML::xpath(unsigned int& value, const char * xpath_expr,
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int ObjectXML::xpath(long long& value, const char * xpath_expr,
const long long& def)
{
vector<string> values;
int rc = 0;
values = (*this)[xpath_expr];
if (values.empty() == true)
{
value = def;
rc = -1;
}
else
{
istringstream iss;
iss.str(values[0]);
iss >> dec >> value;
if (iss.fail() == true)
{
value = def;
rc = -1;
}
}
return rc;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int ObjectXML::xpath(unsigned long long& value, const char * xpath_expr,
const unsigned long long& def)
{
vector<string> values;
int rc = 0;
values = (*this)[xpath_expr];
if (values.empty() == true)
{
value = def;
rc = -1;
}
else
{
istringstream iss;
iss.str(values[0]);
iss >> dec >> value;
if (iss.fail() == true)
{
value = def;
rc = -1;
}
}
return rc;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int ObjectXML::xpath(time_t& value, const char * xpath_expr, const time_t& def)
{
int int_val;