10.19. Monitoring Nodes and Virtual Environments via Zabbix

Note

The collected statistics are only intended for monitoring and are not suitable for billing purposes.

You can monitor nodes with Virtuozzo Hybrid Server 7.5 and newer as well as running VEs on them via Zabbix.

This guide describes how to install the Zabbix agent on a Virtuozzo Hybrid Server node and configure an existing Zabbix server. For details on installing Zabbix, see its documentation.

10.19.1. Installing the Zabbix Agent

Perform these steps on each Virtuozzo Hybrid Server 7.5 node that you want to monitor.

  1. Install the Zabbix repository. For example:

    # rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/\
    zabbix-release-5.0-1.el7.noarch.rpm
    # yum clean all
    
  2. Install the agent package:

    # yum install zabbix-agent
    
  3. Configure the Zabbix agent by editing /etc/zabbix/zabbix_agentd.conf as follows:

    Server=<zabbix_server_IP>
    ListenIP=<listen_IP>
    ServerActive=<zabbix_server_IP>
    Hostname=<hostname>
    Timeout=30
    AllowRoot=1
    

    Where:

    • Server and ServerActive are the Zabbix server IP address.
    • ListenIP is a node’s IP address that will listen for incoming connections from the Zabbix server.
    • Hostname is a unique name that must match the name you will use to register the host in the Zabbix web panel. It is recommended to use node’s actual hostname.
    • Timeout is increased to allow a heavily loaded node enough time to send the statistics data to the Zabbix server.
    • AllowRoot=1 is required to let the user zabbix collect statistics from the node.
  4. Add the user zabbix to sudoers. For example:

    # visudo
    zabbix  ALL=(ALL)   NOPASSWD: ALL
    
  5. Configure node’s firewall:

    # firewall-cmd --zone=public --permanent --add-port=10050-10051/tcp
    # firewall-cmd --reload
    
  6. Install the Virtuozzo module and template:

    # yum install vz-zabbix-agent
    

    The package will supply the following Zabbix XML template:

    # rpm -ql vz-zabbix-agent | grep xml
    /etc/zabbix/templates/zbx_virtuozzo_template.xml
    

    You will need to import it to the Zabbix web panel later.

  7. Enable and start the Zabbix agent:

    # systemctl enable zabbix-agent
    # systemctl start zabbix-agent
    

10.19.2. Configuring Zabbix Server

To see the data collected from the nodes, do the following in the Zabbix web panel:

  1. Navigate to Configuration -> Templates. Click Import and import zbx_virtuozzo_template.xml obtained in the previous section.
  2. Navigate to Configuration -> Hosts and click Create Host. In Host name enter the same name as specified in Hostname in zabbix_agentd.conf. Next, select a Group and provide agent network interface details in Interfaces. Specify other details if needed and click Add.
  3. Navigate to Configuration -> Hosts -> <host> -> Templates. Find “Template Virtuozzo” in Link new templates and click Update.

The statistics for the host will become available in the Zabbix web panel in a short while.

Optionally, you can filter out unnecessary metrics by excluding ploop mounts from mounted filesystem discovery. Zabbix performs it every hour by default in its Linux server template. Moreover, you can safely filter out vme network interfaces of virtual machines. Do the following:

  1. Navigate to Configuration -> Templates -> Template OS Linux by Zabbix agent -> Macros -> Inherited and template macros.

  2. Locate the macro {$VFS.FS.FSNAME.NOT_MATCHES}. Add /vz/root/| to its start. For example:

    ^(/vz/root/|/dev|/sys|/run|/proc|.+/shm$)
    

    Newly discovered ploops will be filtered out from now on. The statistics for the already discovered ploops will be dropped when the grace period is over. The grace period is 30 days by default. You can change it in the filesystem discovery rule.

  3. Locate the macro {$NET.IF.IFNAME.NOT_MATCHES} and add ^vme[0-9a-z]+| to its start. For example:

    (^vme[0-9a-z]+|$^Software Loopback Interface|^NULL[0-9.]*$|^[Ll]o[0-9.]*$|
    ^[Ss]ystem$|^Nu[0-9.]*$|^veth[0-9a-z]+$|docker[0-9]+|br-[a-z0-9]{12})
    

    Now newly discovered vme interfaces will be filtered out as well.