# Setting Up SMARTD and ZED Now we will setup SMART and ZED on the drives, so when any error occurs during the operations i.e. disk failure or bad sectors appear on the disks we will be notified through email. SMART and ZED are already installed on our machines we just need to make sure that they are enabled. But to get email notifications we first need to setup an email client with the SMTP relay information. ### Setup Email Client: Install mailx: ``` sudo yum install -y mailx mailutils ``` Store following information in the mail.rc file: ``` sudo bash -c 'cat <<EOF >> /etc/mail.rc # sendgrid set smtp-use-starttls set smtp=smtp://smtp.sendgrid.net:587 set smtp-auth=login set smtp-auth-user=apikey set smtp-auth-password="password-for-smtp" set from=support@validatus.com set nss-config-dir=/etc/pki/nssdb/ set sendcharsets=iso-8859-1 set ttycharset=iso-8859-1 EOF' ``` Now we will be able to send emails from the terminal. ### Setup SMARTD: Next, we will setup SMARTD to send email notifications when any error occurs during disks tests. To check if SMART is enabled on the drives: ``` sudo smartctl -i /dev/sda ``` If its not enabled, run the following command to enable it: ``` sudo smartctl -s on /dev/sda ``` Open ```/etc/smartd.conf``` and add the following line of code to enable email notifications: ``` /dev/sda -a -m venv@validatus.com -M test ``` The above command says: * Check drive /dev/sda * Send an email to the given address * Type of report is test, means we are just testing that our email notification is working or not. ### Setup ZED ZFS: ZED stands for "ZFS Event Daemon". We will set it up such that when any scrubbing takes place then we will get email notifications with the scrubbing report. ZED is by-default installed with the ZFS package. Open the file ```vi /etc/zfs/zed.d/zed.rc```. Uncomment ```ZED_EMAIL_ADDR="you@yourdomain.com"``` and add the email address to which notifications will be sent. Set notifications verbosity to 1, so that we can get emails everytime the scrubbing takes place. If set to 0 then we will get notification only when pool is unhealthy. ``` ZED_NOTIFY_VERBOSE=1 ``` At the end of the file, set name for syslog: ``` ZED_SYSLOG_TAG="zed" ``` Save the file and run a scrub to test the email notifications. ``` sudo zpool scrub datapool ```