fullcycle icon indicating copy to clipboard operation
fullcycle copied to clipboard

Miner conf

Open supernoveau opened this issue 5 years ago • 23 comments

I'm trying to pick up the miners on my local network (Antminer Z9 and Innosilicon ZMaster).

I updated the miners.conf with the IPs of the machine however when I run fcmsimple the new conf isn't picked up by the system (it shows 1 new machine only plus a S9105 that I haven't configured in the conf.

How do I reset the cache?

What is the clientid, networkid and minerid in the conf? I have these empty.

Will the system pick up miners on port 22, 80 or another port? Z9s are only open on 22 and 80 by default, ZMasters are also open by default on 8001.

supernoveau avatar Nov 09 '18 00:11 supernoveau

I found fcmpurge which allows it to pick up my conf.

Calling fcmsimple I get: Failed to call miner stats api: Expecting value: line 1 column 1 (char0).

Any help regarding the port and miner.conf would be a real help. Thanks

supernoveau avatar Nov 09 '18 05:11 supernoveau

S9105 is my test machine. It is just a friendly name. clientid, networkid, and minerid can be blank. I will write up some help documents for those values.

The port in miner.conf should be the miner api port. Usually 4028 by default. I will check what the setting should be for Z9.

dfoderick avatar Nov 09 '18 16:11 dfoderick

It looks like I have some work to do to automatically configure Innosilicon Zmaster. I will work on that soon.

Please try to enable api on the zmaster using the instructions at the bottom of the following page.
https://support.awesomeminer.com/support/solutions/articles/35000085990-configure-api-access-for-innosilicon-asic-miners

Note: I do not suggest allowing W:0/0 like the example shows, but try it first to get it to work and then try a setting that is more secure.

dfoderick avatar Nov 09 '18 17:11 dfoderick

On the ZMaster I can enable that API following that guide, however I can't access the cgminer API.

Running netstat -l on the miner I see a process listening on 0.0.0.0:4028. However, when I use nmap to the IP, only port 22, 80 and 8001 are open. Running fcmsimple I get [Errno 111] Connection refused.

Do you know how I open port 4028 on the miner?

supernoveau avatar Nov 12 '18 08:11 supernoveau

