Network Monitor – HTML Dashboard with Color (Level 2)

This project shows you how to send a Ping command to the Linux Operating System with Python, and then create an auto refreshing HTML dashboard that displays a visual alert with CSS. IP Addresses/ FQDN’s that are up have a green background color, and those that are not are marked in red.

We also print whether the Host is Up or Down to the console screen for troubleshooting purposes.

The list of IP Addresses or FQDN’s are in a Python List and so can be changed as need be.

To view the HTML Dashboard on the local computer you simply need to go to your Home directory and open network.html in your web browser. This dashboard can be made available to other systems if you install apache2 onto your system and then save network.html in /var/www/html


Ping response is slightly different between MacOS and Linux. MacOS responds with “1 packet received” where are Linux responds with “1 received”.

import os
from time import sleep

host = ["", "","", "", ""]
pause = 10
success = "1 received"
fail = "0 received"
header = f"<meta http-equiv='refresh' content='4'> <title>Up/ Down App</title> <h1>Network Monitor</h1>"

while True:

  body = ""

  for x in host:
    command = f"ping -c 1 {x}"
    response = os.popen(command)
    response =

    if success in response:
      print(f"{x} is UP")
      body = f"{body}<h3 style='background-color:lightgreen;'>{x}</h3><pre>{response}</pre><br>"
    elif fail in response:
      print(f"{x} is DOWN")
      body = f"{body}<h3 style='background-color:salmon;'>{x} is DOWN</h3><br>"
      print(f"Other Issue Communicating with {x}")
      body = f"{body}<h3 style='background-color:purple;'>{x} THERE IS AN ISSUE</h3>"

  html = f"{header} {body}"
  file = open("network.html", "w")

Code language: Python (python)