Bitcoin Forum
December 05, 2016, 08:33:13 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Linux bitcoin text tricks  (Read 4962 times)
bitcoindaddy
Hero Member
*****
Offline Offline

Activity: 481


View Profile
May 26, 2011, 01:31:54 PM
 #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.

1480926793
Hero Member
*
Offline Offline

Posts: 1480926793

View Profile Personal Message (Offline)

Ignore
1480926793
Reply with quote  #2

1480926793
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480926793
Hero Member
*
Offline Offline

Posts: 1480926793

View Profile Personal Message (Offline)

Ignore
1480926793
Reply with quote  #2

1480926793
Report to moderator
1480926793
Hero Member
*
Offline Offline

Posts: 1480926793

View Profile Personal Message (Offline)

Ignore
1480926793
Reply with quote  #2

1480926793
Report to moderator
Pygy
Jr. Member
*
Offline Offline

Activity: 47


View Profile
May 26, 2011, 02:53:57 PM
 #2

Thanks for sharing :-)
inh
Full Member
***
Offline Offline

Activity: 157


View Profile
May 26, 2011, 03:14:01 PM
 #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
a7thson
Newbie
*
Offline Offline

Activity: 7


View Profile
May 26, 2011, 03:25:31 PM
 #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

find something useful in my  post? 13FMjxBshHfrRPLzz41t5UcWyKXWwpoTTt
Binford 6100
Hero Member
*****
Offline Offline

Activity: 504


PGP OTC WOT: EB7FCE3D


View Profile
May 26, 2011, 03:42:09 PM
 #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

You can't build a reputation on what you are going to do.
a7thson
Newbie
*
Offline Offline

Activity: 7


View Profile
May 26, 2011, 04:02:28 PM
 #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 :("

find something useful in my  post? 13FMjxBshHfrRPLzz41t5UcWyKXWwpoTTt
inh
Full Member
***
Offline Offline

Activity: 157


View Profile
May 26, 2011, 05: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
frozen
Full Member
***
Offline Offline

Activity: 196



View Profile WWW
May 26, 2011, 05: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


error
Hero Member
*****
Offline Offline

Activity: 574



View Profile
May 26, 2011, 08:21:51 PM
 #9

Running the script as nobody protects the user from the script author. Tongue

15UFyv6kfWgq83Pp3yhXPr8rknv9m6581W
inh
Full Member
***
Offline Offline

Activity: 157


View Profile
June 05, 2011, 01:40:45 PM
 #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
inh
Full Member
***
Offline Offline

Activity: 157


View Profile
June 11, 2011, 09:29:38 PM
 #11

Use tee to be able to see program output on your screen AND log it to a file Smiley
supa
Jr. Member
*
Offline Offline

Activity: 42


View Profile
June 13, 2011, 02:37:55 PM
 #12

Copypasta from another thread...  Had I known this thread existed, I would've started here. Smiley


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

LehmanSister
Member
**
Offline Offline

Activity: 68


High Desert Dweller-Where Space and Time Meet $


View Profile
June 14, 2011, 07: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

ISO: small island nations with large native populations excited to pay tribute to flying gods, will trade BTC.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!