Monitoring - marco1475/linux-htpc GitHub Wiki
-
Install
msmtpandmsmtp-mta:pacman -S msmtp msmtp-mta -
Create the
/etc/msmtprcconfiguration 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, otherwisemsmtpwill fail:chmod 644 /etc/msmtprc -
To be able to use GMail's SMTP server you either need to allow "Less Secure Apps" in
Settings>Securityor enable 2-factor authentication and use an app password.
-
-
Create the
/etc/aliasesconfiguration 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_sensorspackage:pacman -S lm_sensors -
Run
sensors-detectand hitEnterto accept all the defaults, which will generate the following/etc/conf.d/lm_sensorsfile:HWMON_MODULES="coretemp nct6775" -
You can run the
sensorscommand to test whether the sensors work.
-
Install the
smartmontoolsandhddtemppackages: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/sdacommand to get the S.M.A.R.T. information, including the temperature, of the SSD. -
Set up the
smartddaemon to monitor the drives' S.M.A.R.T. attributes:-
Edit the
/etc/smartd.confconfiguration 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-
-amonitor all attributes -
-msend alert e-mails to[email protected](add-M testto send a test e-mail when the service starts) -
-ndo not check attributes when the disk is instandbymode (or any lower mode, such asofforsleep), unless it happened24times, but bequiet about missing the attribute checks (do not log them) -
-oautomatic offline data collection ison -
-sschedule 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) -
Sautomatic attribute autosave ison -
Wwarn about temperature changes of4degrees or more between runs, log when the temperature reaches40degrees, and log and e-mail if the temperature reaches45degrees
-
-
Create the
/etc/default/smartmontoolsfile 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
smartddaemon 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.shto/usr/local/binand make them executable (chmod +x). -
Create
.serviceand.timerfiles in/etc/systemd/systemfor each of the scripts you wish to run repeatedly:-
.servicefiles:[Unit] Description=<description>
[Service] Type=oneshot ExecStart=/usr/local/bin/<script>.sh
-
.timerfiles:[Unit] Description=<description>
[Timer] OnUnitActivateSec=<time> -or- OnCalendar=<time>
[Install] WantedBy=timers.target
-
-
Notify
systemdthat 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.