Monitoraggio ZFS in Zabbix: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
|||
| Line 36: | Line 36: | ||
* Creare lo script di collecting dei timestamp deglis napshot: | * Creare lo script di collecting dei timestamp deglis napshot: | ||
mkdir -p /etc/zabbix/scripts | mkdir -p /etc/zabbix/scripts | ||
<pre> | <pre> | ||
| Line 114: | Line 114: | ||
* Provare a lanciare manualmente lo script per il collecting dei timestamp: | * Provare a lanciare manualmente lo script per il collecting dei timestamp: | ||
sudo -u zabbix /etc/zabbix/scripts/zabbix-zfs-snapshot | sudo -u zabbix /etc/zabbix/scripts/zabbix-zfs-snapshot | ||
=Riferimenti= | =Riferimenti= | ||
*[http://dnaeon.github.io/monitoring-your-zfs-pools-in-zabbix/ Monitoring your ZFS pools in Zabbix – Marin Atanasov Nikolov – A place about Open Source Software, Operating Systems and some random thoughts] | *[http://dnaeon.github.io/monitoring-your-zfs-pools-in-zabbix/ Monitoring your ZFS pools in Zabbix – Marin Atanasov Nikolov – A place about Open Source Software, Operating Systems and some random thoughts] | ||
*[https://share.zabbix.com/operating-systems/linux/zfs-on-linux Zabbix Share - ZFS on Linux] | *[https://share.zabbix.com/operating-systems/linux/zfs-on-linux Zabbix Share - ZFS on Linux] | ||
Revision as of 17:49, 17 December 2018
Monitoraggio POOLs e Datasets
- Sul client, scaricare il file e scompattarlo
cd /tmp && \ wget "https://share.zabbix.com/index.php?option=com_mtree&task=att_download&link_id=350&cf_id=38" -O ZFSonLinux.zip && \ unzip ZFSonLinux.zip && \ cd ZFSonLinux
- Installare i files
mv ZFSonLinux_sudo_rules /etc/sudoers.d/ mv ZFSonLinux_userparameters.conf /etc/zabbix/zabbix_agentd.d/
- Verificare se i comandi funzionano (DATA è il nome di un pool zfs presente):
sudo -u zabbix /usr/bin/sudo /sbin/zpool list -H -o health DATA
- Riavviare zabbix_agent
systemctl restart zabbix-agent.service
- Dal server o dal prozy zabbix, verificare che le keys siano supportate:
zabbix_get -s 192.168.1.10 -k zfs.zpool.health[DATA]
- Importare il template ZFSonLinux_template.xml suls erver ed assegnare il template all'host
ZFSonLinux
- Definire la Regex in
Administration / General/ Regular Expression
Name: ZFS Fileset Expressions Expression type: Character string included Expression: /
Monitoraggio degli snapshot
- Per far questo, occorre utilizzare la versione customizzata del template Zabbix
- Creare lo script di collecting dei timestamp deglis napshot:
mkdir -p /etc/zabbix/scripts
cat > /etc/zabbix/scripts/zabbix-zfs-snapshot <<EOFile
#!/bin/bash
# Delay maximum half an hour
set -x
if [ -z "$1" ]
then
sleep $((RANDOM % 1800))
fi
# Clear temp file
/bin/rm -f /tmp/zfs-snapshot.dat.tmp
# Append lines in temp file
for DATASET in $(/usr/bin/sudo /sbin/zfs list \
| grep -v '^NAME' \
| /usr/bin/tr -s ' ' | /usr/bin/cut -f 1 --delimiter=' ')
do
TIMESTAMP=$(/usr/bin/sudo \
/sbin/zfs get creation -Hpr -t snapshot ${DATASET} \
| /usr/bin/cut -f 3 | /usr/bin/sort -n | /usr/bin/tail -n 1)
if [ -z "$TIMESTAMP" ]
then
DATETIME=""
else
DATETIME=$(/bin/date -d @$TIMESTAMP +"%Y-%m-%d %H:%M:%S")
fi
echo ${DATASET} $TIMESTAMP $DATETIME >> /tmp/zfs-snapshot.dat.tmp
done
# Substitute real file with temp file
mv /tmp/zfs-snapshot.dat.tmp /var/lib/zabbix/zfs-snapshot.dat
EOFile
chmod +x zabbix-zfs-snapshot
- Abilitarlo in cron:
cat > /etc/cron.d/zabbix-zfs-snapshot <<EOFile # Creates zfs snapshot time creation log file # #min hours DayOfMonth Month DayOfWeek user command # Incr backup mon-tue 0 * * * * zabbix /etc/zabbix/scripts/zabbix-zfs-snapshot EOFile
- Impostare il sudoers
cat > /etc/sudoers.d/zabbix-zfs-snapshot <<EOFile Defaults:zabbix !requiretty zabbix ALL=(ALL) NOPASSWD: /sbin/zfs EOFile
- Definire gli userparamters:
cat > /etc/zabbix/zabbix_agentd.d/zfs-snapshot.conf <<EOFile UserParameter=zfs.snapshot.time[*],/bin/cat /var/lib/zabbix/zfs-snapshot.dat | grep $1 | /usr/bin/cut --delimiter=' ' -f 2 EOFile
- Assicurarsi che ci sia la homedir di zabbix:
mkdir -p /var/lib/zabbix chown zabbix:zabbix /var/lib/zabbix
- Riavviare zabbix agent
systemctl restart zabbix-agent.service
- Provare a lanciare manualmente lo script per il collecting dei timestamp:
sudo -u zabbix /etc/zabbix/scripts/zabbix-zfs-snapshot