mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-18 06:03:39 +03:00
B OpenNebula/one#6765: Improve QEMU Guest Agent monitoring. (#3328)
* Improve qemu-ga monitoring resilience * Add more commands to config files
This commit is contained in:
parent
8ff4b90453
commit
fcd8eb06e5
@ -8,5 +8,16 @@
|
||||
# The value will be run as a command executed with virsh qemu-agent-command
|
||||
# The $vm_id substring, if existing, will be replaced by the VM ID when the monitoring probes
|
||||
# are looping on each of the VMs on the host. Each command will be run once per VM.
|
||||
# The expected response for each command is a JSON string with a "return" key.
|
||||
# The contents of it will appear on the MONITORING message from the poll probe.
|
||||
:commands:
|
||||
:vm_qemu_ping: "one-$vm_id '{\"execute\":\"guest-ping\"}' --timeout 5"
|
||||
:vm_qemu_ping: one-$vm_id '{"execute":"guest-ping"}' --timeout 5
|
||||
# :guest_info: one-$vm_id '{"execute":"guest-info"}' --timeout 5
|
||||
# # The first non-loopback address
|
||||
# :vm_ip_address: >
|
||||
# one-$vm_id '{"execute":"guest-network-get-interfaces"}' --timeout 5 |
|
||||
# jq '{"return": [.return[] | select(."ip-addresses") | ."ip-addresses"[] | select(."ip-address-type"=="ipv4" and (."ip-address"|startswith("127.")|not))."ip-address"][0]}'
|
||||
# # Array of all IP addresses
|
||||
# :vm_ip_address_list: >
|
||||
# one-$vm_id '{"execute":"guest-network-get-interfaces"}' --timeout 5 |
|
||||
# jq '{"return" : [ .return[] | select(."ip-addresses") | ."ip-addresses"[]."ip-address" ]}'
|
||||
|
@ -350,7 +350,16 @@ class Domain < BaseDomain
|
||||
if s.exitstatus != 0
|
||||
@vm[ga_info] = e.chomp
|
||||
else
|
||||
@vm[ga_info] = JSON.parse(text)['return']
|
||||
begin
|
||||
info = JSON.parse(text)['return']
|
||||
|
||||
info = info.join(', ') if info.is_a?(Array)
|
||||
info = info.to_s.gsub(/["\[\]]/) { |match| "\\#{match}" } if info.is_a?(Hash)
|
||||
|
||||
@vm[ga_info] = info
|
||||
rescue JSON::ParserError => e
|
||||
@vm[ga_info] = "Failed to parse command output: #{e}"
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user