Sending generated data through email

The report generated in the previous section provides a good overview of the resources currently on the system. However, we can tweak the script and extend its functionality to send us an email with all of the details. This is very useful for a Network Operation Center (NoC) team, which can receive emails from a monitored system based on specific incidents (HDD failure, high CPU, or dropped packets). Python has a built-in library called smtplib, where it leverages the Simple Mail Transfer Protocol (SMTP) that is responsible for sending and receiving emails from mail servers.

This requires that you have local email servers on your machine, or that you use one of the free online email services, such as Gmail ...

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.