Abilitare le notifiche via mail in Nut UPS

From RVM Wiki
Revision as of 17:32, 19 October 2010 by Gabriele.vivinetto (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  • Installare mail
sudo aptitude install mailx
  • Definire ild estinatario dei messaggi:
export RECIPIENT="gal-alert@rvmgroup.it"
  • Cambiare la descrizione dell'utente Nut
sudo usermod -c "Nut UPS ${HOSTNAME}" nut
  • Impostare il sender address in postfix
echo -e "nut\t${RECIPIENT}" | sudo tee -a /etc/postfix/canonical_maps > /dev/null
cd /etc/postfix
sudo postmap canonical_maps
sudo invoke-rc.d postfix restart
  • Abilitare le notifiche e definire il comando da eseguire:
cat | sudo tee -a /etc/nut/upsmon.conf > /dev/null <<EOFile

NOTIFYCMD /usr/local/bin/nut-notify

NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
EOFile


  • Creare lo script di notifica
cat | sudo tee /usr/local/bin/nut-notify > /dev/null << EOFile
#!/bin/sh
echo "$*" | mail -s "${HOSTNAME} UPS Notice" ${RECIPIENT}
EOFile
sudo chmod +x /usr/local/bin/nut-notify
  • Riavviare Nut
sudo invoke-rc.d nut restart


  • NOTA: È possibile usare upssched se si vogliono mandare gli alter solo dopo un tot tempo (Vedi Riferimenti)

Riferimenti