Using the time and date modules

Great; so far, we have been able to send custom data generated from our servers through email. However, there might be a difference in time between the generated data and the email's delivery time, due to network congestion or a failure in the mail system, or any other reason. So, we can't depend on the email to correlate the delivery time with the actual event time.

For that reason, we will use the Python datetime module to follow the current time on the monitored system. This module can format the time in many attributes, such as year, month, day, hour, and minute.

Aside from that, the datetime instance from the datetime module is actually a standalone object in Python (like int, string, boolean, and so ...

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.