Bitcoin Forum

Bitcoin => Mining => Topic started by: bitcoindaddy on May 26, 2011, 01:31:54 PM



Title: Linux bitcoin text tricks
Post by: bitcoindaddy on May 26, 2011, 01:31:54 PM
These snippets are made to be used in a linux terminal instead of using a browser. I've actually had my system lock up when I started the browser because I was so close to the "edge" when overclocking. They use the linux "watch" command which runs a command periodically over and over. Please don't lower the number of seconds between updates too low when accessing data from someone else's website - you risk having your IP address blocked by the owner.

Show mining progress on Deepbit.net
This could be adapted for other pools that provide JSON statistics. The command requires that you replace the xxxxxxxxx stuff with your JSON API token available on this page: https://deepbit.net/settings (https://deepbit.net/settings)
Code:
curl -s 'http://deepbit.net/api/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' |
sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1;
i<=n; i++) print a[i]}' | grep -e 'confirmed_reward' -e 'hashrate'
The sed and awk stuff is from this page: http://stackoverflow.com/questions/1955505/parsing-json-with-sed-and-awk (http://stackoverflow.com/questions/1955505/parsing-json-with-sed-and-awk)
To show the results continuously, put the command above into a file in /tmp/miningstats, make miningstats executable with "chmod 755 /tmp/miningstats" and use the following command to update it every 60 seconds:
Code:
sudo -u nobody watch -n 60 /tmp/miningstats
I run the code under the userid nobody so that the website owner can't do anything to your system.

Show Current Prices from MtGox
Put the following command in /tmp/mtgoxquote:
Code:
curl -s 'https://mtgox.com/code/data/ticker.php' | sed -e 's/[{}]/''/g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}'
Make the file executable with "chmod 755 /tmp/mtgoxquote"
Show it every 5 minutes in a terminal:
Code:
sudo -u nobody watch -n 300 /tmp/mtgoxquote

Show Wallet Status
This will show your balance, the number of connections, etc.
Code:
watch -n 30 bitcoind getinfo

If you have any additional tips, post them here.



Title: Re: Linux bitcoin text tricks
Post by: Pygy on May 26, 2011, 02:53:57 PM
Thanks for sharing :-)


Title: Re: Linux bitcoin text tricks
Post by: inh on May 26, 2011, 03:14:01 PM
From the linuxcoin thread, I think. Found this in a totally different thread :p

Code:
while true; do
        aticonfig --adapter=0 --od-gettemperature | tail -n1 | awk '{print "Current temp: " $5}' ;
        aticonfig --adapter=0 --od-gettemperature | tail -n1 | awk '{print "Current temp: " $5}' ;
        echo $(aticonfig --odgc --adapter=0| grep GPU);
        echo $(aticonfig --odgc --adapter=1| grep GPU);
# Next lines are to check your balance if solo mining
#        BALANCE=$(bitcoind getbalance)
#        echo -ne "Bitcoin Balance: ${BALANCE}\r";
        sleep 35;
        clear
done


Title: Re: Linux bitcoin text tricks
Post by: a7thson on May 26, 2011, 03:25:31 PM
From the linuxcoin thread, I think. Found this in a totally different thread :p

Code:
while true; do
        aticonfig --adapter=0 --od-gettemperature | tail -n1 | awk '{print "Current temp: " $5}' ;

I use this in my scripting (linux, catalyst 11.5) :
Code:
aticonfig --adapter=0 --odgt | awk '/Temperature/ { print $5 }'

You can stick it into a while loop and get the same thing with one less command in the pipeline


Title: Re: Linux bitcoin text tricks
Post by: Binford 6100 on May 26, 2011, 03:42:09 PM
Thanks for sharing :-)
+1

I'm running a bitcoin deamon for dev/test purposes and a terminal cheat sheet is what i hoped for :)
not mining nor trading but still in need to learn how to use it (preferably from terminal) :)


Title: Re: Linux bitcoin text tricks
Post by: a7thson on May 26, 2011, 04:02:28 PM
here's GPU load too
Code:
aticonfig --adapter=0 --odgc | awk '/GPU\ load/ { print $4 }'

It's more useful just to use as an indicator of mining failure than anything... i.e.

Code:
#!/bin/sh
GPU_LOAD="$(aticonfig --adapter=0 --odgc | awk '/GPU\ load/ { print $4 }')"
[[ "$GPU_LOAD" == "98%" || "$GPU_LOAD" == "99%" ]] && echo "miner running" || echo "GPU melted :("


Title: Re: Linux bitcoin text tricks
Post by: inh on May 26, 2011, 05:09:35 PM
here's GPU load too
Code:
aticonfig --adapter=0 --odgc | awk '/GPU\ load/ { print $4 }'

It's more useful just to use as an indicator of mining failure than anything... i.e.

Code:
#!/bin/sh
GPU_LOAD="$(aticonfig --adapter=0 --odgc | awk '/GPU\ load/ { print $4 }')"
[[ "$GPU_LOAD" == "98%" || "$GPU_LOAD" == "99%" ]] && echo "miner running" || echo "GPU melted :("

