Linux for network engineers lab 10 of 14
Python network checks: sockets, subprocess and requests
You write Python tools that tell open from closed from filtered, parse ping, read a JSON health page and log in to a router, then join them into a parallel monitor with a proper exit code.
Run this lab
It needs Lite: its 3 nodes are set to 3 vCPU and 2,048 MB in total. That fits the free demo too.
In your workspace: Shared, then Linux for network engineers guided labs, then 10 - Python network checks - sockets subprocess and requests
- Level
- Intermediate
- Time
- About 75 minutes
- Nodes need
- 3 vCPU, 2,048 MB
- Smallest plan
- Lite
The scenario
The Halifax team's Bash checks from Lab 09 have outgrown themselves. They want a monitor that handles errors properly, reads a JSON health page and can talk to routers. You'll write it in Python on WS, one small module at a time, and test each against the depot's tracker server WEB and router R1. WS already has requests, netmiko and yaml installed.
| Device | Interface | Address | Role |
|---|---|---|---|
| WS | eth0 | 10.10.10.50/24 | your workstation; write code in /root/lab |
| R1 | Gi0/0, Gi0/1 | 10.10.10.1/24, 10.10.20.1/24 | router; user ops, SSH |
| WEB | eth0 | 10.10.20.10/24 | HTTP on 80, /cgi-bin/health returns JSON; port 8443 is blocked by policy |
| Device | Runs | How to log in |
|---|---|---|
| WS | Ubuntu 22.04 desktop container | Its console is a remote desktop: root / eve. Open a terminal there. |
| R1 | Cisco IOSv 15.9 | The console opens at >; enable has no password. |
| WEB | Alpine Linux 3.16 with iptables and iproute2 | Opens on a menu: press 5, then Enter, for a root shell. |
What you’ll practise
- Test TCP ports with sockets and handle each failure
- Run commands with subprocess and parse the output
- Call a JSON web service with requests
- Read a router with netmiko
- Run checks in parallel and report in JSON with an exit code
The tasks
- Start the Linux nodes
- A port checker with sockets
- Run ping from Python
- Call a web service with requests
- Ask a router with netmiko
- Put it together
The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.
Topology and devices
The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.
Every link, as text
- WS
eth0to R1Gi0/0 - R1
Gi0/1to WEBeth0
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| WS | EVE-NG GUI server (Docker) | eve-gui-server:latest | 1 vCPU, 1,024 MB |
| R1 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
| WEB | Alpine WAN emulator | clbalpinewanem-alpine-3-16-2-wanem | 1 vCPU, 512 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Linux for network engineers guided labs.Open
10 - Python network checks - sockets subprocess and requestsand start its nodes, then open Lab Tasks for the scenario and the steps.
The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.
More Linux for network engineers labs
All Linux for network engineers labs
Related labs in other courses
CloudLabBox is independent of Cisco, CompTIA, the Linux Foundation and the Linux Professional Institute. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.