#!/usr/bin/python ''' ************************************************************************ * pingtest.py - (C) 2015 James Nonnemaker - james (AT) nonnemaker.us * * This program is merely to demonstrate my python coding skills/style * It actually does function, this program will read a lisst of servers * from a MySQL server and ping each one to see if it is online. It * will create a web page with the results of the ping test. ************************************************************************ ''' sql_server = "localhost" sql_user = "sqluser" sql_pass = "p@ssword3" sql_db = "network_uptime" import MySQLdb import os import os.path import datetime if os.path.exists("/tmp/ping.html"): os.remove("/tmp/ping.html") file = open("/tmp/ping.html","w") d = datetime.datetime.now() file.write("\n") file.write("
" + row[0] + " | Host is up | 0 |
" + row[0] + " | Host is down | " + str(down_count) + " |