Server Health Monitor Project
Program 1
We will be using PSUTIL library for this project.
follow the installation instructions here: http://luckypants.weebly.com/psutil.html
go through the psutil documentation and pick at least 4 readings to use for your homework, here is an example:
follow the installation instructions here: http://luckypants.weebly.com/psutil.html
go through the psutil documentation and pick at least 4 readings to use for your homework, here is an example:
import psutil, datetime boot_time = datetime.datetime.fromtimestamp(psutil.boot_time()).strftime("%Y-%m-%d %H:%M:%S") print("\nBOOT TIME:", boot_time) cpu_util = psutil.cpu_percent(interval=1, percpu=True) i=1 print("\nCPU UTILIZATION:") for cpu in cpu_util: print("CPU {} : {}%".format(i, cpu)) i+=1 mem = psutil.virtual_memory() THRESHOLD = 100 * 1024 * 1024 # 100MB print("\nAVAILABLE MEMORY:", mem.available) print("USED MEMORY:", mem.used) print("USED PERCENTAGE:", mem.percent)
Modify the simple HTTP Server to display server health in a nice HTML formatted view, here is an example
BOOT TIME | 2014-10-26 02:00:32 | ||||||||
CPU UTILIZATION |
| ||||||||
AVAILABLE MEMORY | 3552108544 | ||||||||
USED MEMORY | 8140689408 | ||||||||
USED PERCENTAGE | 58.6 |
Tips:
- build your entire output string first and then write it at once
- You can use bytes(message,'utf-8') to convert string into bytes
Program 2
Complete either GET or POST version of the wsgi app here to store data user entered into SQLite DB of animals we created here
Search Engine
Use existing indexer and searcher to fetch data from database and search through it. Unlike the File and URL, there is no direct link to the record in the database, build a small web application that will fetch 1 record from the database given a certain ID as a URL parameter, incorporate that URL as a search result for the searcher