Results 1 to 3 of 3

Thread: P2Pool and scripting

Hybrid View

  1. #1

    Default P2Pool and scripting

    I have a script for my P2Pool which I am not sure how to create or make. I am not really a *nix guy. I am using KDE so yes I know how to open KWrite and copy and paste the script into it, but I don't know were to save it or if I need to make any changes using chmod to the file?

    I appreciate your help!

    Example script:

    ###sample script

    #!/bin/bash


    NICE=`ps -eo pid,nice,command | grep '/home/btd/bitcoinroot/bin/bitcoind' | grep -v grep | awk '{ print $2 }'`
    PID=`ps -eo pid,nice,command | grep '/home/btd/bitcoinroot/bin/bitcoind' | grep -v grep | awk '{ print $1 }'`

    P2P_NICE=`ps -eo pid,nice,command | grep '/home/xo/p2pool/run_p2pool.py' | grep -v grep | awk '{ print $2 }'`
    P2P_PID=`ps -eo pid,nice,command | grep '/home/xo/p2pool/run_p2pool.py' | grep -v grep | awk '{ print $1 }'`

    if [ $NICE -ne -20 ] ; then

    echo "$PID is not nice!"
    echo "Setting $PID to -20 nice value..."
    renice -n -20 -p $PID
    ionice -c1 -p $PID

    else

    echo "$PID is already set to nice value $NICE"
    fi

    if [ $P2P_NICE -ne -20 ] ; then

    echo "p2pool is not running with nice"
    echo "Setting $P2P_PID to -20 nice value.."
    renice -n -20 -p $P2P_PID
    ionice -c1 -p $P2P_PID

    else
    echo "p2pool is already running with $P2P_NICE "
    fi

    ##script ends

    ##change txqueuelen of network interface
    ifconfig ens32 txqueuelen 2000



  2. #2

    Default Re: P2Pool and scripting

    For normal/single user you can put your script in

    Code:
    ~/bin
    aka

    Code:
    "$HOME/bin"
    For system wide aka global script that everyone in your system can use it then it should be in

    Code:
    /usr/local/bin
    The script needs to be executable too, either right click on the script using your mouse and make the permission executable or

    Code:
    chmod +x myscript
    or

    Code:
    chmod +x ~/bin/myscript
    myscript is arbitary in this case.
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

  3. #3

    Default Re: P2Pool and scripting

    Once you have that script in your PATH ie either in ~/bin or /usr/local/bin then you can just awk for everything since you're already using it. Here is my example


    Code:
    ps -eo pid,nice,command | awk '/virtualbox/'
    
    085   0 /usr/lib/virtualbox/VBoxXPCOMIPCD
    2099 0 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
    2193 0 /usr/lib/virtualbox/VBoxHeadless --comment Apache3 --startvm 847216e3-1d84-4327-9a6a-f1c4050bb792 --vrde config
    9299 0 awk /virtualbox/
    It prints the awk command as well that is why you needed then grep -v grep, using grep to avoid it

    Code:
    ps -eo pid,nice,command | grep '[v]irtualbox'
    2085   0 /usr/lib/virtualbox/VBoxXPCOMIPCD
    2099   0 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
    2193   0 /usr/lib/virtualbox/VBoxHeadless --comment Apache3 --startvm 847216e3-1d84-4327-9a6a-f1c4050bb792 --vrde config
    However that needs an additional cut command or an awk command to print the second field. No worries since you can do that all in awk.

    Code:
    ps -eo pid,nice,command | awk '/[v]irtualbox/{print $1}'
    
    ps -eo pid,nice,command | awk '/[v]irtualbox/{print $2}'
    In your case that should be something like

    Code:
    nice=$(ps -eo pid,nice,command | awk  '/[b]itcoind/{print $2}')


    Code:
    pid=$(ps -eo pid,nice,command | awk  '/[b]itcoind/{print $1}')


    Code:
    p2p_nice=$(ps -eo pid,nice,command | awk '/[r]un_p2pool\.py/{ print $2 }')
    Code:
    p2p_pid=$(ps -eo pid,nice,command | awk '/[r]un_p2pool\.py/{ print $1 }')


    The \ before the .py is to make the dot . literal since dot means any character in regrexp. That should be a start, the rest you can adjust as you learn more
    .
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •