Monitoring - marco1475/linux-htpc GitHub Wiki
-
Install
msmtp
andmsmtp-mta
:pacman -S msmtp msmtp-mta
-
Create the
/etc/msmtprc
configuration file:# Example for a system wide configuration file # A system wide configuration file is optional. # If it exists, it usually defines a default account. # This allows msmtp to be used like /usr/sbin/sendmail. account default # The SMTP smarthost. host smtp.gmail.com port 587 from [email protected] user [email protected] password <password> # Construct envelope-from addresses of the form "[email protected]". #auto_from on #maildomain oursite.example # Use TLS. auth on tls on tls_starttls on tls_trust_file /etc/ssl/certs/ca-certificates.crt # Syslog logging with facility LOG_MAIL instead of the default LOG_USER. syslog LOG_MAIL # Aliases aliases /etc/aliases
-
Set the correct file permissions for
/etc/msmtprc
, otherwisemsmtp
will fail:chmod 644 /etc/msmtprc
-
To be able to use GMail's SMTP server you either need to allow "Less Secure Apps" in
Settings
>Security
or enable 2-factor authentication and use an app password.
-
-
Create the
/etc/aliases
configuration file:root: [email protected] marco1475: [email protected]
-
Test the functionality by sending an e-mail:
echo "Hello there from Babylon 5 Server." | msmtp -a default [email protected]
-
Install the
lm_sensors
package:pacman -S lm_sensors
-
Run
sensors-detect
and hitEnter
to accept all the defaults, which will generate the following/etc/conf.d/lm_sensors
file:HWMON_MODULES="coretemp nct6775"
-
You can run the
sensors
command to test whether the sensors work.
-
Install the
smartmontools
andhddtemp
packages:pacman -S smartmontools hddtemp
-
You can run the
hddtemp /dev/sd(b|c)
command to make sure the spinning drives' sensors work and thesmartctl -a /dev/sda
command to get the S.M.A.R.T. information, including the temperature, of the SSD. -
Set up the
smartd
daemon to monitor the drives' S.M.A.R.T. attributes:-
Edit the
/etc/smartd.conf
configuration file:DEVICESCAN -a -m [email protected] -n standby,24,q -o on -s (S/../../1/12|L/../01/./09) -S on -W 4,40,45
-
-a
monitor all attributes -
-m
send alert e-mails to[email protected]
(add-M test
to send a test e-mail when the service starts) -
-n
do not check attributes when the disk is instandby
mode (or any lower mode, such asoff
orsleep
), unless it happened24
times, but beq
uiet about missing the attribute checks (do not log them) -
-o
automatic offline data collection ison
-
-s
schedule a short test every Monday at noon and a long test every 1st of the month at 9am (T/MM/DD/d/HH
, i.e. type, month, day, day of the week, hour) -
S
automatic attribute autosave ison
-
W
warn about temperature changes of4
degrees or more between runs, log when the temperature reaches40
degrees, and log and e-mail if the temperature reaches45
degrees
-
-
Create the
/etc/default/smartmontools
file to change the default frequency of status checks from 1800 seconds (30 minutes) to 3600 seconds (1 hour):SMARTD_ARGS="-i 21600" Check status every 21600 seconds (3 hours)
-
Run the daemon:
systemctl start smartd.service
-
Check the status of the service and the log for any errors:
systemctl status smartd.service journalctl -u smartd
-
Add the
smartd
daemon to the startup sequence:systemctl enable smartd.service
-
-
Copy
compose_email.sh
,cpu_temperature.sh
,hdd_temperature.sh
,raid_check.sh
,send_interval_email.sh
,send_timed_email.sh
, andtmp_usage.sh
to/usr/local/bin
and make them executable (chmod +x
). -
Create
.service
and.timer
files in/etc/systemd/system
for each of the scripts you wish to run repeatedly:-
.service
files:[Unit] Description=<description>
[Service] Type=oneshot ExecStart=/usr/local/bin/<script>.sh
-
.timer
files:[Unit] Description=<description>
[Timer] OnUnitActivateSec=<time> -or- OnCalendar=<time>
[Install] WantedBy=timers.target
-
-
Notify
systemd
that new services were added:systemctl daemon-reload
-
Start and enable services using
systemctl
:systemctl start <service_name>.timer systemctl enable <service_name>.timer
-
You check active timers by calling
systemctl list-timers
.