Skip to content

Commit ff02edf

Browse files
committed
first commit. its a bigun.
0 parents  commit ff02edf

File tree

11 files changed

+1207
-0
lines changed

11 files changed

+1207
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
config.json
2+
config_example.json
3+
node_modules/

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#hivectrl
2+
3+
A basic npm package using promises and server-side fetch to perform authenticated requests to the hiveos api v2 as **per provided javascript sample**
4+
5+
##quickstart
6+
7+
Modify config.json with your hiveos information. ```npm install && npm start```. Access localhost:5000/api (default port). A front end display in progress is available @ localhost:5000/
8+
9+
##the problem
10+
11+
Modifying video card settings on large multi-card-type rigs is very cumbersome; cards must be configured one at a time (which can take a while on a 10 card rig with differing cards)
12+
13+
14+
##intentions
15+
16+
* A better front end interface for manipulating mining rigs; specifically the ability to have better control over flight-sheets and the ability to apply changes per card 'type'.
17+
18+
* Better color coded dashboard interface for visualizing rig/farm/card activity in 'real time (15 seconds)'
19+
20+
* Improve ability to create new flight-sheets from existing ones

config_example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"hiveosAccessToken" : "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpIiwiaWF0IjoxNTY0OTg4NjcxLCJleHAiOjE4ODAzNDg2NzEsIm5iZiI6MTU2NDk4ODY3MSwianRpIjo5MjA3NDQyLCJzdWIiOjkyMDc0NDJ9.Wt_TJSo4fuG7IqxTVr-o-TmYXTEjMXPrDRuSvOlAKsA",
3+
"hiveosLogin" : "redcap3000",
4+
"hiveosPass" : "Tacahey7"
5+
}

examples/getAllWorkers.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
/*
3+
example of how to load from the context of another script
4+
(change require from ./index.js to hivectr when installed as a module
5+
in your own project)
6+
7+
edit config.json with your hiveos api/login info
8+
9+
Good example of a pattern I learned through trial and error. Seems to work.
10+
Maybe its common. IDK.
11+
12+
This could be baked into the main library but it complicates it unnessarily
13+
to perform this all properly with the full advantage of async javascript.
14+
15+
-- wont relogin each time access key is needed
16+
*/
17+
const hiveOS = require('../index.js')
18+
19+
20+
let farms = hiveOS.getAllWorkers().then((r) => {
21+
let farm = []
22+
23+
let filterWorkersInfo = function(worker){
24+
// the final step.
25+
let exclude = [ 'password','platform','tag_ids',
26+
'mirror_url','ip_addresses','remote_addresses',
27+
'vpn','has_amd','has_nvidia',
28+
'lan_config','migrated','has_octofan',
29+
'versions','commands']
30+
31+
var result = {}
32+
for(let k in worker[0]){
33+
if(exclude.indexOf(k) == -1){
34+
console.log(':'+k+':')
35+
//console.log(worker[0][k])
36+
//result[k]={}
37+
result[k]=worker[0][k]
38+
}
39+
}
40+
return result
41+
42+
}
43+
// potentially write the filtered result to a datastore
44+
// but for now just write to console, handy es6 syntax FTW!
45+
let displayWorkersInfo = console.log
46+
r.filter( (f,i) => {
47+
f.then(filterWorkersInfo).
48+
then(displayWorkersInfo).
49+
catch(console.log)
50+
})
51+
}).catch( (e) => {
52+
console.log("HiveOS getFarms() error")
53+
console.log(e)
54+
return false
55+
})

examples/getAllWorkers_interval.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
2+
/*
3+
example of how to load from the context of another script
4+
(change require from ./index.js to hivectr when installed as a module
5+
in your own project)
6+
7+
edit config.json with your hiveos api/login info
8+
9+
Good example of a pattern I learned through trial and error. Seems to work.
10+
Maybe its common. IDK.
11+
12+
This could be baked into the main library but it complicates it unnessarily
13+
to perform this all properly with the full advantage of async javascript.
14+
15+
-- wont relogin each time access key is needed
16+
*/
17+
const hiveOS = require('../index.js')
18+
19+
let getAllWorkers = function(){
20+
return hiveOS.getAllWorkers().then((r) => {
21+
let farm = []
22+
23+
let filterWorkersInfo = function(worker){
24+
// the final step.
25+
let exclude = [ 'name','algo','gpu_summary','gpu_info','stats']
26+
27+
var result = {}
28+
for(let k in worker[0]){
29+
//console.log(worker[0][k])
30+
if(exclude.indexOf(k) > -1){
31+
32+
console.log(':'+k+':')
33+
//
34+
//result[k]={}
35+
if(k == 'gpu_summary'){
36+
result[k]=worker[0][k]['gpus']
37+
}else if(k == 'gpu_info'){
38+
let t = worker[0][k]
39+
let rows = []
40+
t.filter(function(x){
41+
let card = x
42+
console.log(card)
43+
let gpuInfo = {
44+
algo:card.algo,
45+
bus_id: card.bus_id,
46+
bus_number: card.bus_number,
47+
index: card.index,
48+
power_limit : card.power_limit,
49+
cardInfo: card.brand + ' - ' + card.model + ' - ' + card.details.mem
50+
}
51+
rows.push(gpuInfo)
52+
53+
})
54+
55+
//console.log(rows)
56+
result[k] = rows
57+
}else{
58+
result[k]=worker[0][k]
59+
}
60+
}else{
61+
//console.log(k)
62+
}
63+
}
64+
return result
65+
66+
}
67+
// potentially write the filtered result to a datastore
68+
// but for now just write to console, handy es6 syntax FTW!
69+
let displayWorkersInfo = console.log
70+
r.filter( (f,i) => {
71+
f.then(filterWorkersInfo).
72+
then(displayWorkersInfo).
73+
catch(console.log)
74+
})
75+
}).catch( (e) => {
76+
console.log("HiveOS getFarms() error")
77+
console.log(e)
78+
return false
79+
})
80+
}
81+
82+
getAllWorkers().then(setTimeout(getAllWorkers,15 * 1000)).catch((e)=>{
83+
console.log('getAllWorkers_interval error')
84+
console.log(e)
85+
})

0 commit comments

Comments
 (0)