File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 88# The value will be run as a command executed with virsh qemu-agent-command
99# The $vm_id substring, if existing, will be replaced by the VM ID when the monitoring probes
1010# are looping on each of the VMs on the host. Each command will be run once per VM.
11+ # The expected response for each command is a JSON string with a "return" key.
12+ # The contents of it will appear on the MONITORING message from the poll probe.
1113:commands:
12- :vm_qemu_ping: "one-$vm_id '{\"execute\":\"guest-ping\"}' --timeout 5"
14+ :vm_qemu_ping: one-$vm_id '{"execute":"guest-ping"}' --timeout 5
15+ # :guest_info: one-$vm_id '{"execute":"guest-info"}' --timeout 5
16+ # # The first non-loopback address
17+ # :vm_ip_address: >
18+ # one-$vm_id '{"execute":"guest-network-get-interfaces"}' --timeout 5 |
19+ # jq '{"return": [.return[] | select(."ip-addresses") | ."ip-addresses"[] | select(."ip-address-type"=="ipv4" and (."ip-address"|startswith("127.")|not))."ip-address"][0]}'
20+ # # Array of all IP addresses
21+ # :vm_ip_address_list: >
22+ # one-$vm_id '{"execute":"guest-network-get-interfaces"}' --timeout 5 |
23+ # jq '{"return" : [ .return[] | select(."ip-addresses") | ."ip-addresses"[]."ip-address" ]}'
Original file line number Diff line number Diff line change @@ -350,7 +350,16 @@ def ga_stats
350350 if s . exitstatus != 0
351351 @vm [ ga_info ] = e . chomp
352352 else
353- @vm [ ga_info ] = JSON . parse ( text ) [ 'return' ]
353+ begin
354+ info = JSON . parse ( text ) [ 'return' ]
355+
356+ info = info . join ( ', ' ) if info . is_a? ( Array )
357+ info = info . to_s . gsub ( /["\[ \] ]/ ) { |match | "\\ #{ match } " } if info . is_a? ( Hash )
358+
359+ @vm [ ga_info ] = info
360+ rescue JSON ::ParserError => e
361+ @vm [ ga_info ] = "Failed to parse command output: #{ e } "
362+ end
354363 end
355364 end
356365 else
You can’t perform that action at this time.
0 commit comments