Bitcoin Forum
May 14, 2024, 02:59:46 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: cgminer-monitor: Simple monitor script for cgminer in python. Alert/HTTP/console  (Read 12036 times)
shazbits (OP)
Member
**
Offline Offline

Activity: 105
Merit: 10



View Profile
June 12, 2013, 12:24:19 AM
Last edit: June 22, 2013, 09:16:21 PM by shazbits
 #1

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








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
Transactions must be included in a block to be properly completed. When you send a transaction, it is broadcast to miners. Miners can then optionally include it in their next blocks. Miners will be more inclined to include your transaction if it has a higher transaction fee.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715698786
Hero Member
*
Offline Offline

Posts: 1715698786

View Profile Personal Message (Offline)

Ignore
1715698786
Reply with quote  #2

1715698786
Report to moderator
1715698786
Hero Member
*
Offline Offline

Posts: 1715698786

View Profile Personal Message (Offline)

Ignore
1715698786
Reply with quote  #2

1715698786
Report to moderator
jaycuse
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
June 22, 2013, 04:41:00 PM
 #2

Thanks, this is exactly what I was looking for Smiley

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
shazbits (OP)
Member
**
Offline Offline

Activity: 105
Merit: 10



View Profile
June 22, 2013, 09:11:10 PM
 #3

Glad you like it Smiley

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.
PirateHatForTea
Full Member
***
Offline Offline

Activity: 181
Merit: 104


View Profile
August 16, 2013, 01:50:15 AM
 #4

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.

Unlevereged financial instruments acting as a store of value that fluctuate 50% within 10 minutes is perfectly acceptable. I think it should be offered in IRA form to soon to be retirees.
shazbits (OP)
Member
**
Offline Offline

Activity: 105
Merit: 10



View Profile
August 16, 2013, 03:22:48 AM
 #5

As long as you run cgminer and the API has not changed the script should just work with it.
mruiter
Sr. Member
****
Offline Offline

Activity: 281
Merit: 250



View Profile
August 22, 2013, 06:23:33 PM
 #6

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 ?

❘|❘ ICONOMI  Fund Management Platform
  LINK TO ICO | LINK TO DISCUSSION
shazbits (OP)
Member
**
Offline Offline

Activity: 105
Merit: 10



View Profile
August 22, 2013, 08:03:31 PM
 #7

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.
MarvelMiner
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
October 23, 2013, 07:40:23 PM
 #8

[Errno 10061] No connection could be made because the target machine actively re
fused it
shazbits (OP)
Member
**
Offline Offline

Activity: 105
Merit: 10



View Profile
October 31, 2013, 02:02:45 AM
 #9

[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
compile
Newbie
*
Offline Offline

Activity: 51
Merit: 0


View Profile
December 19, 2013, 06:39:29 PM
 #10

Is there a way to change MHS to KHS?

I would prefer see my KHS.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!