用于订阅Arista遥测事件和发送电子邮件警报的脚本。
telemetry-email-alerter的Python项目详细描述
python脚本,允许您订阅arista遥测事件,然后将它们发送到smtp服务器以获取电子邮件通知。
电子邮件是为警报程序运行时发生的事件发送的,您不会收到过去事件的警报。
我们建议您设置电子邮件筛选器以限制通知。例如,您可以设置过滤器以忽略基于电子邮件主题的“信息”事件。
用法
您可以通过运行以下命令启动报警器:
telemetry-email-alerter <telemetry-server> <smtp-server> <email-1> <email-2> ... <email-n>
下面列出了脚本接受的参数的完整列表。
Name | Required? | Default | Description |
---|---|---|---|
telemetryUrl | yes | — | The IP address or hostname of your CVP Telemetry instance |
smtpServer | yes | — | The IP address or hostname of your SMTP (email) server |
sendToAddress | yes | — | The emails to send notifications to. You can specify multiple emails |
–sendCcAddress a@example.comb@example.com | no | — | Emails to CC notifications for. You can specify multiple emails |
–port 1234 | no | 465 | The port your SMTP server listens to if it use a non-standard port |
–subjectPrefix ‘CVP Alert’ | no | [CloudVision Telemetry] | A message to prepend to email subjects |
–noSmtpSsl | no | off (SSL is used) | Disable SSL for SMTP connections |
–smtpUsername a@example.com | no | — | SMTP server username if authentication is required |
–smtpPassword secret | no | — | SMTP server password if authentication is required. You will be prompted at startup if this is not provided |
–noTelemetrySsl | no | off (SSL is used) | Disable SSL for Telemetry connections |
–telemetryUsername example | no | — | Telemetry username if authentication is required |
–telemetryPassword secret | no | — | Telemetry password if authentication is required. You will be prompted at startup if this is not provided |
–noSslValidation | no | off (validation is used) | Disables validation of SSL certificates. For debugging purposes. Not advised to use in real environments |
–verbose | no | off | Show logging messages |
使用SMTP服务器
我们建议您使用自己运行和维护的SMTP服务器。你的公司可能有一个你可以用的。
或者可以使用the Gmail SMTP server。你可以使用你的gmail用户名和an app password。注意它的发送限制,尽管你肯定有可能超过它们。
开发信息
您将需要带有pip和virtualenv的python 2.7。你可以在the Python packaging documentation中阅读更多关于这些的内容。创建一个virtualenv来容纳此项目的依赖项。完成后,可以通过从项目根目录运行pip install -r requirements.pip来安装依赖项。
您可以使用Using an SMTP server中提到的gmail smtp服务器来测试电子邮件通知。或者,您可以在本地计算机上使用类似mailslurper的应用程序。
要在本地运行脚本,可以从项目根目录运行telemetry_email_alerter包:
python telemetry_email_alerter [...args]