Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KVM: Monitor VM IP address using qemu-guest-agent #6762

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" ]}'