You are here: Foswiki>SAWeb Web>NetRun (18 Jul 2012, CoreyOsman)Edit Attach

Netrun

DESCRIPTION

Netrun provides a convenient and efficient way to run a single command or a script on a bunch of remote

hosts. Netrun captures the output and error messages from the command or script for reporting and examination.

Netrun is powered by ssh and assumes that you have a setup like the following:

• You have created an SSH public/private key pair using ssh−keygen.

• You have copied your public key(s) to $HOME/.ssh/authorized_keys on all of the remote

hosts on which you plan to run commands or scripts with netrun. If you plan to access remote hosts

with different accounts, you’ll need to make sure that your public key(s) have been added to each

account’s authorized_keys file. Be sure to check your local computer security policy and to get permission

from the affected users before doing this!

• You have started an ssh−agent and loaded your private keys with ssh−add. Note that you can

avoid having to run ssh−agent by creating private keys with no passphrase. Please do not do this!

At many sites, this is grounds for disciplinary action (especially if the corresponding public keys are

added to root’s authorized_keys files).

Installation

  1. wget http://backpan.perl.org/authors/id/D/DC/DCS/scripts/netrun-1.20.tar.gz
  2. tar -zxvf netrun-1.20.tar.gz
  3. cp netrun-1.20/bin/netrun /bin/
  4. cp netrun-1.20/man/man1/netrun.1 /usr/share/man/man1/
  5. Install forkmanager
  6. sudo perl -MCPAN -e 'install Parallel::ForkManager'

Example Usage

username@system1:~$ netrun

Usage: /bin/netrun [-hqRS] [-c connect timeout] [-f max forks] [-i interpreter] [-s script file] | [-e script] [-d data file] [-l login name] [-L log dir] [-t timeout] hosts ...

Example usage with the foremancli hostslist

ssh-agent bash

bash-3.2$ netrun -l username -e "uname" -i bash `hostlistbrandorr.sh`

Progress: 0% |-----------+-----------+-----------+-----------| 100%

################################################# Done.

$ netrun -e 'uname' -l 'user1' -c '15' -i 'bash' build64.brandorr.com ...

Name/Address Exit Runtime # Lines First Line of Output

---------------------------------------------------------------------------

xen1.brandorr.com interpreter failure: connect: timeout

xen2.brandorr.com interpreter failure: Could not resolve xen2.brandorr.com to an address

cfrouter2.dev.bran interpreter failure: connect: timeout

cfrouter.dev.brand interpreter failure: connect: timeout

gbproxy.brandorr.c 0 1.126 1 Linux

pm1.brandorr.com 0 1.378 1 Linux

metro.brandorr.com 0 1.751 1 Linux

build64.brandorr.c 0 1.813 1 Linux

www1.brandorr.com 0 1.820 1 Linux

gbftp.brandorr.com 0 1.825 1 Linux

perception.brandor 0 1.825 1 Linux

centos.brandorr.co 0 1.853 1 Linux

relay1.brandorr.co 0 1.860 1 Linux

redmine.brandorr.c 0 2.000 1 Linux

dev1.brandorr.com 0 2.028 1 Linux

foswiki.brandorr.c 0 2.164 1 Linux

rt.brandorr.com 0 2.169 1 Linux

mon.brandorr.com 0 2.185 1 Linux

dhclient-test.bran 255 1.370 0

scratch3.brandorr. 255 1.382 0

log1.brandorr.com 255 1.508 0

---------------------------------------------------------------------------

Results can be found in ./netrun.12465

-- CoreyOsman - 18 Jul 2012

Topic revision: r1 - 18 Jul 2012, CoreyOsman
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback