- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython.py
More file actions
Latest commit
26 lines (21 loc) · 670 Bytes
/
Copy pathpython.py
File metadata and controls
26 lines (21 loc) · 670 Bytes
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
importos
defread(path):
withopen(path) asf:
returnf.read()
user, term, shell= [os.environ[x] forxin ["USER", "TERM", "SHELL"]]
host=read('/etc/hostname').rstrip()
kernel=read('/proc/version').split()[2]
tasks=len([xforxinos.listdir('/proc') ifx.isdigit()])
mem=read('/proc/meminfo').split('\n')[:3]
(total, _, avail) = [int(x.split()[1]) //1000forxinmem]
uptime=float(read('/proc/uptime').split()[0])
d=int(uptime/60/60/24)
h=int(uptime/60/60%24)
m=int(uptime/60%60)
print(f"""{user}@{host}
kernel\t{kernel}
term\t{term}
shell\t{shell}
tasks\t{tasks}
mem\t{avail}m / {total}m
uptime\t{d}d {h}h {m}m""")