I have been setting up NSA-325v2 (fw 4.70) for automatically pulling in backups from a hosted web server. I also set up the built in logs to record any issues detected in my scripts, and to email me if needed. I thought that I'd share the logging setup and also how to set up gmail (or virtually any other email) to work with the logs when the default SMTP port 25 is blocked by your ISP. I did not find documentation for these elsewhere. Setting up outgoing email to use TLS and port 465
The web interface does not allow the admin to specify a port (nor set up TLS security) for outgoing email. Outgoing email uses port 25 by default. Many ISPs block that outgoing port. You can still use Google mail if you configure the port manually to 465 and the connection to use TLS security. The username and mail server information can and should be set via the web interface at Maintenance->Log page and under Report config. The configuration is in the file /etc/msmtprc, but a reboot (or changing any mail server parameters) will overwrite the file and lose all our changes. We can use cron from the Tweaks zypkg http://zyxel.nas-central.org/wiki/3rd_party_zypkgs#Tweaks
to counter that as decribed below. NSA uses msmtp http://msmtp.sourceforge.net/
as the mail client.Steps:
Log in as root via telnet.
Add the following script to a file, for example to /i-data/md0/admin/enable_emailTLS.sh
cat <<EOF | cat - /etc/msmtprc > /etc/msmtprc.tmp; mv /etc/msmtprc.tmp /etc/msmtprc; chmod 0600 /etc/msmtprc
This will prepend our default connection parameters to the configuration file. It sets the mail server connection to use port 465 and to use TLS security and to skip server certificate validation. Google mail will accept these.
Change file permissions for the script
chmod u+x /i-data/md0/admin/enable_emailTLS.sh
To get our settings restored after a reboot add this line to cron setting on the Tweaks configuration web page to make Tweaks call our script at reboot.
You can also run the script manually, but just once between each reboot.
An easy way to test is to go to the Maintenance->Log page and under Report config->Report setting activate email alert. Now if you try to log in to the web interface with a wrong username/password it will be logged as an alert and the system will send an email.Using logging in shell scripts
You can add entries to the Maintenance->Log page and create alerts that will trigger email notifications.
The command for that is
zylogger -s source -p priority -f facility logstring...
zylogger -s 31 -p 1 -f 0 Alert message test
will produce a backup alert in the log. Or
zylogger -s 31 -p 6 -f 0 Info message test
will produce a backup info message.
I did not find any documentation for this, but with some experimenting I found out how to use it.
The source parameter specifies the class that is shown on the log page.
The values that produce an entry in the log are listed below.
The priority parameter is the severity that is shown on the log. Severity value "alert" will trigger an email.
The log does not show anything that corresponds to the facility parameter, so I did not find out the values for that. But some value must be specified.
I will be happy to hear if anyone has more information.