Scheduled Health Check Reports
Lesson 9 of 10
The Scenario
Every morning before the team standup, you want a health check report waiting in your inbox: device reachability, BGP peer status, interface utilization, any critical errors. Currently you SSH into 5 devices to check manually. A scheduled script does it automatically at 7 AM.
The Prompt
Write a Python script for a daily network health check that:
1. Reads devices from devices.csv
2. For each device, collects:
- Ping reachability (is it up?)
- Uptime (show version | include uptime)
- CPU utilization (show processes cpu | include five)
- Interface errors (any interface with errors > 0 since last clear)
- BGP peer status (show ip bgp summary — if applicable)
3. Generates an HTML report with:
- Green/red status indicators per device
- Table of interface errors (if any)
- BGP peers with state other than Established flagged in yellow
4. Sends the report via email using SMTP (server: mail.nhprep.com, port: 587)
5. Also saves the HTML report to a "reports" folder
Designed to run at 7:00 AM via cron/Task Scheduler.
What AI Gives You
A comprehensive health check script with HTML email output. Color-coded status makes it scannable in 30 seconds.
Review and Validate
- SMTP credentials: Use environment variables, not hardcoded
- BGP check: Only applicable to routers — skip for switches. Ask AI to make this conditional
- Error thresholds: An interface with 1 CRC error is not critical. Add minimum thresholds
Try It Yourself
Start with just the ping check and uptime for 3 devices. Get the email working first, then add more checks one at a time.
Subscribe to unlock this lesson
₹7,999/year
Full access to all 10 lessons in this course, plus 74 more lab courses, quizzes, and AI mock interviews. 365 days.
Already have an account? Sign in