Abilitare le notifiche via mail in Nut UPS: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| Line 1: | Line 1: | ||
* Installare mail | * Installare mail | ||
sudo aptitude install mailx | sudo aptitude install mailx | ||
* Definire ild estinatario dei messaggi: | |||
export RECIPIENT="gal-alert@rvmgroup.it" | |||
* Cambiare la descrizione dell'utente Nut | * Cambiare la descrizione dell'utente Nut | ||
sudo usermod -c "Nut UPS ${HOSTNAME}" 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: | * Abilitare le notifiche e definire il comando da eseguire: | ||
| Line 24: | Line 33: | ||
</pre> | </pre> | ||
* Creare lo script di notifica | * Creare lo script di notifica | ||
Latest revision as of 17:32, 19 October 2010
- 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)