def get_sys_info():
"""Display info on system and output as nice HTML"""
spacer = "<tr><td> </td><td> </td></tr>"
html = '<h3>System Information for {}</h3>'.format(platform.node())
html += '<table>'
html += '<tr><td align="left">Python Executable</td>'
html += '<td>{}</td></tr>'.format(sys.executable)
html += '<tr><td>Kernel PID</td><td>{}</td></tr>'.format(
psutil.Process().pid)
mem = psutil.virtual_memory()
html += '<tr><td>Total System Memory</td>'
html += '<td>{:.4} Mb</td></td>'.format(mem.total/1024**3)
html += '<tr><td>Total Memory Used</td>'
html += '<td>{:.4} Mb</td></td>'.format(mem.used/1024**3)
html += '<tr><td>Total Memory Free</td>'
html += '<td>{:.4} Mb</td></td>'.format(mem.free/1024**3)
html += '<tr><td>Number of CPU Cores</td><td>{}</td></tr>'.format(
psutil.cpu_count())
html += '<tr><td>Current CPU Load</td><td>{} %</td></tr>'.format(
psutil.cpu_percent(1, False))
html += '</table>'
return HTML(html)
评论列表
文章目录