Author

Topic: [Phoenix Addon] Simple export hashrate and accepted/rejected to a text file (Read 3325 times)

newbie
Activity: 41
Merit: 0
I've modified this patch (when you first posted it to the Phoenix thread) to also include a timestamp in the file. It's distributed with the "Rug Monitor" package. Link: https://github.com/disq/bitcoin-rug-monitor/blob/master/logtotext-1.48.diff
legendary
Activity: 2058
Merit: 1431
can someone compile this to a windows .exe? i got python installed, but executing .py files is really screwing up my scripts
newbie
Activity: 9
Merit: 0
I think my solution using XML-RPC is a bit more elegant: http://forum.bitcoin.org/index.php?topic=23308.0
legendary
Activity: 2058
Merit: 1431
ups, it must be a typo Tongue thanks for reporting.
oh the irony!
hero member
Activity: 1134
Merit: 502
Vave.com - Crypto Casino
ups, it must be a typo Tongue thanks for reporting.
member
Activity: 98
Merit: 11
Great work! It's all good except the error here:

Code:
            self.lastUpdate = time()e
needs to be

Code:
            self.lastUpdate = time()
hero member
Activity: 1134
Merit: 502
Vave.com - Crypto Casino
I could open it at begining and them just attach, but i like to have no need for parsing the file to get the last hashrate. Single line make it easy to use it later, and i like that the file will never increase in size.

Personally i have no problems with opening/closing the file, as im using a temp folder on mem, that folder its actually the apache 2 root folder, so i can access those text file from my server, making a php web page with a updated hash rate and temps of every miner i have, it maybe wastefull but even writting on a pendrive has no issues for the miner, of course, you will destroy the pendrive if you store the file in it Tongue

Thats makes monitoring my miners very very easy. Im using that method you explained to export to text file the temperatures of my cards, those file are also uploaded to the same folder.

Also, i have some single vga rigs using my minerpe, under Windows based operative system you cant do that with phoenix... you end with a file of over a 1gb in size in 2 hours lol, and its very very difficult to parse.

Im not a Python programer, im C/C++, so there maybe some way to do so whiout opening the file everytime, in c i could just move the pointer to the begining of the file everytime.
hero member
Activity: 560
Merit: 517
Very useful feature! A small quibble: Why are you opening and closing the file every time? That's very wasteful.


I was too lazy to modify phoenix when I discovered a need for logging, so I use a script like this (poclbm is the example here):

Code:
./poclbm.py --verbose blahblahmoreargs -d $1 > ~/miner_log_$1.txt 2>&1

And then I can execute ./miner.sh 0 & or ./miner.sh 1 &, etc to bring up all my miners. I use tail -f ~/miner_log_0.txt to monitor the log, and do so remotely over SSH with multitail Smiley

Anyway, I'm glad someone took the time to put some file logging into phoenix!
hero member
Activity: 1134
Merit: 502
Vave.com - Crypto Casino
Hi, i posted the code in the phoenix tropic, but i place it here. I done this to help me monitor my miners.

What this mod do is add a new command line argument ( -l ), this allow you to set a output filename for the status.

Examples:
Quote
./phoenix.py -u http://user:pass@server:port -k kernel device=x WORKSIZE=128 VECTORS AGGRESSION=12 BFI_INT FASTLOOP=FALSE -l hashrate.txt
That one will output the file to the phoenix folder.

Quote
sudo ./phoenix.py -u http://user:pass@server:port -k kernel device=x WORKSIZE=128 VECTORS AGGRESSION=12 BFI_INT FASTLOOP=FALSE -l /usr/hashrate.txt
That one will place the file intro the /usr folder, sudo is required for permision.

I use .txt as a example, the extension does not matter. You can call it index.html and place intro the apache web folder it you want.

The output is something like this, in a single line, no attachments.
Quote
[400.31 Mhash/sec] [0 Accepted] [0 Rejected] [RPC]

You need to edit the code in phoenix.py and ConsoleLogger.py.

phoenix.py

Search for:
Code:
self.queue = None
Put this below:
Code:
        self.queue = None
       self.logtotext = None

Search for:
Code:
        parser.add_option("-a", "--avgsamples", dest="avgsamples", type="int",
            default=10,
            help="how many samples to use for hashrate average")
reemplace with:
Code:
        parser.add_option("-a", "--avgsamples", dest="avgsamples", type="int",
            default=10,
            help="how many samples to use for hashrate average"),
        parser.add_option("-l", "--logtotext", dest="logtotext", default="none",
            help="-l filename.txt log hashrate to text option, disabled by default")

Search for:
Code:
self.logger = ConsoleLogger(miner,self.parsedSettings.verbose)
Reemplace with this:
Code:
self.logger = ConsoleLogger(miner,self.parsedSettings.verbose,self.parsedSettings.logtotext)


ConsoleLogger.py

Search for:
Code:
    def __init__(self, miner, verbose=False):
        self.verbose = verbose
        self.miner = miner
        self.lastUpdate = time() - 1
        self.rate = 0
        self.accepted = 0
        self.invalid = 0
        self.lineLength = 0
        self.connectionType = None
Reemplace with this:
Code:
    def __init__(self, miner, verbose=False, logtotext="none"):
        self.verbose = verbose
        self.miner = miner
        self.logtotext = logtotext
        self.lastUpdate = time() - 1
        self.rate = 0
        self.accepted = 0
        self.invalid = 0
        self.lineLength = 0
        self.connectionType = None

Search for:
Code:
self.say(status)
self.lastUpdate = time()
Reemplace with this:
Code:
            self.say(status)
            if self.logtotext != "none":
                try:
                        f = open(self.logtotext,"w")
                        f.write(status)
                        f.close()
                except IOError as e:
                        print("({})".format(e))
           self.lastUpdate = time()

All credits are for jedi95, its his miner, i just did a small addon for it.  Wink
Jump to: