Commit 8b5d76ae authored by Michael Völske's avatar Michael Völske

split out util script for parallel idrac commands

parent cf8c2eb0
......@@ -4,7 +4,7 @@
# Copyright 2014-today www.webis.de
#
# Project WEBIS
# Author: Steve Göring
# Author: Michael Völske
#
scriptPath=${0%/*}
. "$scriptPath"/../../libs/bashhelper.sh
......@@ -30,14 +30,7 @@ main() {
read_password "Enter betamng password:" SSHPASS
export SSHPASS
seq -f "betamng%03.0f" 1 135 \
| xargs -n1 -P0 -I% bash -c ' \
echo -e % \\t $( \
sshpass -e ssh \
-o StrictHostkeyChecking=no -o UserKnownHostsFile=/dev/null \
webis@%.medien.uni-weimar.de \
racadm serveraction powerstatus 2>/dev/null ) ' \
| sort
#"$scriptPath/pssh.sh" "racadm serveraction powerstatus"
| webis util parallel-idrac --cmd 'racadm serveraction powerstatus'
}
#
......
#!/bin/bash
# Execute idrac command in parallel across multiple hosts
#
# Copyright 2014-today www.webis.de
#
# Project WEBIS
# Author: Michael Völske
#
scriptPath=${0%/*}
. "$scriptPath"/../../libs/bashhelper.sh
. "$scriptPath"/../../libs/shflags
check_tools "sshpass" "ssh" "xargs"
usage() {
echo "
Usage:
$(basename "$0")
Description:
Execute a given idrac command across multiple hosts and return the output, optionally processed through a filter.
A list of hostnames should be passed on stdin, one per line. The environment variable SSHPASS must be set to the iDrac password.
"
exit 0
}
DEFINE_string 'cmd' 'racadm serveraction powerstatus' 'iDrac command to execute' 'c'
DEFINE_string 'user' 'webis' 'iDrac username' 'u'
DEFINE_string 'filtercmd' 'cat' 'filter (command) to pass Idrac output from each individual host through' 'f'
DEFINE_string 'sortcmd' 'sort' 'Command to sort all output lines at the end' 's'
export FLAGS_HELP=$(usage)
FLAGS "$@" || exit 0
eval set -- "${FLAGS_ARGV}"
main() {
xargs -t -n1 -P0 -I% bash -c \
"echo -e % : \$( \
sshpass -e ssh \
-o StrictHostkeyChecking=no -o UserKnownHostsFile=/dev/null \
${FLAGS_user}@% \
${FLAGS_cmd} \
2>/dev/null \
| ${FLAGS_filtercmd} \
) " \
| ${FLAGS_sortcmd}
}
main "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment