1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

feature #1279: Change name of *_monitoring_history internal variables. Adds a custom dump_monitoring method for single VMs. Expiration times are stored as time_t.

This commit is contained in:
Ruben S. Montero 2012-05-17 00:56:03 +02:00
parent 14d30d826c
commit 87a7a09626
7 changed files with 62 additions and 48 deletions

View File

@ -37,7 +37,7 @@ public:
const string& hook_location,
const string& remotes_location,
vector<const Attribute *>& restricted_attrs,
int vm_monitoring_history);
time_t monitor_expiration);
~VirtualMachinePool(){};
@ -133,7 +133,7 @@ public:
int update_monitoring(
VirtualMachine * vm)
{
if ( _vm_monitoring_history <= 0 )
if ( _monitor_expiration <= 0 )
{
return 0;
}
@ -201,13 +201,31 @@ public:
int dump_monitoring(ostringstream& oss,
const string& where);
/**
* Dumps the VM monitoring information for a single VM
*
* @param oss the output stream to dump the pool contents
* @param vmid id of the target VM
*
* @return 0 on success
*/
int dump_monitoring(ostringstream& oss,
int vmid)
{
ostringstream filter;
filter << "oid = " << vmid;
return dump_monitoring(oss, filter.str());
}
/**
* Get the size, in seconds, of the historical monitoring information
* @return the seconds
*/
static const int& vm_monitoring_history()
static time_t monitor_expiration()
{
return _vm_monitoring_history;
return _monitor_expiration;
};
private:
@ -223,7 +241,7 @@ private:
/**
* Size, in seconds, of the historical monitoring information
*/
static int _vm_monitoring_history;
static time_t _monitor_expiration;
};
#endif /*VIRTUAL_MACHINE_POOL_H_*/

View File

@ -11,14 +11,14 @@
#
# HOST_MONITORING_INTERVAL: Time in seconds between host monitorization.
# HOST_PER_INTERVAL: Number of hosts monitored in each interval.
# HOST_MONITORING_HISTORY: Size, in seconds, of the historical monitoring
# information. (use 0 to disable host monitoring history).
# HOST_MONITORING_EXPIRATION_TIME: Time, in seconds, to expire monitoring
# information. Use 0 to disable HOST monitoring recording.
#
# VM_POLLING_INTERVAL: Time in seconds between virtual machine monitorization.
# (use 0 to disable VM monitoring).
# Use 0 to disable VM monitoring.
# VM_PER_INTERVAL: Number of VMs monitored in each interval.
# VM_MONITORING_HISTORY: Size, in seconds, of the historical monitoring
# information. (use 0 to disable VM monitoring history).
# VM_MONITORING_EXPIRATION_TIME: Time, in seconds, to expire monitoring
# information. Use 0 to disable VM monitoring recording.
#
# SCRIPTS_REMOTE_DIR: Remote path to store the monitoring and VM management
# scripts.
@ -44,11 +44,11 @@
HOST_MONITORING_INTERVAL = 600
#HOST_PER_INTERVAL = 15
HOST_MONITORING_HISTORY = 86400
#HOST_MONITORING_EXPIRATION_TIME = 86400
VM_POLLING_INTERVAL = 600
#VM_PER_INTERVAL = 5
VM_MONITORING_HISTORY = 86400
#VM_MONITORING_EXPIRATION_TIME = 86400
SCRIPTS_REMOTE_DIR=/var/tmp/one

View File

@ -263,13 +263,15 @@ void Nebula::start()
try
{
int vm_monitoring_history;
int host_monitoring_history;
string mac_prefix;
int size;
string mac_prefix;
string default_image_type;
string default_device_prefix;
time_t expiration_time;
time_t vm_expiration;
time_t host_expiration;
vector<const Attribute *> vm_hooks;
vector<const Attribute *> host_hooks;
@ -284,21 +286,20 @@ void Nebula::start()
nebula_configuration->get("VM_RESTRICTED_ATTR", vm_restricted_attrs);
nebula_configuration->get("IMAGE_RESTRICTED_ATTR", img_restricted_attrs);
nebula_configuration->get("VM_MONITORING_HISTORY",vm_monitoring_history);
nebula_configuration->get("HOST_MONITORING_HISTORY",host_monitoring_history);
nebula_configuration->get("VM_MONITORING_EXPIRATION_TIME",vm_expiration);
nebula_configuration->get("HOST_MONITORING_EXPIRATION_TIME",host_expiration);
vmpool = new VirtualMachinePool(db,
vm_hooks,
hook_location,
remotes_location,
vm_restricted_attrs,
vm_monitoring_history);
vm_expiration);
hpool = new HostPool( db,
host_hooks,
hook_location,
remotes_location,
host_monitoring_history);
host_expiration);
nebula_configuration->get("MAC_PREFIX", mac_prefix);
nebula_configuration->get("NETWORK_SIZE", size);

