-
Notifications
You must be signed in to change notification settings - Fork 0
/
cgminer
executable file
·87 lines (79 loc) · 2.54 KB
/
cgminer
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- python -*-
#
# Cgminer plugin
#
# Optional configuration:
#
# [cgminer]
# env.host = 'localhost'
# env.port = 4028
#
#%# capabilities=autoconf
#%# family=auto
import os, sys, string, glob, socket, json
plugin_name=list(os.path.split(sys.argv[0]))[1]
plugin_version="3.0"
rpc_host = os.getenv("host", "localhost")
rpc_port = int(os.getenv("port", 4028))
def cgminer_rpc(command):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((rpc_host, rpc_port))
s.send(json.dumps({"command": command}))
res = s.makefile().read()
s.close()
return json.loads(res.replace('\x00','')), None
except socket.error as e:
return None, str(e)
devs, err = cgminer_rpc('devs')
arg = sys.argv[1] if len(sys.argv) == 2 else None
if arg == "config":
print('multigraph cgminer_hashrate')
print('graph_category mining')
print('graph_title Hashrate')
print('graph_vlabel Hash/s')
print('graph_args --base 1000 --lower-limit 0')
if devs:
for dev in devs['DEVS']:
print('gpu_'+str(dev['GPU'])+'.label GPU '+str(dev['GPU']))
print('gpu_'+str(dev['GPU'])+'.type DERIVE')
print('gpu_'+str(dev['GPU'])+'.min 0')
print('gpu_'+str(dev['GPU'])+'.draw '+("AREA" if dev==devs['DEVS'][0] else "STACK"))
print('multigraph cgminer_temperature')
print('graph_category mining')
print('graph_title GPU Temperature')
print('graph_vlabel °C')
if devs:
for dev in devs['DEVS']:
print('gpu_'+str(dev['GPU'])+'.label GPU '+str(dev['GPU']))
print('multigraph cgminer_fans')
print('graph_category mining')
print('graph_title GPU Fans')
print('graph_vlabel %')
print('graph_args -l 0 -u 100 -r')
if devs:
for dev in devs['DEVS']:
print('gpu_'+str(dev['GPU'])+'.label GPU '+str(dev['GPU']))
elif arg == "autoconf":
if err:
print("no ("+err+")")
elif len(devs['DEVS']) == 0:
print("no (no gpu found)")
else:
print("yes")
#elif arg == "suggest":
elif arg == "version":
print(plugin_name+' Munin plugin, version '+plugin_version)
else:
if devs:
print('multigraph cgminer_hashrate')
for dev in devs['DEVS']:
print('gpu_%s.value %d' % (dev['GPU'], dev['Total MH']*1e6))
print('multigraph cgminer_temperature')
for dev in devs['DEVS']:
print('gpu_%s.value %f' % (dev['GPU'], dev['Temperature']))
print('multigraph cgminer_fans')
for dev in devs['DEVS']:
print('gpu_%s.value %f' % (dev['GPU'], dev['Fan Percent']))