I think I've seen high GPU loads when the system locked up, so i would verify by checking temps. Low temp = obviously not being used :)


Title: Re: Linux bitcoin text tricks
Post by: frozen on May 26, 2011, 05:30:54 PM
btcguild api json tree:

Code:
curl -s http://www.btcguild.com/api.php?api_key=PUT_API_KEY_HERE | python -mjson.tool



Title: Re: Linux bitcoin text tricks
Post by: error on May 26, 2011, 08:21:51 PM
Running the script as nobody protects the user from the script author. :P


Title: Re: Linux bitcoin text tricks
Post by: inh on June 05, 2011, 01:40:45 PM
Here's a modified version of what I posted earlier. It's easier to configure for multiple GPUs.

Code:
#!/bin/bash

#set the line below to the exact number of GPUs you have in your system
GPU_COUNT=3

while true; do

#loop for each GPU and spit out the temp and load

COUNTER=1
let GPU_COUNT-1

while [  $COUNTER -le $GPU_COUNT ]; do
 aticonfig --adapter=${COUNTER} --od-gettemperature | tail -n1 | awk '{print "Current temp: " $5}' ;
 echo $(aticonfig --odgc --adapter=${COUNTER}| grep GPU);
 echo -e " \n"
 let COUNTER=COUNTER+1
done

# Next lines are to check your balance if solo mining
#        BALANCE=$(bitcoind getbalance)
#        echo -ne "Bitcoin Balance: ${BALANCE}\r";
        sleep 10;
        clear
done


Title: Re: Linux bitcoin text tricks
Post by: inh on June 11, 2011, 09:29:38 PM
Use tee to be able to see program output on your screen AND log it to a file :)


Title: Re: Linux bitcoin text tricks
Post by: supa on June 13, 2011, 02:37:55 PM
Copypasta from another thread...  Had I known this thread existed, I would've started here. :)


Code:
#!/bin/bash
while [ 1 ]; do
        echo "<html><head><meta http-equiv=\"refresh\" content=\"5\"/><body>$(aticonfig --adapter=all --odgt | sed ':a;N;$!ba;s/\n/<br\/>/g')<body></html>" | nc -l 9001
done

I realized we have a lot of new Linux users out there, so here's a simple script to keep you away from the GUI.

Put the above in a file, chmod u+x it, run it.  That's it.  Connect with a browser to whatever the host is, port 9001.

Requires netcat (nc).

Feel free to replace "aticonfig --adapter=all --odgt" with whatever you like - use tee to redirect your miner output or whatever you want to a file, then push that through netcat.

Let's say you've got a script called startminer.sh that starts poclbm (or whatever).  You can use the following to start it:

startminer.sh | tee -a minerlog.log

Then use -
Code:
#!/bin/bash
while [ 1 ]; do
        echo "<html><head><meta http-equiv=\"refresh\" content=\"5\"/><body>$(sed ':a;N;$!ba;s/\n/<br\/>/g' < minerlog.log)<body></html>" | nc -l 9001
done

For ssh sessions, don't forget that happy watch command -
watch -n 1 aticonfig --adapter=all --odgt

Will continuously print to the screen the output from aticonfig every 1 second.

And finally, if you're using eligius, don't forget there are both EU and US servers.

I haven't been able to test the following script... eligius servers haven't gone down.  But the idea is if you had a line in your /etc/hosts like:

173.242.112.67 eligius.mining

And pointed a miner at http://eligius.mining:8337 while the script below ran..... if the hashrate for that server hit 0 or was otherwise unreachable it should "failover" to the other server.

Code:
#!/bin/bash

EUHTTP="http://eligius.st/~luke-jr/raw/eu/hashrate.txt"
USHTTP="http://eligius.st/~luke-jr/raw/us/hashrate.txt"

EUIP="85.25.78.8"
USIP="173.242.112.67"

export EUIP
export USIP

CURRENT=$USHTTP

echo $EUIP
echo $USIP

while [ 1 == 1 ]; do
echo "Checking..."

HR=$(wget -q -O - $CURRENT)

if [ -z "$HR" ]
then
HR="0"
fi

echo "Hashrate $HR"

if [ $CURRENT == $USHTTP ]
then
if [ $HR == 0 ]
then
cp /etc/hosts /tmp/hosts
sed s/$USIP/$EUIP/ < /tmp/hosts > /etc/hosts
echo "Switched to Europe."
CURRENT=$EUHTTP
fi
elif [ $CURRENT == $EUHTTP ]
then
if [ $HR == 0 ]
then
cp /etc/hosts /tmp/hosts
sed s/$EUIP/$USIP/ < /tmp/hosts > /etc/hosts
echo "Switched to US."
CURRENT=$USHTTP
fi
fi
sleep 5m
done


Title: Re: Linux bitcoin text tricks
Post by: LehmanSister on June 14, 2011, 07:58:06 PM
I have a script here, as well as a Python class that needs much more work. And I also found a far far better mine monitor as well, all referenced over here:

http://forum.bitcoin.org/index.php?topic=13855.msg210638