From 047c32025c6eb5d504b61feaadfa3c493e28d83b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 12 Jun 2019 18:50:49 +0200 Subject: [PATCH] F #1324: Configure update interval of VM monitor data --- src/nebula/NebulaTemplate.cc | 2 ++ src/vmm/VirtualMachineManagerDriver.cc | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc index 4a3f4d012b..4f5fbe6a7a 100644 --- a/src/nebula/NebulaTemplate.cc +++ b/src/nebula/NebulaTemplate.cc @@ -417,6 +417,7 @@ void OpenNebulaTemplate::set_conf_default() # MONITORING_INTERVAL_VM # MONITORING_INTERVAL_MARKET # MONITORING_INTERVAL_DATASTORE +# MONITORING_INTERVAL_DB_UPDATE # MONITORING_THREADS # HOST_PER_INTERVAL # HOST_MONITORING_EXPIRATION_TIME @@ -437,6 +438,7 @@ void OpenNebulaTemplate::set_conf_default() set_conf_single("MONITORING_INTERVAL_VM", "180"); set_conf_single("MONITORING_INTERVAL_MARKET", "600"); set_conf_single("MONITORING_INTERVAL_DATASTORE", "300"); + set_conf_single("MONITORING_INTERVAL_DB_UPDATE", "0"); set_conf_single("MONITORING_THREADS", "50"); set_conf_single("HOST_PER_INTERVAL", "15"); set_conf_single("HOST_MONITORING_EXPIRATION_TIME", "43200"); diff --git a/src/vmm/VirtualMachineManagerDriver.cc b/src/vmm/VirtualMachineManagerDriver.cc index b6fb8e5cea..cbb4541e43 100644 --- a/src/vmm/VirtualMachineManagerDriver.cc +++ b/src/vmm/VirtualMachineManagerDriver.cc @@ -711,6 +711,7 @@ void VirtualMachineManagerDriver::process_poll(VirtualMachine* vm, const string& monitor_str) { char state; + time_t update_time; Nebula &ne = Nebula::instance(); @@ -720,8 +721,10 @@ void VirtualMachineManagerDriver::process_poll(VirtualMachine* vm, /* ---------------------------------------------------------------------- */ /* Update VM info only for VMs in ACTIVE */ /* ---------------------------------------------------------------------- */ + ne.get_configuration_attribute("MONITORING_INTERVAL_DB_UPDATE", update_time); - if (vm->get_state() == VirtualMachine::ACTIVE) + if (vm->get_state() == VirtualMachine::ACTIVE && update_time != -1 && + (time(0) - vm->get_last_poll() > update_time)) { if (vm->update_info(monitor_str) == 0) {