Skip to content

Instantly share code, notes, and snippets.

@githubfoam
Last active October 9, 2025 13:44
Show Gist options
  • Select an option

  • Save githubfoam/21fd006e6a5522b62fe81c4eeea2182f to your computer and use it in GitHub Desktop.

Select an option

Save githubfoam/21fd006e6a5522b62fe81c4eeea2182f to your computer and use it in GitHub Desktop.
zabbix experience
#=====================================================================
~$ cat collect_zabbix_disk_io_info.sh
#!/bin/bash
# ===============================================================
# Zabbix Disk I/O Diagnostics Collector
# ===============================================================
OUTPUT_DIR="/tmp"
HOSTNAME=$(hostname)
DATE=$(date '+%Y-%m-%d_%H-%M-%S')
OUTPUT_FILE="$OUTPUT_DIR/zabbix_disk_io_diagnostics_${HOSTNAME}_${DATE}.log"
echo "Collecting Zabbix Disk I/O diagnostic data..."
echo "Output will be saved to: $OUTPUT_FILE"
sleep 1
{
echo "=============================================================="
echo "Zabbix Disk I/O Diagnostics Report"
echo "Host: $HOSTNAME"
echo "Date: $(date)"
echo "=============================================================="
echo
# 1. System Info
echo "[1] System Information"
echo "--------------------------------------------------------------"
uname -a
lsb_release -a 2>/dev/null
uptime
echo
# 2. Disk I/O Statistics
echo "[2] Disk I/O Statistics (iostat -x 1 5)"
echo "--------------------------------------------------------------"
if command -v iostat >/dev/null 2>&1; then
iostat -x 1 5
else
echo "iostat not installed. Install via: sudo apt install sysstat -y"
fi
echo
# 3. Current Load and I/O Wait
echo "[3] Current Load and CPU I/O Wait"
echo "--------------------------------------------------------------"
top -b -n1 | head -20
echo
vmstat 1 5
echo
# 4. Top I/O-consuming Processes
echo "[4] Top I/O-consuming Processes (iotop -b -n3 -o if available)"
echo "--------------------------------------------------------------"
if command -v iotop >/dev/null 2>&1; then
sudo iotop -b -n3 -o
else
echo "iotop not installed. Install via: sudo apt install iotop --no-install-recommends"
fi
echo
# 5. Disk Usage and Inodes
echo "[5] Filesystem Disk Usage"
echo "--------------------------------------------------------------"
df -h
echo
echo "[5.1] Filesystem Inode Usage"
echo "--------------------------------------------------------------"
df -i
echo
# 6. Swap Usage
echo "[6] Memory and Swap Usage"
echo "--------------------------------------------------------------"
free -h
echo
cat /proc/swaps
echo
grep -i swappiness /etc/sysctl.conf /etc/sysctl.d/* 2>/dev/null || echo "vm.swappiness: $(cat /proc/sys/vm/swappiness)"
echo
# 7. Disk Scheduler and Type
echo "[7] Disk Scheduler and Type"
echo "--------------------------------------------------------------"
for DISK in /sys/block/sd*; do
DEV=$(basename "$DISK")
echo "Device: /dev/$DEV"
echo -n " Scheduler: "
cat "$DISK/queue/scheduler"
echo -n " Rotational (1=HDD, 0=SSD): "
cat "$DISK/queue/rotational"
echo
done
echo
# 8. SMART Health
echo "[8] SMART Health Information"
echo "--------------------------------------------------------------"
if command -v smartctl >/dev/null 2>&1; then
for DISK in /dev/sd?; do
echo "SMART for $DISK"
sudo smartctl -a "$DISK" | grep -E "Model|Serial|Reallocated_Sector|Pending_Sector|Offline_Uncorrectable" || echo "SMART data not available for $DISK"
echo
done
else
echo "smartctl not installed. Install via: sudo apt install smartmontools -y"
fi
echo
# 9. Zabbix Database Type and High-I/O Directory Sizes
echo "[9] Zabbix Database and High-I/O Directory Sizes"
echo "--------------------------------------------------------------"
ZABBIX_CONF="/etc/zabbix/zabbix_server.conf"
DB_TYPE=""
if [ -f "$ZABBIX_CONF" ]; then
DB_TYPE=$(grep -i "^DBType=" "$ZABBIX_CONF" | cut -d'=' -f2 | tr '[:upper:]' '[:lower:]')
fi
# Default guess if not set
if [ -z "$DB_TYPE" ]; then
if dpkg -l | grep -iq 'mysql\|mariadb'; then
DB_TYPE="mysql"
elif dpkg -l | grep -iq 'postgresql'; then
DB_TYPE="postgresql"
fi
fi
echo "Detected Zabbix DB Type: ${DB_TYPE:-unknown}"
echo
case "$DB_TYPE" in
mysql)
DB_DIR="/var/lib/mysql"
;;
postgresql)
DB_DIR="/var/lib/postgresql"
;;
*)
DB_DIR=""
echo "Could not determine Zabbix database type, skipping DB directory check."
;;
esac
if [ -n "$DB_DIR" ]; then
if [ -d "$DB_DIR" ]; then
echo "Database directory exists: $DB_DIR"
du -sh "$DB_DIR"
else
echo "Database directory does not exist: $DB_DIR"
fi
fi
# Check other high-I/O directories
for DIR in /var/lib/zabbix /var/log /tmp; do
if [ -d "$DIR" ]; then
echo "Directory: $DIR"
du -sh "$DIR"
else
echo "Directory: $DIR does not exist"
fi
done
echo
# 10. Virtualization Environment
echo "[10] Virtualization / Cloud Environment"
echo "--------------------------------------------------------------"
systemd-detect-virt
echo "dmidecode -s system-manufacturer (if available):"
sudo dmidecode -s system-manufacturer 2>/dev/null || echo "dmidecode not available"
echo
echo "=============================================================="
echo "End of Zabbix Disk I/O Diagnostics Report"
echo "=============================================================="
} | tee "$OUTPUT_FILE"
echo
echo "Diagnostic data collection complete."
echo "File saved at: $OUTPUT_FILE"
echo "Share this file with your support team as needed."
echo
#=====================================================================
zabbix 7.2 on debian bookworm
#A non-root user with an administrator user
#Installing PostgreSQL Server
sudo apt update
sudo apt install postgresql postgresql-contrib -y
sudo systemctl is-enabled postgresql && sudo systemctl status postgresql
#Creating PostgreSQL Database and User
#enter the password for your database user and repeat when prompted
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix
#Installing Zabbix
wget https://repo.zabbix.com/zabbix/7.2/release/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.2+debian12_all.deb
sudo dpkg -i zabbix-release_latest_7.2+debian12_all.deb
sudo apt update
sudo apt install zabbix-server-pgsql zabbix-frontend-php php8.2-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent -y
#Integrating Zabbix with PostgreSQL
#Import the database schema for Zabbix to the 'zabbix' database with the user 'zabbix'. Enter your 'zabbix' password when prompted.
zcat /usr/share/zabbix/sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
sudo nano /etc/zabbix/zabbix_server.conf
#Uncomment the default 'DBHost', 'DBName', 'DBUser', and 'DBPassword'
DBHost = localhost
DBName = zabbix
DBUser = zabbix
# set new password
DBPassword = password
13 sudo nano /etc/zabbix/nginx.conf
listen 8080;
server_name zabbix72;
14 sudo nginx -t
15 sudo systemctl enable zabbix-server zabbix-agent nginx php8.2-fpm
16 sudo systemctl restart zabbix-server zabbix-agent nginx php8.2-fpm
17 sudo systemctl status zabbix-server zabbix-agent nginx php8.2-fpm
#=====================================================================
18 locale -a
19 sudo nano /etc/locale.gen
enable (starting "EN_US")
en_US.UTF-8
20 sudo locale-gen
23 locale
#=====================================================================
problem:
web interface, first time setup
'ICMP ping' checks failed: "At least one of '/usr/sbin/fping', '/usr/sbin/fping6' must exist. Both are missing in the system
fix:
40 sudo nano /etc/zabbix/zabbix_server.conf
41 sudo systemctl status zabbix-server
enable
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6
Fping6Location
The location of fping6. Make sure that the fping6 binary has root ownership and the SUID flag set. Make empty ("Fping6Location=") if your fping utility is capable to process IPv6 addresses.
Default: /usr/sbin/fping6
FpingLocation
The location of fping. Make sure that the fping binary has root ownership and the SUID flag set.
Default: /usr/sbin/fping
https://www.zabbix.com/documentation/current/en/manual/appendix/config/zabbix_server#fping6location
#=====================================================================
#zabbix server
https:// localhost:8080
#=====================================================================
sudo tail -f /var/log/zabbix/zabbix_server.log
#=====================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment