Add Healthchecks service details to architecture and backup documentation, including its role as a Dead man's switch for backups. Update backup scripts to utilize systemd timers instead of cron for improved scheduling. Enhance network topology documentation to reflect Healthchecks integration in the VPS Miran setup. This update clarifies backup processes and enhances overall system reliability.
110 lines
3.4 KiB
Markdown
110 lines
3.4 KiB
Markdown
# SMART и smartd — мониторинг дисков
|
||
|
||
Настройка `smartd` для мониторинга дисков Proxmox: NVMe, HDD, SSD. При отклонениях — уведомление в Telegram через `notify-telegram.sh`.
|
||
|
||
---
|
||
|
||
## Диски (из контекста homelab)
|
||
|
||
| Устройство | Тип | Размер | Использование |
|
||
|--------------|------|--------|----------------------------------|
|
||
| /dev/nvme0n1 | NVMe | 256 GB | LVM (система, local-lvm) |
|
||
| /dev/sda | HDD | 2 TB | ZFS |
|
||
| /dev/sdb | SSD | 2 TB | ext4, /mnt/backup |
|
||
| /dev/sdc | HDD | 2 TB | ZFS (RAID1 с sda) |
|
||
| /dev/sdd | HDD | 8 TB | ext4 (внешний) |
|
||
|
||
---
|
||
|
||
## Установка
|
||
|
||
```bash
|
||
apt install -y smartmontools
|
||
```
|
||
|
||
---
|
||
|
||
## Конфигурация smartd
|
||
|
||
Файл: `/etc/smartd.conf`. Текущая конфигурация на хосте:
|
||
|
||
```conf
|
||
# NVMe (система)
|
||
/dev/nvme0n1 -a -W 4,45,55 -m root -M exec /root/scripts/smartd-notify.sh
|
||
|
||
# HDD sda (ZFS)
|
||
/dev/sda -a -d ata -R 5 -R 197 -R 198 -W 4,45,55 -m root -M exec /root/scripts/smartd-notify.sh
|
||
|
||
# SSD sdb (backup)
|
||
/dev/sdb -a -d ata -R 5 -R 197 -R 198 -W 4,45,55 -m root -M exec /root/scripts/smartd-notify.sh
|
||
|
||
# HDD sdc (ZFS)
|
||
/dev/sdc -a -d ata -R 5 -R 197 -R 198 -W 4,45,55 -m root -M exec /root/scripts/smartd-notify.sh
|
||
|
||
# HDD sdd (внешний, USB/SAT)
|
||
/dev/sdd -a -d sat -R 5 -R 197 -R 198 -W 4,45,55 -m root -M exec /root/scripts/smartd-notify.sh
|
||
```
|
||
|
||
**Параметры:**
|
||
- `-a` — мониторить все атрибуты
|
||
- `-d ata` / `-d sat` — тип устройства (ata для SATA, sat для USB/SAT)
|
||
- `-R 5` — Reallocated_Sector_Ct
|
||
- `-R 197` — Current_Pending_Sector
|
||
- `-R 198` — Offline_Uncorrectable
|
||
- `-W 4,45,55` — температура: delta 4°C, warn 45°C, crit 55°C
|
||
- `-M exec` — выполнить скрипт при проблеме
|
||
|
||
---
|
||
|
||
## Скрипт уведомления в Telegram
|
||
|
||
Создать `/root/scripts/smartd-notify.sh`:
|
||
|
||
```bash
|
||
#!/bin/bash
|
||
# Вызывается smartd при обнаружении проблемы.
|
||
# Аргументы: device, type (health/usage/fail), message
|
||
# См. man smartd.conf (-M exec)
|
||
|
||
NOTIFY_SCRIPT="${NOTIFY_SCRIPT:-/root/scripts/notify-telegram.sh}"
|
||
DEVICE="${1:-unknown}"
|
||
# smartd передаёт полный вывод в stdin
|
||
MSG=$(cat)
|
||
SUMMARY="${2:-SMART problem}"
|
||
|
||
if [ -x "$NOTIFY_SCRIPT" ]; then
|
||
"$NOTIFY_SCRIPT" "⚠️ SMART" "Диск $DEVICE: $SUMMARY
|
||
|
||
$MSG" || true
|
||
fi
|
||
|
||
# Передать дальше в mail (если настроен)
|
||
exit 0
|
||
```
|
||
|
||
Сделать исполняемым: `chmod +x /root/scripts/smartd-notify.sh`
|
||
|
||
**Примечание:** smartd при `-M exec` передаёт в скрипт до 3 аргументов и stdin. Точный формат см. в `man smartd.conf` (раздел -M exec).
|
||
|
||
---
|
||
|
||
## Запуск smartd
|
||
|
||
```bash
|
||
systemctl enable --now smartd
|
||
systemctl status smartd
|
||
```
|
||
|
||
Проверка вручную:
|
||
|
||
```bash
|
||
smartctl -a /dev/sda
|
||
smartctl -a /dev/nvme0n1
|
||
```
|
||
|
||
---
|
||
|
||
## Интеграция с Netdata
|
||
|
||
Netdata имеет плагин smartmontools. После установки smartmontools и настройки smartd Netdata может отображать метрики SMART на дашборде. См. [netdata-proxmox-setup.md](netdata-proxmox-setup.md).
|