-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathinfo.py
More file actions
49 lines (43 loc) · 1.42 KB
/
info.py
File metadata and controls
49 lines (43 loc) · 1.42 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import commands
import os
def main():
# 查看GPU温度
gpu = commands.getoutput( '/opt/vc/bin/vcgencmd measure_temp' ).replace( 'temp=', '' ).replace( '\'C', '' )
gpu = float(gpu)
print('gpu Temp: %.2f ' % gpu)
# 查看CPU温度
file = open("/sys/class/thermal/thermal_zone0/temp")
cpu = float(file.read()) / 1000
file.close()
print('cpu Temp: %2.2f' % cpu)
load_1min = str(os.popen("top -n1 | awk '/load average:/ {print $12}'").readline().strip()).replace(',', '' )
load_5min = str(os.popen("top -n1 | awk '/load average:/ {print $13}'").readline().strip()).replace(',', '' )
load_1min = float(load_1min)
load_5min = float(load_5min)
print('')
print('load_1min: %.2f'%load_1min)
print('load_5min: %.2f'%load_5min)
Ramused = str(os.popen("top -n1 | awk '/MiB/ {print $6}'").readline().strip()).replace(',', '' )
print('')
print('Ramused: %s '%Ramused +' Mb')
def getDiskSpace():
p = os.popen("df -h /")
i = 0
while 1:
i = i +1
line = p.readline()
if i==2:
return(line.split()[1:5])
# Disk information
DISK_stats = getDiskSpace()
DISK_total = DISK_stats[0].replace('G','')
DISK_used = DISK_stats[1].replace('G', '' )
DISK_perc = DISK_stats[3].replace('%', '' )
print('')
print('DISK_total: '+str(DISK_total)+' Gb')
print('DISK_used: '+str(DISK_used)+' Gb')
print('DISK_perc: '+str(DISK_perc)+' %')
if __name__ == '__main__':
main()