UPS (networkupstools - nut)

Provvisorio

  • Update 11:38

Nel senso che per ora sono arrivato fino a qua, inviare mail quando succede qualcosa, poi vedro` secondo necessita`.

 

Premesso che avendo l'UPS comprensivo di porte USB per ricarica cellulare, ci ho collegato un Raspberry Pi per gestirselo.

OS

Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

Installazione

apt install nut mutt

 

Configurazione

Editazioni e modifiche dei files di configurazione

 

/etc/nut/nut.conf

MODE=standalone

 

/etc/nut/ups.conf

[tecnoware]
    driver = blazer_usb
    langid_fix=0x409
    port = auto
    desc = "Server"

#maxretry = 3

 

/etc/nut/upsd.users

    [pi]
        password  = <password in chiaro>
        upsmon master

 

/etc/nut/upmon.conf

RUN_AS_USER pi

MONITOR tecnoware@localhost 1 pi <PASSWORD> master

NOTIFYCMD /home/pi/bin/upsnotify.sh

NOTIFYFLAG ONLINE       SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT       SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT      SYSLOG+WALL+EXEC
NOTIFYFLAG FSD  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 NOPARENT     SYSLOG+WALL+EXEC

 

/home/pi/bin/upsnotify.sh (new)

#!/bin/bash
echo "$*" | mutt -s "Notifica UPS" <indirizzo mail destinazione>

 

 

.muttrc (user pi)

set index_format="%4C %Z %{%b %d} %-16.16L  %s"

color hdrdefault cyan black
color quoted magenta black
color signature brightred black
color indicator brightyellow red
color error brightred black
color status brightyellow blue
color tree brightmagenta black  # the thread tree in the index menu
color tilde brightmagenta black
color message brightcyan black
color normal white black
color attachment brightmagenta black
color search black green        # how to hilite search patterns in the pager
color header brightyellow black ^(From|Subject):
color body brightyellow black "(ftp|http)://[^ ]+"      # point out URLs
color body brightcyan black [-a-z_0-9.]+@[-a-z_0-9.]+   # e-mail addresses
color underline brightgreen black

set sort=threads
set editor=vi

set imap_user="USERNAME@gmail.com"
set imap_pass="PASSWORD"
set folder="imaps://imap.gmail.com:993"
set spoolfile="+INBOX"
set postponed="+[Gmail]/Drafts"
set header_cache="~/.mutt/cache/headers"
set message_cachedir="~/.mutt/cache/bodies
set certificate_file="~/.mutt/certificates
set smtp_url="smtp://USERNAME@smtp.gmail.com:587/"
set smtp_pass="PASSWORD"
set move=no
set imap_keepalive="900"

ignore *
unignore  Date To From: Subject X-Mailer Organization User-Agent
hdr_order Date From To Subject X-Mailer User-Agent Organization

 

/home/pi/bin/alivenotify.sh (new)

#!/bin/bash
echo "I'm alive $(hostname)" | mutt -s "Alive UPS Raspberry Pi" <indirizzo mail di destinazione>

 

crontab

crontab -e

1 1 * * 0 /home/pi/bin/alivenotify.sh