1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-28 14:50:08 +03:00

B #5300 Write disk monitor information

This commit is contained in:
Ruben S. Montero 2017-09-05 13:17:08 +02:00
parent 7f7f65cd64
commit 6faed83d43
6 changed files with 42 additions and 34 deletions

View File

@ -301,8 +301,9 @@ public:
/**
* Updates VM dynamic information (usage counters), and updates last_poll,
* and copies it to history record for acct.
* @param update_db true if the VM table needs to be updated.
*/
int update_info(const string& monitor_data);
int update_info(const string& monitor_data, bool& update_db);
/**
* Clears the VM monitor information usage counters (MEMORY, CPU),
@ -970,8 +971,9 @@ public:
/**
* Deletes the error message from the template (ERROR_MONITOR)
* @param message Message string
* @return the number of ERROR_MONITOR attributes removed
*/
void clear_template_monitor_error();
int clear_template_monitor_error();
// ------------------------------------------------------------------------
// Timers & Requirements

View File

@ -74,19 +74,16 @@ public:
*
* @param id VM id
* @param monitor_str String returned by the poll driver call
* @param update_db write data to DB (or keep it in memory)
*/
static void process_poll(int id, const string &monitor_str, bool update_db);
static void process_poll(int id, const string &monitor_str);
/**
* Updates the VM with the information gathered by the drivers
*
* @param vm VM to update, must be locked
* @param monitor_str String returned by the poll driver call
* @param update_db write data to DB (or keep it in memory)
*/
static void process_poll(VirtualMachine* vm, const string &monitor_str,
bool update_db);
static void process_poll(VirtualMachine* vm, const string &monitor_str);
/**
* Check if action is supported for imported VMs

View File

@ -282,7 +282,7 @@ void MonitorThread::do_message()
continue;
}
VirtualMachineManagerDriver::process_poll(vm, itm->second, true);
VirtualMachineManagerDriver::process_poll(vm, itm->second);
vm->unlock();
}

View File

@ -606,6 +606,8 @@ static void monitor_action(istringstream& is,
int id,
const string& result)
{
static unsigned int tics = 10;
string dsinfo64;
string *dsinfo = 0;
@ -690,6 +692,18 @@ static void monitor_action(istringstream& is,
ds->unlock();
oss << "Datastore " << ds_name << " (" << id << ") successfully monitored.";
NebulaLog::log("ImM", Log::DEBUG, oss);
//Process VM disk information every 10 monitor actions
if ( tics++ < 10 )
{
return;
}
tics = 0;
vector<VectorAttribute *> vm_disk_info;
vector<VectorAttribute *>::iterator it;
@ -706,13 +720,9 @@ static void monitor_action(istringstream& is,
continue;
}
VirtualMachineManagerDriver::process_poll(vm_id, poll_info, false);
VirtualMachineManagerDriver::process_poll(vm_id, poll_info);
}
oss << "Datastore " << ds_name << " (" << id << ") successfully monitored.";
NebulaLog::log("ImM", Log::DEBUG, oss);
return;
}

View File

@ -2179,13 +2179,15 @@ int VirtualMachine::from_xml(const string &xml_str)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualMachine::update_info(const string& monitor_data)
int VirtualMachine::update_info(const string& monitor_data, bool& update_db)
{
int rc;
string error;
ostringstream oss;
update_db = false;
last_poll = time(0);
rc = monitoring.update(monitor_data, error);
@ -2201,12 +2203,14 @@ int VirtualMachine::update_info(const string& monitor_data)
log("VMM", Log::ERROR, oss);
update_db = true;
return -1;
}
set_vm_info();
clear_template_monitor_error();
update_db = clear_template_monitor_error() > 0;
oss << "VM " << oid << " successfully monitored: " << monitor_data;
@ -2340,9 +2344,9 @@ void VirtualMachine::set_template_monitor_error(const string& message)
/* -------------------------------------------------------------------------- */
void VirtualMachine::clear_template_monitor_error()
int VirtualMachine::clear_template_monitor_error()
{
user_obj_template->erase("ERROR_MONITOR");
return user_obj_template->erase("ERROR_MONITOR");
}
/* -------------------------------------------------------------------------- */

View File

@ -661,7 +661,7 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
string monitor_str;
getline(is, monitor_str);
process_poll(vm, monitor_str, true);
process_poll(vm, monitor_str);
}
else
{
@ -684,10 +684,7 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::process_poll(
int id,
const string &monitor_str,
bool update_db)
void VirtualMachineManagerDriver::process_poll(int id,const string& monitor_str)
{
// Get the VM from the pool
VirtualMachine* vm = Nebula::instance().get_vmpool()->get(id,true);
@ -697,7 +694,7 @@ void VirtualMachineManagerDriver::process_poll(
return;
}
process_poll(vm, monitor_str, update_db);
process_poll(vm, monitor_str);
vm->unlock();
}
@ -705,10 +702,8 @@ void VirtualMachineManagerDriver::process_poll(
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManagerDriver::process_poll(
VirtualMachine* vm,
const string& monitor_str,
bool update_db)
void VirtualMachineManagerDriver::process_poll(VirtualMachine* vm,
const string& monitor_str)
{
char state;
@ -723,17 +718,17 @@ void VirtualMachineManagerDriver::process_poll(
if (vm->get_state() == VirtualMachine::ACTIVE)
{
int rc = vm->update_info(monitor_str);
bool update_db;
if ( update_db )
if (vm->update_info(monitor_str, update_db) == 0)
{
if ( rc == 0)
{
vmpool->update_history(vm);
vmpool->update_history(vm);
vmpool->update_monitoring(vm);
}
vmpool->update_monitoring(vm);
}
if (update_db)
{
vmpool->update(vm);
}