KVM Libvirt Integration

Created by Kristaps Felzenbergs, Modified on Mon, 26 Aug at 4:25 PM by Kristaps Felzenbergs

This article aims to describe the steps required to setup the KVM Libvirt integration with Opvizor


To enable the monitoring for your KVM virtualization environment we have two options - agent or agent-less approach.


Going the agent-less way


1. Create a new user account and add it to the libvirt group

useradd opvizor
usermod -aG libvirt opvizor


2. Generate a RSA keypair

ssh-keygen -t RSA ~/.ssh/id_rsa_opvizor


3. Prepare the key

cat ~/.ssh/id_rsa_opvizor | base64 -w0


4. Set the credentials in Opvizor


Completing this you are done. Within a couple of minutes the data will start to flow in.


Installing the agent (optional)


1. Install Telegraf

# on debian based systems
apt install telegraf

# on centos / alma linux based systems
yum install telegraf


2. Adjust the configuration 


Note the endpoint "localhost:9086" within the outputs section, you have to change it to your Opvizor IP/domain.

# Global tags can be specified here in key="value" format.
[global_tags]
  # dc = "us-east-1" # will tag all metrics with dc=us-east-1
  # rack = "1a"
  ## Environment variables can be used as tags, and throughout the config file
  # user = "$USER"


# Configuration for telegraf agent
[agent]
  interval = "60s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "60s"
  flush_jitter = "0s"
  precision = ""
  debug = false
  quiet = false
  hostname = ""
  omit_hostname = false


### OUTPUT

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
  urls = ["http://localhost:8086"]
  database = "telegraf"

  ## Retention policy to write to. Empty string writes to the default rp.
  retention_policy = ""
  ## Write consistency (clusters only), can be: "any", "one", "quorum", "all"
  write_consistency = "any"

  ## Write timeout (for the InfluxDB client), formatted as a string.
  ## If not provided, will default to 5s. 0s means no timeout (not recommended).
  timeout = "5s"
  # username = "telegraf"
  # password = "2bmpiIeSWd63a7ew"
  ## Set the user agent for HTTP POSTs (can be useful for log differentiation)
  # user_agent = "telegraf"
  ## Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
  # udp_payload = 512

[[inputs.libvirt]]
  interval = "30s"
  # domain_names = [""]
  libvirt_uri = "qemu+ssh://root@192.168.100.97/system?keyfile=/etc/telegraf/id_rsa_libvirt&no_verify=1"
  additional_statistics = ["vcpu_mapping"]


3. Start the service

systemct restart telegraf



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article