Skip to content

Instantly share code, notes, and snippets.

@theycallmemac
Created November 5, 2019 17:20
Show Gist options
  • Save theycallmemac/ea230b9a98faa1cb112d3d66a80a9de3 to your computer and use it in GitHub Desktop.
Save theycallmemac/ea230b9a98faa1cb112d3d66a80a9de3 to your computer and use it in GitHub Desktop.
def main():
with open("/proc/meminfo", "r") as f:
lines = f.readlines()
with open("/proc/cpuinfo", "r") as f:
info = f.readlines()
cpuinfo = [x.strip().split(":")[1] for x in info if "model name" in x]
cpu = []
for index, item in enumerate(cpuinfo):
cpu.append(str(index) + ": " + item)
f=open("/root/stats.txt","a+")
f.write("memory:\n" + lines[0].strip() + "\n" + lines[1].strip())
f.write("\nprocessors:\n" + "".join(cpu) + "\n-------------------------------\n")
f.close()
if __name__== "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment