Skip to content

Commit

Permalink
KVM: Monitor VM IP address using qemu-guest-agent
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitrios Apostolou <[email protected]>
  • Loading branch information
jimis committed Oct 29, 2024
1 parent d5b5a4d commit 10f2fbb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/im_mad/remotes/kvm-probes.d/guestagent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
# enable or disable monitoring information from the qemu guest agent.
:enabled: false
# Commands used to gather VM information.
# Each command key will appear on the MONITORING message from the poll probe
# 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"
# The first non-loopback address
:vm_ip_address: >
one-$vm_id '{"execute":"guest-network-get-interfaces"}' --timeout 5 |
jq '{"return" : [ .return[]."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[]."ip-addresses"[]."ip-address" ]}'

0 comments on commit 10f2fbb

Please sign in to comment.