Created
April 13, 2019 05:41
-
-
Save nb5p/157b944cf40a5e408205313add184d96 to your computer and use it in GitHub Desktop.
Get system info.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from subprocess import Popen, PIPE | |
| def hostname(): | |
| hostname = Popen(["hostname"], stdout=PIPE) | |
| hostname = hostname.stdout.read() | |
| return hostname | |
| def osversion(): | |
| with open("/etc/issue") as f: | |
| osversion = f.read() | |
| return osversion | |
| def oscoreversion(): | |
| oscoreversion = Popen(["uname", "-r"], stdout=PIPE) | |
| oscoreversion = oscoreversion.stdout.read() | |
| return oscoreversion | |
| def cpuinfo(): | |
| corenumber = [] | |
| with open("/proc/cpuinfo") as cpuinfo: | |
| for i in cpuinfo: | |
| if i.startswith("processor"): | |
| corenumber.append(i) | |
| if i.startswith("model name"): | |
| cpumode = i.split(":")[1] | |
| return corenumber, cpumode | |
| def meminfo(): | |
| with open("/proc/meminfo") as meminfo: | |
| for i in meminfo: | |
| if i.startswith("MemTotal"): | |
| totalmem = i.split(":")[1] | |
| return totalmem | |
| if __name__ == '__main__': | |
| hostname() | |
| osversion() | |
| oscoreversion() | |
| cpuinfo() | |
| meninfo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment