Abilitare le notifiche via mail in Nut UPS: Difference between revisions

From RVM Wiki
Jump to navigation Jump to search
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
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 23: Line 32:
EOFile
EOFile
</pre>
</pre>


* Creare lo script di notifica
* Creare lo script di notifica
Line 28: Line 38:
cat | sudo tee /usr/local/bin/nut-notify > /dev/null << EOFile
cat | sudo tee /usr/local/bin/nut-notify > /dev/null << EOFile
#!/bin/sh
#!/bin/sh
echo "$*" | mail -s "${HOSTNAME} UPS Notice" gal-alert@rvmgroup.it
echo "$*" | mail -s "${HOSTNAME} UPS Notice" ${RECIPIENT}
EOFile
EOFile
</pre>
</pre>
Line 35: Line 45:


* Riavviare Nut
* Riavviare Nut
sudo invoke-rc.d nut restart


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


==Riferimenti==
==Riferimenti==
*[http://www.interphero.com/?p=139 Make your UPS email you with NUT | Interphero Miscellany]
*[http://www.interphero.com/?p=139 Make your UPS email you with NUT | Interphero Miscellany]
*[http://articles.techrepublic.com.com/5100-10878_11-6040972.html Customize UPS-related alerts in NUT]
*[http://articles.techrepublic.com.com/5100-10878_11-6040972.html Customize UPS-related alerts in NUT]

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)

Riferimenti