Monitoring LVM Thin Volume Pool using Zabbix

From Notes_Wiki

Home > Debian > Proxmox virtual environment > Monitoring LVM Thin Volume Pool using Zabbix

We can Monitor LVM Thin Volume Pool using Zabbix custom script

Create a new script in zabbix folder

# nano /etc/zabbix/script.sh

Script

#!/bin/bash

# Get LVM thin pool usage
disk_usage=$(sudo lvdisplay -v /dev/ssdvg/ssdlv | grep "Allocated pool data" | awk '{print $4}' | tr -d '%')

# Output the numeric value
echo "$disk_usage"

# Check if usage exceeds threshold (e.g., 80%)
if (( $(echo "$disk_usage > 80" | bc -l) )); then
    exit 1
fi

exit 0

make the script executable and change owner to zabbix user

# chmod +x /etc/zabbix/script.sh

# chown -R zabbix:zabbix /etc/zabbix/script.sh

Install sudo package

# apt install sudo

Edit the configuration file

# nano /etc/zabbix/zabbix_agentd.conf

add the following lines at the bottom in the following positions

### Option: EnableRemoteCommands - Deprecated, use AllowKey=system.run[*] or DenyKey=system.run[*] instead
 AllowKey=system.run[*]

### Option: UnsafeUserParameters
 UnsafeUserParameters=1

### Option: UserParameter
 UserParameter=custom.script,/etc/zabbix/script.sh