prun_doxer projects
Shell Perl Tcl
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


prun_doxer(/bin/prun_doxer) is a tool for running commands on Linux servers in parallel. It works by SSH(in parallel) to the list of Linux servers(defined in /etc/prun_doxer/server_list-running.txt) and execute commands(defined in /etc/prun_doxer/ line by line. It will try credentials(defined in /etc/prun_doxer/password_file) until get the right one.

You can get prun_doxer rpm package for Linux here

=== Interactive prun_doxer

You should edit prun_doxer config file(defined in /etc/prun_doxer/config) before running it(/bin/prun_doxer). Here's an sample of this file:

    #If there are 100 servers that need execute commands, then the max concurrent processes will be 60.
    #You can modify this
        set max_concurrent 60

    #The time to sleep when reaching max_concurrent
    #You can modify this(not suggested)
        set spawn_speed 10

    #The location to keep the commands that need run. No need to write "#!/bin/bash", as the commands will be ran by bash by default.
    #You should write commands in one line if possible. e.g. "for i in {1..10};do echo $i;done".
    #You should not modify this
        set SCRIPTFILE "/etc/prun_doxer/"

    #The location to keep the linux hosts that will have commands ran.
    #You should not modify this
        set HOSTFILE "/etc/prun_doxer/server_list-running.txt"

    #The location to keep credential.
    #You should not modify this
        set password_file "/etc/prun_doxer/password_file"

    #This is the maximum time in seconds that commands can reach.
    #You can modify this
        set timeout_value 36000

    #Each host will generate a log file, this variable defines the unique prefix of the log file.
    #You should not modify this
        set resfile "/var/log/prun_doxer/[exec date +%N]"

    #Sudo options for sudo to root
    #You can modify this
        set SUDOCMD_1 "/usr/bin/sudo su -"
        set SUDOCMD_2 "/usr/local/run_as_root 'su -'"
        set SUDOCMD_3 "pbrun root"

    #Whether the script will need root. 5 needs root, 2 no need(normal user is ok to run the script you defined).
    #You should modify this according to your needs
        #set IFSUDO 2
        set IFSUDO 5

    #Strings that will be deemed as non-root user
    #You should not modify this
        set prompt_notroot "(\\\$|\\\$\040)$"

    #prompt_root is the string that will be deemed as root user
    #prompt_all is the string that will be deemed as root or normal non-root user
    #You can use below when the servers are linux servers "[root@testbox ~]# " or ilom console "-> "
    #You should not modify this
        set prompt_root "(\->\040|#|#\040)$"
        set prompt_all "(\\\$|\\\$\040|\->\040|#|#\040)$"

    #prompt_root is the string that will be deemed as root user
    #prompt_all is the string that will be deemed as root or normal non-root user
    #You can use below when the servers are SUN ZFS appliances "filer01:> "
    #You should not modify this
        #set prompt_root "(\->\040|#|#\040|:>)"
        #set prompt_all "(\\\$|\\\$\040|\->\040|#|#\040|:>)"

After modification of /etc/prun_doxer/config according to your needs, you can now run prun_doxer. Here's what it looks like:

                Welcome to prun_doxer(by

                The hosts file will be:                         /etc/prun_doxer/server_list-running.txt

                The credentials file will be:                   /etc/prun_doxer/password_file

                The script file will be:                        /etc/prun_doxer/

                The log files pattern will be:                  /var/log/prun_doxer/762460000.<hostname>

        go      Start the script with these settings

        q       Exit immediately

                prompt_notroot is (\$|\$ )$

                prompt_root is (-> |#|# )$

                prompt_all is (\$|\$ |-> |#|# )$

                Need root, will try sudo

        Please enter the your selection:

As it suggested, you can type "go" followed by enter key. You can check logs in /var/log/prun_doxer/762460000.<hostname> to see the output of commands on each host.

=== Modules of prun_doxer

Modules extend prun_doxer's capabilities. You can check modules in /etc/prun_doxer/modules/. Under each module's directory, there's a README.txt file, you can check that for the usage.

Here's a brief introduction of existing modules:

    1. pping_doxer - ping multiple servers in parallel to check whether they are pingable or not.

    2. prun_doxer_telnet - telnet servers in parallel to check whether specified ports connectable or not.

    3. monitor - check memory/space of multiple servers in parallel, and sends mail when reaching threshold.

    4. get_root_access - get the way to log on servers with root access.

=== Writing modules with prun_doxer

You can write your own modules with prun_doxer in only a few steps. Please refer to get_root_access for reference. Here's the structure when defining your own module(this sample module will get the way to log on servers with root access):

    # tree
    |-- logs
    |   `-- 979945389_get_root_access.host01
    |-- password_file
    |-- result_get_root_access.txt

And here's the role of each file/dir: - commands that will be ran after SSH to the hosts
    password_file - credentials this module will use to try SSH
    logs/ - directory to place logs of the commands
    result_get_root_access.txt - outputs of the module itself - the main logic

And below is the content of which will invoke prun_doxer:

    echo "" > /doxer/projects/automation/get_root_access/result_get_root_access.txt
    logfile=`date +%N`
    /etc/prun_doxer/bootstrap_module.tcl $hostname /doxer/projects/automation/get_root_access/ /doxer/projects/automation/get_root_access/logs/${logfile}_get_root_access /doxer/projects/automation/get_root_access/password_file "/usr/bin/sudo su -" "(\->\040|#|#\040)$" "(\\\$|\\\$\040)$" "(\\\$|\\\$\040|\->\040|#|#\040)$" 600 "/usr/local/run_as_root 'su -'" "pbrun root" 5 >> /doxer/projects/automation/get_root_access/result_get_root_access.txt

    grep 'unpingable' /doxer/projects/automation/get_root_access/logs/${logfile}_get_root_access.$hostname | awk '{print $3" "$4}'
    grep 'We have a prompt directly' /doxer/projects/automation/get_root_access/logs/${logfile}_get_root_access.$hostname | awk -F- '{print $2}'
    grep 'with sudo option' /doxer/projects/automation/get_root_access/logs/${logfile}_get_root_access.$hostname