diff --git a/advanced/app.py b/advanced/app.py new file mode 100644 index 0000000..31512f5 --- /dev/null +++ b/advanced/app.py @@ -0,0 +1,16 @@ +import psutil +from flask import Flask, render_template + +app = Flask(__name__) + +@app.route("/") +def index(): + cpu_percent = psutil.cpu_percent() + mem_percent = psutil.virtual_memory().percent + message = None + if cpu_percent > 80 or mem_percent > 80: + message = "High CPU or memory utilization detected!" + return render_template("index.html", cpu_percent=cpu_percent, mem_percent=mem_percent, message=message) + +if __name__ == '__main__': + app.run(debug=True, host='0.0.0.0') diff --git a/advanced/templates/index.html b/advanced/templates/index.html new file mode 100644 index 0000000..d86b997 --- /dev/null +++ b/advanced/templates/index.html @@ -0,0 +1,78 @@ + + + + System Monitoring + + + + +
+

System Monitoring

+
+
+ {% if message %} +
{{ message }}
+ {% endif %} +
+ + +