View File

@ -90,10 +90,10 @@ void OpenNebulaTemplate::set_conf_default()
#-------------------------------------------------------------------------------
# HOST_MONITORING_INTERVAL
# HOST_PER_INTERVAL
# HOST_MONITORING_HISTORY
# HOST_MONITORING_EXPIRATION_TIME
# VM_POLLING_INTERVAL
# VM_PER_INTERVAL
# VM_MONITORING_HISTORY
# VM_MONITORING_EXPIRATION_TIME
# PORT
# DB
# VNC_BASE_PORT
@ -112,10 +112,10 @@ void OpenNebulaTemplate::set_conf_default()
attribute = new SingleAttribute("HOST_PER_INTERVAL",value);
conf_default.insert(make_pair(attribute->name(),attribute));
// HOST_MONITORING_HISTORY
// HOST_MONITORING_EXPIRATION_TIME
value = "86400";
attribute = new SingleAttribute("HOST_MONITORING_HISTORY",value);
attribute = new SingleAttribute("HOST_MONITORING_EXPIRATION_TIME",value);
conf_default.insert(make_pair(attribute->name(),attribute));
// POLL_INTERVAL
@ -130,10 +130,10 @@ void OpenNebulaTemplate::set_conf_default()
attribute = new SingleAttribute("VM_PER_INTERVAL",value);
conf_default.insert(make_pair(attribute->name(),attribute));
// VM_MONITORING_HISTORY
// VM_MONITORING_EXPIRATION_TIME
value = "86400";
attribute = new SingleAttribute("VM_MONITORING_HISTORY",value);
attribute = new SingleAttribute("VM_MONITORING_EXPIRATION_TIME",value);
conf_default.insert(make_pair(attribute->name(),attribute));
//XML-RPC Server PORT

View File

@ -582,10 +582,9 @@ void VirtualMachineMonitoring::request_execute(
RequestAttributes& att)
{
int id = xmlrpc_c::value_int(paramList.getInt(1));
int rc;
ostringstream oss;
string where;
int rc;
bool auth = vm_authorization(id, 0, att, 0, 0, auth_op);
@ -594,13 +593,7 @@ void VirtualMachineMonitoring::request_execute(
return;
}
oss << "oid = " << id;
where = oss.str();
oss.str("");
rc = (static_cast<VirtualMachinePool *>(pool))->dump_monitoring(oss, where);
rc = (static_cast<VirtualMachinePool *>(pool))->dump_monitoring(oss, id);
if ( rc != 0 )
{

View File

@ -744,6 +744,7 @@ int VirtualMachine::update_monitoring(SqlDB * db)
string xml_body;
string error_str;
char * sql_xml;
time_t max_last_poll;
sql_xml = db->escape_str(to_xml(xml_body).c_str());
@ -757,10 +758,11 @@ int VirtualMachine::update_monitoring(SqlDB * db)
goto error_xml;
}
max_last_poll = last_poll - VirtualMachinePool::monitor_expiration();
oss << "DELETE FROM " << monit_table
<< " WHERE vmid = " << oid
<< " AND last_poll < (" << last_poll
<< " - " << VirtualMachinePool::vm_monitoring_history() << ")";
<< " AND last_poll < " << max_last_poll;
db->exec(oss);

View File

@ -24,7 +24,7 @@
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualMachinePool::_vm_monitoring_history;
time_t VirtualMachinePool::_monitor_expiration;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@ -35,7 +35,7 @@ VirtualMachinePool::VirtualMachinePool(
const string& hook_location,
const string& remotes_location,
vector<const Attribute *>& restricted_attrs,
int vm_monitoring_history)
time_t expire_time)
: PoolSQL(db, VirtualMachine::table, false)
{
const VectorAttribute * vattr;
@ -49,6 +49,8 @@ VirtualMachinePool::VirtualMachinePool(
bool state_hook = false;
_monitor_expiration = expire_time;
for (unsigned int i = 0 ; i < hook_mads.size() ; i++ )
{
vattr = static_cast<const VectorAttribute *>(hook_mads[i]);
@ -193,8 +195,6 @@ VirtualMachinePool::VirtualMachinePool(
// Set restricted attributes
VirtualMachineTemplate::set_restricted_attributes(restricted_attrs);
_vm_monitoring_history = vm_monitoring_history;
}
/* -------------------------------------------------------------------------- */