Bitcoin Forum

Bitcoin => Mining software (miners) => Topic started by: shazbits on June 12, 2013, 12:24:19 AM



Title: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: shazbits on June 12, 2013, 12:24:19 AM
cgminer-monitor

Simple monitor script for cgminer in python.
Console display, http server, email alerts. No additional modules required.


Tested with python 2.7.2 and cgminer 3.2.0.

usage: cgminer-monitor.py [command] [parameter]


Monitor mode
cgminer-monitor.py
 - Monitors cgminer by checking a few critical values
 - Emails if something is wrong
 - Restarts cgminer if the GPU is sick or dead
 - Runs a dead simple http server that only serves a page with the results of the monitor (identical to the console output with a nice display)
 - Monitors MMFCE pools and display the current balance in their currencies
 - Could support multi-gpus very easily (see comment in the code)
 - CTRL+C to stop everything

http://www.shazbits.com/images/cgminer-monitor.png

http://www.shazbits.com/images/cgminer-monitor-iphone_tn.png

http://www.shazbits.com/images/cgminer-monitor-email.png


Command mode
cgminer-monitor.py somecommand someoptionalparameter
 - Ouputs the results returned by cgminer miner and exits
 - Examples:
    - cgminer-monitor.py summary
    - cgminer-monitor.py gpu 0
    - See cgminer's API-README for all available commands


Credits
CGMinerClient class based on WyseNynja's gist https://gist.github.com/WyseNynja/1500780

Notes
I know there are a bunch of watchers, web interfaces and all but they are far too advanced for my light mining. I didn't want to have to run somone's .exe or have to compile it myself, or install apache/php, etc.
I just wanted the simplest thing so I made this single python script (about 200 lines without the comments) to do everything listed above. There is no install or anything, just set a couple of config values at the top and run it.

It only supports 1 GPU (because I've only one :/) but that should be as simple as adding a for loop and changing a couple of indexes to support multi gpus.

Updates

06/22/2013:
Monitors MMFCE pools + minor improvements
  • Monitors MMFCE pools and display the current balance in their currencies (web page only)
  • Display the current pool URL
  • Don't send a warning email in the first 10 seconds (hashrate takes a bit to get stable)
  • Use a smaller font for the web page
  • Ignore requests on /favicon.ico that most browsers send
  • Faster shutdown with CTRL+C (within 1 second)


https://github.com/shazbits/cgminer-monitor

BTC 1Kcn1Hs76pbnBpBQHwdsDmr3CZYcoCAwjj


Title: Re: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: jaycuse on June 22, 2013, 04:41:00 PM
Thanks, this is exactly what I was looking for :)

Some thing small and simple for my raspberry pi. Modified it for linux and to display my block erupter USBs. If anyone wants the source let me know.

A few notes
I'm using cgminer 3.1.1
in order to send the api command gpu (basically to list details of the device, in my case I used devs) and to restart you need to run cgminer with --api-listen and --api-allow W:127.0.0.1


Title: Re: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: shazbits on June 22, 2013, 09:11:10 PM
Glad you like it :)

New update - 06/22/2013:

Monitors MMFCE pools + minor improvements
  • Monitors MMFCE pools and display the current balance in their currencies (web page only)
  • Display the current pool URL
  • Don't send a warning email in the first 10 seconds (hashrate takes a bit to get stable)
  • Use a smaller font for the web page
  • Ignore requests on /favicon.ico that most browsers send
  • Faster shutdown with CTRL+C (within 1 second)

I kept the spirit of the script intact while making this update. There is still no additional dependencies and still just 1 file to run.
Updated screenshots on first post.


Title: Re: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: PirateHatForTea on August 16, 2013, 01:50:15 AM
Would this script work with an Avalon? I have a plugcomputer setup on the same network as my avalon, with --api-allow set for its IP, so I could theoretically use it to monitor CGMiner and restart it if something goes wrong.


Title: Re: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: shazbits on August 16, 2013, 03:22:48 AM
As long as you run cgminer and the API has not changed the script should just work with it.


Title: Re: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: mruiter on August 22, 2013, 06:23:33 PM
As long as you run cgminer and the API has not changed the script should just work with it.

So bfgminer wil work to i gues, api is almost the same, maybee restart tweak to bfgminer executable.
Anyone tested it yet ?


Title: Re: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: shazbits on August 22, 2013, 08:03:31 PM
It should work, the API looks the same: https://github.com/luke-jr/bfgminer/blob/bfgminer/README.RPC
The monitor is only using the following commands: coin, pools, gpu, summary, stats, restart and they're all in bfgminer's page.


Title: Re: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: MarvelMiner on October 23, 2013, 07:40:23 PM
[Errno 10061] No connection could be made because the target machine actively re
fused it


Title: Re: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: shazbits on October 31, 2013, 02:02:45 AM
[Errno 10061] No connection could be made because the target machine actively re
fused it

Your cgminer is not listening on localhost on the port 4028. The monitor can't connect to it.

You can either launch cgminer with default API settings (listening interface/port), or you can edit these 2 lines at the top of cgminer-monitor.py.

Code:
cgminer_host = 'localhost'
cgminer_port = 4028


Title: Re: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console
Post by: compile on December 19, 2013, 06:39:29 PM
Is there a way to change MHS to KHS?

I would prefer see my KHS.