-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
61 lines (54 loc) · 2.21 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from flask import Flask
import os
import socket
import platform
import multiprocessing
app = Flask(__name__)
def get_ip():
return socket.gethostbyname(socket.gethostname())
def get_image_name():
imageStr = "/static/NodeInfoOnTITANIUMCENTOS.png"
platformStr = platform.platform()
if platformStr.__contains__("yocto"):
imageStr = "/static/NodeInfoOnWRLINUX.png"
return imageStr
@app.route("/")
def hello():
html = "<CENTER><h2>Node Info {name} ({buildVersion})</h2></CENTER>" \
"<CENTER><h4>[ Build Date: {buildDate} ]</h4></CENTER>" \
"<CENTER><IMG SRC=\"{imageName}\" ALIGN=\"TOP\"></CENTER>" \
"<HR>" \
"<b>Container:</b><br/>" \
"<b>     IP Address:</b> {ipaddr}<br/>" \
"<b>     Container :</b> {container}<br/>" \
"<br/>" \
"<b>Host :</b><br/>" \
"<b>     Platform :</b> {plat}<br/>" \
"<b>     Machine :</b> {mach}<br/>" \
"<b>     Node :</b> {node}<br/>" \
"<b>     System :</b> {sys}<br/>" \
"<b>     Release :</b> {rel}<br/>" \
"<b>     Version :</b> {version}<br/>" \
"<b>     Uname :</b> {uname}<br/>" \
"<br/>" \
"<b>Resources :</b><br/>" \
"<b>     CPUs :</b> {cpus}<br/>" \
"<b>     Memory(GB):</b> {memory}<br/>" \
"<HR>"
return html.format(name=os.getenv("NAME", "Web Server"),
buildVersion=os.getenv("VERSIONID", "Unknown Version"),
buildDate=os.getenv("BUILDDATE", "Unknown Build Date"),
imageName=get_image_name(),
ipaddr=get_ip(),
container=socket.gethostname(),
plat=platform.platform(),
mach=platform.machine(),
node=platform.node(),
sys=platform.system(),
rel=platform.release(),
version=platform.version(),
uname=platform.uname(),
cpus=multiprocessing.cpu_count(),
memory=((os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES'))/(1024.**3)))
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80)