-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor coding style changes and typo fixes #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,29 +6,33 @@ | |
# XPM: AV3w57CVmRdEA22qNiY5JFDx1J5wVUciBY | ||
|
||
if [ "$#" -ne "2" ] ; then # Script needs two parameters. | ||
echo "USAGE: ./datawatch.sh POOL MODE" | ||
echo "DTC pools: xpool, gpool" | ||
echo "Modes: stay, jump" | ||
echo "Example: ./datawatch.sh xpool jump" | ||
echo "(xpool - dtc.xpoll.xram.co | gpool - dtc.gpoool.net)" | ||
echo "WARNING: you have to edit script if you haven't do so." | ||
exit | ||
cat <<-USAGE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I don't like cats like this personally... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can still indent the text with the cat, but I understand if you prefer the echo way which is what it's used more widely but I just like good coding practice in bash. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not that big diffrence if it was already written and works, but triple USAGE can break syntax highlighting (seems to happen on github site with that). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change "USAGE" to "HELP". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I already put standard EOF there (second branch, https://github.com/arkhebuz/datawatch/blob/patch1patch/datawatch.sh, that is). |
||
USAGE: ./datawatch.sh POOL MODE | ||
DTC pools: xpool, gpool | ||
Modes: stay, jump | ||
Example: ./datawatch.sh xpool jump | ||
(xpool - dtc.xpoll.xram.co | gpool - dtc.gpoool.net) | ||
WARNING: you have to edit script if you haven't do so. | ||
USAGE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a much better way to print multiple lines, instead of having all those echos :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh I missed the |
||
fi | ||
|
||
# Catalog where logs will be stored. | ||
logkat="/home/arkhebuz/datacoin" | ||
logkat="${HOME}/.datacoin" | ||
|
||
# Catalog corresponding to network interface you are using, containing carrier file (like /sys/class/net/eth0/carrier) having value of either 1 if network is up or 0 if it's down. | ||
# Catalog corresponding to network interface you are using, containing carrier file | ||
# (like /sys/class/net/eth0/carrier) having value of either 1 if network is up or 0 if it's down. | ||
netinterface="/sys/class/net/eth0" | ||
|
||
# Interval in seconds bettwen checks, too small will make the script steal cpu cycles and usually won't let the miner recover under its own steam when possible. Five to ten minutes is good enough in my expirence. | ||
# Interval in seconds between checks, too small will make the script steal cpu cycles and usually | ||
# won't let the miner recover under its own steam when possible. | ||
# Five to ten minutes is good enough in my expirience | ||
sleeptime=600 | ||
|
||
function minerlaunch { | ||
if [ "$1" = "xpool" ] ; then | ||
if [ "${1}" = "xpool" ] ; then | ||
ip="162.243.241.151" | ||
port="1335" | ||
elif [ "$1" = "gpool" ] ; then | ||
elif [ "${1}" = "gpool" ] ; then | ||
ip="162.243.41.59" | ||
port="8336" | ||
fi | ||
|
@@ -40,78 +44,76 @@ function minerlaunch { | |
# -genproclimit="8" <-- Number of threads to use. | ||
# -sievesize="1000000" -sieveextensions="10" -sievepercentage="9" <-- These parameters affect mining. Nobody wants to say what this three are exactly doing. Mayby nobody knows? | ||
# For me it works little better with these values. Either play with them or cut this three out. | ||
# Note: don't change -poolip=$ip -poolport=$port and -poolshare=6 unless you know things are working. | ||
./primeminer -poolip=$ip -poolport=$port -poolshare=6 -pooluser=DMy7cMjzWycNUB4FWz2YJEmh8EET2XDvqz -genproclimit="8" -sievesize="1000000" -sieveextensions="10" -sievepercentage="9" 2>&1 | tee -a $logkat/$filename & | ||
# Note: don't change -poolip=${ip} -poolport=${port} and -poolshare=6 unless you know things are working. | ||
./primeminer -poolip=${ip} -poolport=${port} -poolshare=6 -pooluser=DMy7cMjzWycNUB4FWz2YJEmh8EET2XDvqz -genproclimit="8" -sievesize="1000000" -sieveextensions="10" -sievepercentage="9" 2>&1 | tee -a ${logkat}/${filename} & | ||
} | ||
|
||
# 5 DNS servers for a very "finesse" connection checking... No need to change them. | ||
google1=8.8.8.8 # <-- this one is checked first - if it's ok, the rest is omnitted. | ||
google2=8.8.4.4 | ||
opendns1=208.67.222.222 | ||
level3=209.244.0.3 | ||
comodo=8.26.56.26 | ||
# First DNS server is checked first - if it's ok, the rest are omnitted. | ||
declare -A dns_servers=( [google1]=8.8.8.8 [google2]=8.8.4.4 [opendns1]=208.67.222.222 [level3]=209.244.0.3 | ||
[comodo]=8.26.56.26 ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, but you changed script behaviour a little (see below) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see my comment here ->likewhoa@5e088af#commitcomment-4998832 |
||
|
||
hammer=$1 # you can't touch this | ||
hammer=${1} # DO NOT EDIT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I really appreciate any kind of feedback, I won't let anybody to make my code more serious, period. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hehe, you're right :) |
||
|
||
while true ; do | ||
# Checking for primeminer process, launching if not found. | ||
islive=$(pgrep primeminer) | ||
if [ -z "$islive" ] ; then | ||
if [ -z "${islive}" ] ; then | ||
echo -n "primeminer not found, launching... " | ||
minerlaunch $hammer | ||
minerlaunch ${hammer} | ||
echo "PID: $(pgrep primeminer)" | ||
fi | ||
|
||
ping=$(ping -q -w2 -c2 $google1 | grep -o -P ".{0,2}received" | head -c 1) | ||
if [ "1" -ge "$ping" ] ; then # Ping Google to check internet, if problems proceed. | ||
ping=$(ping -q -w2 -c2 ${dns_servers[google1]} | grep -o -P ".{0,2}received" | head -c 1) | ||
if ((1>ping)); then # Ping Google to check internet, if problems proceed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Little change of behaviour too, orginally this was like |
||
n=0 | ||
carrier=$(cat $netinterface/carrier) | ||
carrier=$(<${netinterface}/carrier) | ||
|
||
for ip in $google2 $opendns1 $level3 $comodo ; do # Checking rest of ip's, each two times, eight pings total. | ||
i=$(ping -q -w2 -c2 $ip | grep -o -P ".{0,2}received" | head -c 1) | ||
n=$[n+i] | ||
for ip in ${dns_servers[@]}; do # Checking rest of ip's, each two times. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here google1 is checked second time (well, doesn't really hurt), so max ping count is 10 instead of 8 (doesn't really hurt too, even with old log barrier). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only google2 is checked here, google1 was checked before hand. |
||
i=$(ping -q -w2 -c2 ${ip} | grep -o -P ".{0,2}received" | head -c 1) | ||
((n=$n+i)) | ||
done | ||
|
||
if [ "$n" -le "5" -a "$n" -gt "0" ] ; then # [1-4] out of 8 ping receieved, write to logs. | ||
echo "$(date) : conection problems, only $n packets received, carrier = $carrier" 2>&1 | tee -a $logkat/$filename | ||
echo "$(date) : conection problems, only $n packets received, carrier = $carrier" >> $logkat/netlog | ||
elif [ "$n" -eq "0" ] ; then # Zero pings received, write to logs. | ||
echo "$(date) : fatal conection problems - connection lost, carrier = $carrier" 2>&1 | tee -a $logkat/$filename | ||
echo "$(date) : fatal conection problems - connection lost, carrier = $carrier" >> $logkat/netlog | ||
if ((n<5 && n>0)) ; then # [1-4] out of 8 ping received, write to logs. | ||
echo "$(date) : conection problems, only ${n} packets received, carrier = ${carrier}" 2>&1 | tee -a ${logkat}/${filename} | ||
echo "$(date) : conection problems, only ${n} packets received, carrier = ${carrier}" >> ${logkat}/netlog | ||
elif ((n==0)) ; then # Zero pings received, write to logs. | ||
echo "$(date) : fatal conection problems - connection lost, carrier = ${carrier}" 2>&1 | tee -a $logkat/${filename} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ugh i hate when that happens |
||
echo "$(date) : fatal conection problems - connection lost, carrier = ${carrier}" >> ${logkat}/netlog | ||
fi | ||
fi | ||
|
||
# I had long lasting hangs with "force reconnect if possible!" communicate on my box. | ||
connection_lost=$(grep -in "force reconnect if possible" "$logkat/$filename" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/; $!d') # Get line number of last "force reconnect if possible" comm. | ||
connection_lost=$(grep -in "force reconnect if possible" "${logkat}/${filename}" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/; $!d') # Get line number of last "force reconnect if possible" comm. | ||
|
||
# I had hangs with "system:111" communicate too. Works like above. | ||
system111_comm_hang=$(grep -in "system:111" "$logkat/$filename" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/; $!d') | ||
system111_comm_hang=$(grep -in "system:111" "${logkat}/${filename}" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/; $!d') | ||
|
||
# In case when miner can't connect even at beggining, I guess. Thats when I see 'system:110'. | ||
system110_cant_connect=$(grep -in "system:110" "$logkat/$filename" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/; $!d') | ||
system110_cant_connect=$(grep -in "system:110" "${logkat}/${filename}" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/; $!d') | ||
|
||
# Get last [MASTER] communicate line number. | ||
masterline=$(grep -in "master" "$logkat/$filename" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/; $!d') | ||
if [ -z "$masterline" ] ; then masterline=1; fi | ||
masterline=$(grep -in "master" "${logkat}/${filename}" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/; $!d') | ||
if [ -z "${masterline}" ] ; then masterline=1; fi | ||
|
||
for hangs in connection_lost system111_comm_hang system110_cant_connect; do | ||
if [ -z "${!hangs}" ] ; then eval $hangs=0; fi | ||
if [ "${!hangs}" -gt "$masterline" ] ; then | ||
if [ -z "${!hangs}" ] ; then eval ${hangs}=0; fi | ||
if [ "${!hangs}" -gt "${masterline}" ] ; then | ||
# If theres no "[MASTER]" somewhere after error communicate then kill primeminer, write to logs and start (on another pool when in jumping mode). Works good with long enough sleeptime. | ||
echo "$(date) : primeminer $hangs, line: ${!hangs} (last master: $masterline)" 2>&1 | tee -a $logkat/$filename | ||
echo "$(date) : primeminer $hangs, line: ${!hangs} (last master: $masterline)" >> $logkat/netlog | ||
if [ "$2" = "jump" ] ; then | ||
if [ "$hammer" = "xpool" ] ; then # If you wondered what hammer is for... | ||
echo "$(date) : primeminer ${hangs}, line: ${!hangs} (last master: ${masterline})" 2>&1 | tee -a ${logkat}/${filename} | ||
echo "$(date) : primeminer ${hangs}, line: ${!hangs} (last master: ${masterline})" >> ${logkat}/netlog | ||
if [ "${2}" = "jump" ] ; then | ||
if [ "${hammer}" = "xpool" ] ; then # If you wondered what hammer is for... | ||
hammer="gpool" | ||
else | ||
hammer="xpool" | ||
fi | ||
fi | ||
pkill primeminer | ||
minerlaunch $hammer | ||
minerlaunch ${hammer} | ||
break | ||
fi | ||
done | ||
|
||
sleep $sleeptime | ||
sleep ${sleeptime} | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be changed too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally missed that one. we can change that with if (($#!=2))