Sending to the cgminer API echo '{"command":"stats"}' | nc x.x.x.x 4028 I get the response {"STATUS":[{"STATUS":"S" .... so it seems this is working at the cgminer end?

supernoveau avatar Nov 12 '18 09:11 supernoveau

I presume this is an unrestricted API call.

I removed the api-allow key in /config/cgminer.conf so there can't be a conflict with the systemctl init, and it may have enabled it.

Running fcmsimple then gives

1 api calls in 13ms
[stacktrace]
ZeroDivisionError: division by zero

supernoveau avatar Nov 12 '18 10:11 supernoveau

To confirm, I used the API directly and I do have privileged access enabled, so the fcmsimple isn't working if I'm not mistaken?

Request: echo '{"command":"privileged"}' | nc xx.xx.xx.xx 4028 >> ~/Desktop/output.txt

Response:

{"STATUS":[{"STATUS":"S","When":1542018669,"Code":46,"Msg":"Privileged access OK","Description":"sgminer 4.4.2"}],"id":1}

supernoveau avatar Nov 12 '18 10:11 supernoveau

I presume this is an unrestricted API call.

I removed the api-allow key in /config/cgminer.conf so there can't be a conflict with the systemctl init, and it may have enabled it.

Running fcmsimple then gives

1 api calls in 13ms
[stacktrace]
ZeroDivisionError: division by zero

Thank you for your help to diagnose this!

There must be a programming error on my side that is doing a division by zero. I will check the code. In the mean time, does the stack trace tell you the line number for the ZeroDivisionError? Or, if you can send me you output of the stats command then I can parse it to debug.

dfoderick avatar Nov 12 '18 18:11 dfoderick

Sending to the cgminer API echo '{"command":"stats"}' | nc x.x.x.x 4028 I get the response {"STATUS":[{"STATUS":"S" .... so it seems this is working at the cgminer end?

Can you send me the full contents of the output of stats command? There must be some contents that I have not encountered before and it is throwing an error in my programming.

dfoderick avatar Nov 12 '18 18:11 dfoderick

This is the full response to the stats command - https://gist.github.com/almccann/a44351ec8bafc17ab000a8a70c575d24

supernoveau avatar Nov 12 '18 22:11 supernoveau

So to help with debug, with cgminer API configured with privileged access (according to response above), fcmsimple full stack trace is:

Starting...
2018-11-13 09:54:43: Starting FCM Init
2018-11-13 09:54:43: Starting FCM Configuration
Starting FCM Cache
2018-11-13 09:54:43: started app. getting known miners
2018-11-13 09:54:43: 1 miners configured
Failed to call miner stats api: 'Description'
Traceback (most recent call last):
  File "/home/pi/fullcycle/fullcyclepy/helpers/antminerhelper.py", line 56, in stats
    minerinfo = parse_minerinfo(status)
  File "/home/pi/fullcycle/fullcyclepy/helpers/antminerhelper.py", line 124, in parse_minerinfo
    if status['Description'].startswith('cgminer'):
KeyError: 'Description'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/fullcycle/fullcyclepy/backend/simplemonitor.py", line 113, in <module>
    LOOP.run_until_complete(run_tasks(CUTOR, MINERS))
  File "/usr/lib/python3.5/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/pi/fullcycle/fullcyclepy/backend/simplemonitor.py", line 94, in run_tasks
    results = await fut
  File "/usr/lib/python3.5/asyncio/tasks.py", line 500, in _wait_for_one
    return f.result()  # May raise f.exception().
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/pi/fullcycle/fullcyclepy/backend/simplemonitor.py", line 21, in getstats
    minerstats, minerinfo, statspolling, minerpool = antminerhelper.stats(miner)
  File "/home/pi/fullcycle/fullcyclepy/helpers/antminerhelper.py", line 65, in stats
    raise MinerMonitorException(ex)
helpers.antminerhelper.MinerMonitorException: 'Description'

supernoveau avatar Nov 12 '18 22:11 supernoveau

  1. Should be status = jstats['STATUS'][0]? https://github.com/dfoderick/fullcycle/blob/35f5d79359e890d67e189f8341db8b64241aa7fc/fullcyclepy/helpers/antminerhelper.py#L52

  2. With that change no miner_count, GHS 5s, GHS av, frequency nor controllertemps in this json. Have commented out this lines in my local version. https://github.com/dfoderick/fullcycle/blob/35f5d79359e890d67e189f8341db8b64241aa7fc/fullcyclepy/helpers/antminerhelper.py#L69

  3. Change to list index and sgminer if status[0]['Description'].startswith('sgminer'):? https://github.com/dfoderick/fullcycle/blob/35f5d79359e890d67e189f8341db8b64241aa7fc/fullcyclepy/helpers/antminerhelper.py#L124


With these amendments fcmsimple returns:

Starting...
2018-11-13 17:19:39: Starting FCM Init
2018-11-13 17:19:39: Starting FCM Configuration
Starting FCM Cache
2018-11-13 17:19:39: started app. getting known miners
2018-11-13 17:19:39: 1 miners configured
zmaster1 mining at Antpool ZCash 8899
2018-11-13 17:19:40 zmaster1 offline 0 0 temp=0 0d2h47m 1054ms
1 api calls in 1072ms. Avg=1072.0ms
Concurrency saved 1054.8569099996712ms - 1072ms = -17.14309000032881ms (-1%)
Shutting down fcm app...

supernoveau avatar Nov 13 '18 06:11 supernoveau

You're almost there. The temps need to be parsed correctly. I will work on a pull request today.

dfoderick avatar Nov 13 '18 14:11 dfoderick

This is the full response to the stats command - https://gist.github.com/almccann/a44351ec8bafc17ab000a8a70c575d24

These stats are quite a bit different than what i have seen before. Basically, I need to get hash from 'MHS av' and temp from 'Temp'

If I can pull those out then you can get basic monitoring and run rules on them.

dfoderick avatar Nov 13 '18 14:11 dfoderick

Is this the sgminer API compared to cgminer? That json is the ZMaster.

If you check the type of API - sgminer or cgminer - can them call the different parsers accordingly and handle both machines?

supernoveau avatar Nov 13 '18 19:11 supernoveau

Is this the sgminer API compared to cgminer? That json is the ZMaster.

There is no official standard for the output of each api command. Each miner manufacturer produces different output, especially for the stats command. So yes, this is a difference in format between the different mining software.

If you check the type of API - sgminer or cgminer - can them call the different parsers accordingly and handle both machines?

Yes, this is exactly what I am going to do.

Later I will improve the code and make it easier to notify me when a new miner comes out so I can get it fixed sooner.

dfoderick avatar Nov 13 '18 22:11 dfoderick

Make a backup of ~/fullcycle/fullcyclepy/backend/config/*
Update the app with the following command

fcmupdate

That will stop services, backup config, get new version then restore config and restart services.

Then let me know if simplemonitor runs.

dfoderick avatar Nov 13 '18 23:11 dfoderick

My debugging to get fcmsimple to return

  1. Key needs to be lowercase: https://github.com/dfoderick/fullcycle/blob/b53a35b1b051db27d947f2768c96712ad01f2328/fullcyclepy/helpers/antminerhelper.py#L54

  2. This isn't used and errors: https://github.com/dfoderick/fullcycle/blob/b53a35b1b051db27d947f2768c96712ad01f2328/fullcyclepy/helpers/antminerhelper.py#L57

  3. Just needs the function doesn't pick up the module https://github.com/dfoderick/fullcycle/blob/b53a35b1b051db27d947f2768c96712ad01f2328/fullcyclepy/helpers/antminerhelper.py#L58

  4. Needs conditional on max if empty or at least its not parsing these for me https://github.com/dfoderick/fullcycle/blob/b53a35b1b051db27d947f2768c96712ad01f2328/fullcyclepy/helpers/antminerhelper.py#L88 https://github.com/dfoderick/fullcycle/blob/b53a35b1b051db27d947f2768c96712ad01f2328/fullcyclepy/helpers/antminerhelper.py#L97

  5. This line just needs to come back four spaces outside the if else https://github.com/dfoderick/fullcycle/blob/b53a35b1b051db27d947f2768c96712ad01f2328/fullcyclepy/helpers/antminerhelper.py#L68

Sorry probably could just have made a PR..

To help with the Elapsed and Temp, this is the content of jsonstats that is passed to parse_statistics_inno: https://gist.github.com/almccann/101eb5aa52b4d7c5b38466303384e094

supernoveau avatar Nov 14 '18 01:11 supernoveau

Actually if line 54 is like this then the Elapsed and Temp is plucked:

jstats = stats_and_pool['stats'][0]['STATS']

Probably brittle but that does get it.

supernoveau avatar Nov 14 '18 08:11 supernoveau

Any idea on the currenthash - the calc from the API gives a hash of 2862500 whereas the web admin gives around 50000 sol/s?

Is the controllertemp and average of the hashboards? Also regarding the rules.conf, I see the controllertemp is this value, what is the boardtemp? Is that coming from Z9 which has a chip and PCB temp but here with this API not applicable?

supernoveau avatar Nov 14 '18 08:11 supernoveau

It was a little hard for me to interpret the stats output without being able to compare it with anything.

In the stats output there was 3 'MHS av' values. Normally that is the hash for each board, so I summed them.

How many hashing boards does the Z9 have? Do you have the Antminer Z9 or the innosilicon A9 zmaster?

dfoderick avatar Nov 14 '18 11:11 dfoderick

I dug into their web code and it uses another API call - I don't know why its accurate for hashrates - a lot of the info is duplicated. Anyway I opened a PR with the changes that got that going for the ZMasters.

I will look into the temperatures. Is the rules.conf working to shutdown - would I need to amend anything for ZMasters?

I do have Z9s as well but they're at another location and I'm working on getting the ZMasters set up first.

supernoveau avatar Nov 15 '18 02:11 supernoveau

Thanks for the PR. I will review it.

Once you get the hash and temp into my Miner object then it should work fine for the rules.conf.

You may have to modify when_runrules.py to suit your situation.

dfoderick avatar Nov 15 '18 13:11 dfoderick