Author

Topic: Linux bitcoin text tricks (Read 5366 times)

member
Activity: 68
Merit: 10
High Desert Dweller-Where Space and Time Meet $
June 14, 2011, 02:58:06 PM
#13
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
copper member
Activity: 56
Merit: 0
June 13, 2011, 09:37:55 AM
#12
Copypasta from another thread...  Had I known this thread existed, I would've started here. Smiley


Code:
#!/bin/bash
while [ 1 ]; do
        echo "$(aticonfig --adapter=all --odgt | sed ':a;N;$!ba;s/\n//g')" | 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 "$(sed ':a;N;$!ba;s/\n//g' < minerlog.log)" | 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
inh
full member
Activity: 155
Merit: 100
June 11, 2011, 04:29:38 PM
#11
Use tee to be able to see program output on your screen AND log it to a file Smiley
inh
full member
Activity: 155
Merit: 100
June 05, 2011, 08:40:45 AM
#10
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
hero member
Activity: 588
Merit: 500
May 26, 2011, 03:21:51 PM
#9
Running the script as nobody protects the user from the script author. Tongue
full member
Activity: 196
Merit: 100
May 26, 2011, 12:30:54 PM
#8
btcguild api json tree:

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

inh
full member
Activity: 155
Merit: 100
May 26, 2011, 12:09:35 PM
#7
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 Smiley
newbie
Activity: 7
Merit: 0
May 26, 2011, 11:02:28 AM
#6
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 :("
hero member
Activity: 504
Merit: 504
PGP OTC WOT: EB7FCE3D
May 26, 2011, 10:42:09 AM
#5
Thanks for sharing :-)
+1

I'm running a bitcoin deamon for dev/test purposes and a terminal cheat sheet is what i hoped for Smiley
not mining nor trading but still in need to learn how to use it (preferably from terminal) Smiley
newbie
Activity: 7
Merit: 0
May 26, 2011, 10:25:31 AM
#4
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
inh
full member
Activity: 155
Merit: 100
May 26, 2011, 10:14:01 AM
#3
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
newbie
Activity: 47
Merit: 0
May 26, 2011, 09:53:57 AM
#2
Thanks for sharing :-)
hero member
Activity: 481
Merit: 500
May 26, 2011, 08:31:54 AM
#1
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
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
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.

Jump to: