This article covers the configuration and use of email in Arista EOS.
1) Configuring Email
Arista switches can be configured as email clients and can be used to send email alerts through event handlers (which trigger an action when a certain event happens, for example when an interface goes down). This capability is in addition to the other management and monitoring methods available in EOS. Email can also be used from the CLI, as a convenient way to retrieve information for support. EOS email supports both TLS and SMTP authentication.
Arista(config)#email Arista(config-email)#? auth Email account authentication from-user Send email from this user server Email relay tls Require TLS Arista(config-email)#from-user <switch>@<domain> Arista(config-email)#server <smtp-server>.<domain> Arista(config-email)#auth username <SMTP account user> Arista(config-email)#auth password <STMP user password> Arista(config-email)#tls
Note: For the above configuration to work, the SMTP server should be configured to allow the configured SMTP user account must be authorised to send outgoing emails. In addition, the switch must be configured for domain name resolution, via the ip name-server command (in global configuration mode).
Example with Google public DNS:
Arista(config)#ip name-server 220.127.116.11 18.104.22.168
2) Using Emails in EOS
With the previous configuration in place, the can send email by two different ways:
- From Arista EOS CLI
- From the kernel Bash
You might employ the two methods differently. The following section details each.
2.1) Emails in EOS CLI
The native integration of “| email” in the show commands allow to very easily send the outputs of your choice. Below is an example collect the output of show tech :
Arista#show tech | email email@example.com
Note: the output is sent as email attachment.
The default subject for the email will be “Support email sent from the switch“. If you wish to cutomize it, use the option “-s <email subject>”, as per the following example:
Arista#show tech | email firstname.lastname@example.org -s [ShowTech]
Additionally, since the underlying email client employs the kernel, you can user environment variable in the command string, such as $HOSTNAME. Example:
Arista#show version | email email@example.com -s "[show version] From $HOSTNAME"
The resulting email is as follow. Notice the attachment. The first illustration is a capture from an email client receiving the email (e.g. Gmail), the second output is a raw ASCII visualisation of that same email.
Email client GUI example:
Raw ASCII email content:
Return-Path: <firstname.lastname@example.org> Received: from [127.0.0.1] (host.telco [x.x.x.x]) by mx.google.com with ESMTPSA id something for <email@example.com> (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 Aug 2014 09:00:00 -0700 (PDT) From: firstname.lastname@example.org X-Google-Original-From: vEOS1@dummy.lab Content-Type: multipart/mixed; boundary="===============1798300181==" MIME-Version: 1.0 To: email@example.com Subject: [show version] From vEOS1 Message-ID: <blah.email@vEOS1> Date: Sat, 16 Aug 2014 16:00:00 +0000 --===============1234567890== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline see attachment --===============1234567890== Content-Type: application/octet-stream MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: attachment QXJpc3RhIHZFT1MKSGFyZHdhcmUgdmVyc2lvbjogICAgClNlcmlhbCBudW1iZXI6ICAgICAgIApT eXN0ZW0gTUFDIGFkZHJlc3M6ICAwMDBjLjI5YWMuZTc2NAoKU29mdHdhcmUgaW1hZ2UgdmVyc2lv bjogNC4xNC4xLTIwMDY0NTguZmxjb2NvYWRldi4xIChlbmdpbmVlcmluZyBidWlsZCkKQXJjaGl0 ZWN0dXJlOiAgICAgICAgICAgaTM4NgpJbnRlcm5hbCBidWlsZCB2ZXJzaW9uOiA0LjE0LjEtMjAw NjQ1OC5mbGNvY29hZGV2LjEKSW50ZXJuYWwgYnVpbGQgSUQ6ICAgICAgOTg4NDA0YWMtNDRlZS00 OTVjLWEzMTgtNjE4YTZlYWVkMWRmCgpVcHRpbWU6ICAgICAgICAgICAgICAgICAzNyBtaW51dGVz ClRvdGFsIG1lbW9yeTogICAgICAgICAgIDE5Nzg4Njgga0IKRnJlZSBtZW1vcnk6ICAgICAgICAg ICAgNzg1MzYga0IKCg== --===============1234567890==--
2.2) Emails in Kernel Bash
If you are running scripts, you can use the native Bash command “email” to send those email, for example by piping a command output into email. The settings you configured in Arista EOS CLI will be used.
The below example will send the disk space usage in the switch
[user@Arista ~]$ df -h | email -s "[DiskUsage on $HOSTNAME]" firstname.lastname@example.org
This command has exactly the same effect as its EOS CLI counter part. The output will be sent as an email attachment.
2.3) Sending outputs to the email body rather than as attachment
Depending on the size of the output you want to send by email, you might prefer having the content either:
- as a text file attachment, you need to download the attachment before visualising the content.
- in the email body itself, without attachment, the output is directly readible from the email client.
For short output, and immediate visualisation, haveing the output content in the email body might be preferred.
For very long output, difficultly visible in an email client, and easier file transer/manipulations, attachments might pre prefered
Add “-i” to the command to fake interactive mode. Since the EOS CLI “show” command, or the Bash output, will be piped to the email client, the user intervention would effectively not be necessary. The informational message can therefore be ignored. In the below two examples, for the EOS CLI and Bash, the informational message was ignored, and no key was pressed, and the email sent automatically. This would be different if you were not sending content via pipe (‘|’) to the email client.
Arista EOS CLI:
Arista#show version | email email@example.com -i -s "[ShowVer $HOSTNAME]" Enter your message below. Hit ^D to finish the message. Arista#
[user@Arista ~]$ df -h | email -i -s "[DiskUsage on $HOSTNAME]" firstname.lastname@example.org Enter your message below. Hit ^D to finish the message. [user@Arista ~]$
The resulting email contains no attachment, the output is directly readible in the email body, as seen in the email client GUI, or in the email raw ASCII content:
Return-Path: <email@example.com> Received: from [127.0.0.1] (host.telco. [x.x.x]) by mx.google.com with ESMTPSA id 123 for <firstname.lastname@example.org> (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 Aug 2014 10:19:48 -0700 (PDT) From: email@example.com X-Google-Original-From: vEOS1@dummy.lab Content-Type: multipart/mixed; boundary="===============191237001==" MIME-Version: 1.0 To: firstname.lastname@example.org Subject: [ShowVer vEOS1] Message-ID: <1234.email@vEOS1> Date: Sat, 16 Aug 2014 15:16:46 +0000 --===============2345587000== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Arista vEOS Hardware version: Serial number: System MAC address: 000c.29ac.e764 Software image version: 4.14.1-2006458.flcocoadev.1 (engineering build) Architecture: i386 Internal build version: 4.14.1-2006458.flcocoadev.1 Internal build ID: 988404ac-44ee-495c-a318-618a6eaed1df Uptime: 1 hour and 4 minutes Total memory: 1978868 kB Free memory: 75912 kB --===============2345587000==--
3) Full Arista EOS Configuration Example
This section presents an example of working configuration, in this case with a Gmail SMTP server.
! ip name-server 22.214.171.124 126.96.36.199 ! email from-user vEOS1@dummy.lab server smtp.gmail.com:587 auth username test auth password 7 Q1v3UFpDtg4J9sQT61A-= tls !
4) How to setup Gmail to work with EOS Email client
Although you might have a corporate emailing system, it might be useful to use a flexible web-based client. This article has been using Gmail as test email client.
The are few simple steps to allow Gmail for SMTP email exchanges with the Arista EOS Email client.
The main steps consist in:
- Activate SMTP
- Enable less secured client. Note: do not sent un-encrypted sensitive data across an untrusted network
Activate SMTP – part 1: Access your email settings
Activate SMTP – part 2: In the “Forwarding and POP/IMAP” tab, select the radio button to enable POP.
Enabling less-secured email clients – part 1: Access your account settings
Enabling less-secured email clients – part 2: Access the settings for less-secured apps
Enabling less-secured email clients – part 3: Select the radio button to Enable