-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_stats.py
38 lines (32 loc) · 1023 Bytes
/
save_stats.py
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
import sqlite3
import ADL
import time
import config
ADL.SetupADL(config.device_number)
config.
for i in range(config.update_frequency):
conn = sqlite3.connect(config.db_file)
c = conn.cursor()
c.execute("create table if not exists stats (time REAL, load INTEGER, "
"temp REAL, fanspeed INTEGER, fanrpm INTEGER, hashrate REAL, "
"efficiency REAL)")
try:
hashrate, efficiency = open(config.miner_log).readline().split(':')
except ValueError:
hashrate, efficiency = (0, 0)
hashrate = int(hashrate)
efficiency = float(efficiency)
c.execute("insert into stats values (?, ?, ?, ?, ?, ?, ?)",
( time.time(),
ADL.getGPULoad(),
ADL.getTemp(),
ADL.getFanSpeed(),
ADL.getFanRPM(),
hashrate / 1000.,
efficiency * 100
)
)
conn.commit()
c.close()
conn.close()
time.sleep(60/config.update_frequency)