Oct 312016

I have a ProxMox hypervisor host with a disk setup as LVM thin provisioning. This means that I could potentially fill up the LVM partition and run out of space, the guests won’t be able to write to disk, and it’ll all come crashing down…or already has.

In any case, I needed to set up some monitoring on the LVM partition so that this didn’t happen again. The problem there is that LVM’s free extents aren’t typically shown unless you ask for it, and the command that shows it also requires root privileges.

After some googling, I found out that you can use setcap to allow a non-root user to run the vgs command, and get the required information.
From the referenced link below, I used the following command to set the capabilities. I’ve probably set more than required, but it works and I haven’t had time to determine exactly which capabilities is required.
To set the capability, run the following command as root:

setcap "cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_admin,cap_sys_chroot,cap_sys_admin,cap_sys_resource,cap_audit_control,cap_setfcap=+eip" /sbin/lvm

However, running it on /sbin/lvm will allow a non-root user to execute any lvm related command so use this with care.

Once the capabilities are set, we’ll need to then create an item on the Zabbix server. This item requires a Zabbix Agent so make sure that you have an agent installed on the machine that requires the LVM monitoring.

The item can be either a Zabbix Agent type, or a Zabbix Agent (Active) type.
The key will be similar to the following:
system.run["vgs pve --units b --rows --nosuffix 2>/dev/null | grep VFree | awk -F ' ' ' { print $2 } '"]
You will need to replace pve in the key above with the Volume Group Name that you need to monitor.

The rest of the item can be configured as per this screenshot:

Item Configuration

Item Configuration

Customise the Update Interval, History, and Trend Storage to your needs. Once the item is setup, you can check to make sure you’re getting data via the Latest Data page.



 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>