1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-08 21:17:43 +03:00

L #-: Monitor probes

This commit is contained in:
Ruben S. Montero 2020-03-24 13:24:22 +01:00
parent 739b463e65
commit 944f9ab7cf
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
7 changed files with 29 additions and 14 deletions

View File

@ -125,6 +125,8 @@ class ProbeRunner
# @return[Array] rc, data. rc 0 for success and data is the output of
# probes. If rc is -1 it signal failure and data is the error message of
# the failing probe
#
# rubocop:disable Lint/SuppressedException
def run_probes
data = ''
dpro = Dir.new(@path)
@ -167,6 +169,7 @@ class ProbeRunner
[0, data]
end
# rubocop:enable Lint/SuppressedException
# Singleton call for run_probes method
def self.run_once(hyperv, path, stdin)
@ -301,11 +304,14 @@ threads = []
probes.each do |msg_type, conf|
threads << Thread.new do
ProbeRunner.monitor_loop(hyperv, conf[:path], conf[:period], xml_txt) do |rc, da|
ProbeRunner.monitor_loop(hyperv,
conf[:path],
conf[:period],
xml_txt) do |result, da|
da.strip!
next if da.empty?
client.send(msg_type, rc == 0, da)
client.send(msg_type, result == 0, da)
end
end
end

View File

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and #
# limitations under the License. #
# -------------------------------------------------------------------------- #
# rubocop:disable Layout/ArgumentAlignment
ONE_LOCATION = ENV['ONE_LOCATION']
if !ONE_LOCATION
@ -42,12 +42,12 @@ def unindent(s)
end
hid = ARGV[1]
hname = ARGV[2]
_hname = ARGV[2]
client = OpenNebula::Client.new
vmpool = OpenNebula::VirtualMachinePool.new(client,
OpenNebula::VirtualMachinePool::INFO_ALL_VM)
OpenNebula::VirtualMachinePool::INFO_ALL_VM)
rc = vmpool.info
@ -71,10 +71,10 @@ vmpool.each do |vm|
base_net = Time.now.to_i % 10000
mon_s = unindent(<<-EOS)
NETTX=#{base_net+(50*rand(3))}
NETRX=#{base_net+(100*rand(4))}
MEMORY=#{max_memory * (rand(80)+20)/100}
CPU=#{max_cpu * (rand(95)+5)/100}
NETTX=#{base_net + (50 * rand(3))}
NETRX=#{base_net + (100 * rand(4))}
MEMORY=#{max_memory * rand(20..100)/100}
CPU=#{max_cpu * rand(5..100)/100}
DISKRDBYTES=#{rand(1000)}
DISKWRBYTES=#{rand(1000)}
DISKRDIOPS=#{rand(1000)}

View File

@ -9,6 +9,7 @@ require_relative '../../../lib/lxd'
# This module implements the functions needed by probe_db.rb
# -----------------------------------------------------------
module DomainList
# LXD to OpenNebula state mapping
STATE_MAP = {
'RUNNING' => 'RUNNING',

View File

@ -78,7 +78,7 @@ module NUMA
core_id = File.read("#{core_path}/core_id").chomp
nodes[node_id]['cores'] << { 'id' => core_id, 'cpus' => siblings }
nodes[node_id]['cores'] << {'id' => core_id, 'cpus' => siblings}
rescue StandardError
next
end

View File

@ -18,6 +18,9 @@
require_relative '../../../lib/numa_common'
#
# Module for monitoring host NUMA information
#
module NUMA
def self.node_to_template(node, nid)

View File

@ -101,9 +101,9 @@ class MicroVM
end
def get_pid
rc, stdout, = Command.execute("ps auxwww | grep " \
rc, stdout, = Command.execute('ps auxwww | grep ' \
"\"^.*firecracker.*--id['\\\"=[[:space:]]]*#{@one.vm_name}\" " \
"| grep -v grep", false)
'| grep -v grep', false)
if !rc.zero? || stdout.nil?
return -1

View File

@ -66,10 +66,15 @@ begin
drv_action,
vm_id)
if vm.instantiated_as_persistent?
oclient = OpenNebula::Client.new
template_id = vm.one_item['TEMPLATE/TEMPLATE_ID']
vm_template = OpenNebula::Template.new_with_id(template_id, OpenNebula::Client.new)
rc = vm_template.info()
vm_template = OpenNebula::Template.new_with_id(template_id, oclient)
rc = vm_template.info
raise if OpenNebula.is_error?(rc)
vm_template.lock(1)
end
end