-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhhwchk
executable file
·540 lines (482 loc) · 18.2 KB
/
hhwchk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
#!/bin/bash
# hhwchk v2.3.2 last mod 2012/08/26
# Latest version at <http://github.com/ryran/hhwchk>
# Copyright 2010, 2011, 2012 Ryan Sawhill <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License <gnu.org/licenses/gpl.html> for more details.
#-------------------------------------------------------------------------------
# Hops into systems via ssh to check out what they have in the way of hardware.
#
# When I started this script with the name host-hwcheck, I began with a simple
# purpose: I wanted to be able to quickly gather information about a handful of
# systems that I had been handed root access to -- specifically in a classroom
# environment where it was important that the students' systems be relatively
# uniform. Since my first days with linux I've been pretty handy with bash and
# so it never was much work to use for-loops along with ssh, but you know what
# they say about things that you have to do more than once, let alone every
# single week...
#
# So the initial goal was to display info on number of processors and their
# capabilities, plus amount of ram and disk space and I wanted to be able to
# do this on remote systems without requiring the script to reside on those
# systems as well.
# Right from the start I also wanted to be able to use number generation ('seq'
# or '{n..n}') for hostnames, along with some other configurable prefix like
# 'station' -- I don't know of a quick and elegant way to do this with bash
# trickery, so that was also part of it.
#
# Over the course of a month and a half, it evolved and vastly improved, with a
# small sacrifice in efficiency. This also prompted my first bit of self-study
# into awk, which I had only ever used for simply pulling out a column in text.
# I'm definitely still learning on that front -- you'll see me resort to piping
# almost-baked awk-output into sed or other commands because I haven't figured
# out all the wonders of this new and complicated (*ahem* .. to me) language.
# Hopefully this will continue to evolve in efficiency as my knowledge expands,
# but to move that process along quicker, send any ideas for ways to improve
# things to me at <[email protected]>. I've been meaning to get into python as well
# actually, so if you're looking at this mess and thinking "WOW this would be so
# much better in XYZ LANGUAGE", hit me up and let me know.
#
# Notes:
# This script doesn't use absolute paths for cmd names; however there is some
# error-checking to account for the following commands being missing:
# dmidecode, ethtool, multipath
# There is no error-checking for anything else, so standard coreutils and the
# util-linux-ng commands must be available via $PATH, plus the following:
# gawk, sed, lspci
#-------------------------------------------------------------------------------
# I like color; please, sue me
reset='\E[0;0m'; grey='\E[00;30m'; GREY='\E[01;30m'; red='\E[0;31m'; RED='\E[1;31m';
green='\E[0;32m'; GREEN='\E[1;32m'; orange='\E[0;33m'; ORANGE='\E[1;33m'; blue='\E[0;34m';
BLUE='\E[1;34m'; purple='\E[0;35m'; PURPLE='\E[1;35m'; cyan='\E[0;36m'; CYAN='\E[1;36m'
c_sep=$cyan ; c_h=$green ; c_text=$orange
# Get version from line #2
version=$(sed '2q;d' $0)
# GNU getopt short and long options:
sopts='P:S:Lxbcdeghmnrv'
lopts='prefix:,suffix:,localhost,nocolor,bios,cpu,disks,ethtool,graphics,hostname,multipath,net,ram,verbose'
USAGE() {
echo "Usage: hhwchk [-xbcdeghmnr|-Nv] SSH_HOST...|--localhost"
echo " or: hhwchk -?|--help"
}
XHELP() {
USAGE
echo "Use proc & standard tools to report hw info on localhost or ssh hosts
Host-selection options:"
echo "
-P, --prefix=PREFIX@where PREFIX is text to be prepended to SSH_HOST
-S, --suffix=SUFFIX@where SUFFIX is text to be appended to SSH_HOST
-L, --localhost@operate on localhost instead of SSH_HOST via ssh" |
column -s@ -t
echo "
Display options:"
echo "
-x, --nocolor@disable coloring of output
-b, --bios@use dmidecode to query the bios for extra info
-c, --cpu@show info on detected cpus
-d, --disks@show info on block devices
-e, --ethtool@show net interface details, via ethtool
-g, --graphics@show info on vga adapters, via lspci
-h, --hostname@show uname and (with -b) system info
-m, --multipath@show info on multipath storage devices
-n, --net@list detected wifi/ethernet devices, via lspci
-r, --ram@show info on system ram
-v, --verbose@show as much information as possible" |
column -s@ -t
echo "
Examples:
hhwchk --localhost
hhwchk -Lv
hhwchk --cpu dev.b19.org prod.b19.org web.b19.org
hhwchk -c dev prod web --suffix=.b19.org
hhwchk --ram --bios station5 station6 station7
hhwchk -rb --prefix station 5 6 7
hhwchk -P root@station -S .example.com -v 5 6 7
Version info: ${version:2}
Report bugs or suggestions to <[email protected]>
Or see <github.com/ryran/hhwchk> for bug tracker & latest version
Alternatively, run hhwchk with '--update'"
exit
}
UPDATE() {
echo -e "${blue}Checking $0 against latest version at github.com/ryran/hhwchk ...${GREY}\n"
latest_version_file=$(mktemp /tmp/hhwchk_latest.XXX)
trap "rm $latest_version_file" EXIT
# download latest version of hhwchk with wget or curl
if command -v wget >/dev/null; then
wget https://raw.github.com/ryran/hhwchk/master/hhwchk -O $latest_version_file
elif command -v curl >/dev/null; then
curl https://raw.github.com/ryran/hhwchk/master/hhwchk -o $latest_version_file; echo
else
echo -e "${RED}Need either wget or curl in \$PATH to perform the download!${reset}"
exit 255
fi
# save version string
latest_version=$(sed '2q;d' $latest_version_file)
# compare currently running hhwchk with downloaded file
if ! diff $0 $latest_version_file >/dev/null; then
echo -e "${blue}The version you are running reports as:\n\t${orange}${version:2}${blue}\nThe version on github appears to be different and reports as:\n\t${ORANGE}${latest_version:2}${blue}"
echo -e "Press ${GREEN}enter${blue} to see the differences between them${reset}"
read
# set name of tmp diff file
diff_file=$(mktemp /tmp/hhwchk.XXX.patch); trap "rm $diff_file" EXIT;
# create a diff file
diff -u $0 $latest_version_file > $diff_file
# if it's installed, vim gives pretty colors
command -v vim >/dev/null && vim $diff_file || less $diff_file
echo -e "${blue}If you are sure you know what you are doing, type ${GREEN}update${blue}\nto replace $0 with the latest version${GREEN}"
read -p "> "
if [[ $REPLY = update ]]; then
echo -e "${blue}Backing up current version and replacing it with downloaded version ...${cyan}"
cp -v $0 /tmp/hhwchk.orig
cp -v $latest_version_file $0
chmod +x $0
echo -e "${reset}"
else
echo -e "${cyan}Not performing update${reset}\n"
fi
else
echo -e "${blue}$0 is the same version as what is on github, i.e.,\n\t${BLUE}${version:2}${reset}\n"
fi
exit
}
# check for help query
[ $# -eq 0 ] && { USAGE; echo "{${version:2}}"; exit; }
case $1 in
--help|-\?) XHELP
;;
--update) UPDATE
;;
esac
# check for bad switches
getopt -Q --name=hhwchk -o $sopts -l $lopts -- $* || { USAGE; exit 1; }
#-------------------------------------------------------------------------------
# parse command-line arguments
PARSE() {
opts=n
unset pre suf localhost nocolor bios cpu disks ethtool graphics hostname multipath net ram verbose
until [[ $1 = -- ]]; do
case $1 in
-P|--prefix) pre=$2; shift 2
;;
-S|--suffix) suf=$2; shift 2
;;
-L|--localhost) localhost=y; shift
;;
-x|--nocolor) nocolor=y; shift
;;
-b|--bios) bios=y; shift
opts=y
;;
-c|--cpu) cpu=y; shift
opts=y
;;
-d|--disks) disks=y; shift
opts=y
;;
-e|--ethtool) ethtool=y; shift
opts=y
;;
-g|--graphics) graphics=y; shift
opts=y
;;
-h|--hostname) hostname=y; shift
opts=y
;;
-m|--multipath) multipath=y; shift
opts=y
;;
-n|--net) net=y; shift
opts=y
;;
-r|--ram) ram=y; shift
opts=y
;;
-v|--verbose) verbose=y; shift
opts=y
;;
esac
done
shift #(to get rid of the '--')
# check for missing HOST
if [[ $# -eq 0 && $localhost != y ]]; then
echo -e "hhwchk: which hosts to check? (use '-L' for localhost)\n"
USAGE
exit 5
else
hosts=$*
fi
}
PARSE $(getopt -u --name=hhwchk -o $sopts -l $lopts -- $*)
#-------------------------------------------------------------------------------
# time to set up which commands to run
cmdscript=$(mktemp /dev/shm/hhwchk.XXX)
trap "rm $cmdscript" EXIT
[[ $bios = y || $verbose = y ]] &&
cat >> $cmdscript <<\EOF
if [[ $UID -eq 0 ]] && command -v dmidecode >/dev/null && ! dmidecode -t memory|grep -q "table is broken"; then
dmi=yes
BIOS_sysinfo="$(dmidecode -s system-manufacturer) $(dmidecode -s system-product-name)"
BIOS_model_cpu="<bios: $(dmidecode -s processor-manufacturer|sort -u) \
$(dmidecode -s processor-family|sort -u) @ $(dmidecode -s processor-frequency|sort -u)>"
BIOS_cpu_count_info=$(dmidecode -t4 |
awk '
/Status:/ {
numsocks++; if ($2 ~ /Populated/) popsocks++
}
/Core Count:/ {
corespercpu=$3; totalnumcores+=$3
}
END {
printf "<bios: %d of %d sockets populated, with %d cores/cpu, %d total cores>\n",
popsocks, numsocks, corespercpu, totalnumcores
}'
)
BIOS_ram=$(dmidecode -t memory|
awk '
/Size:/ {
numdimmslots++
if ($2 ~ /^[0-9]/) {
popdimms++; sumram+=$2
}
}
/Maximum Capacity:/ {
maxram = $3" "$4
}
END {
printf "<bios: %d MB total, %d of %d DIMMs populated (%s max capacity)>\n",
sumram, popdimms, numdimmslots, maxram
}'
)
else
unset dmi
fi
EOF
[[ $hostname = y || $verbose = y ]] &&
cat >> $cmdscript <<\EOF
echo -e "HOST: $(uname -nr)"
[[ -n $dmi ]] && echo -e " ${BIOS_sysinfo}"
EOF
# What will hopefully (eventually) be a much more efficient version of the cpu code
cat >/dev/null <<\EOF
[[ $cpu = y || $verbose = y ]] &&
#cat >> $cmdscript <<\EOF
cpu1=$(
awk -F: '
/model name/ {
sub("(R)", ""); sub("(TM)", "")
numcpus++
}
/physical id/ {
physcpu[$2]++
}
/pae|lm|vmx|svm|ht/ {
END {
printf "CPU: %d logical cpus (%s)\n", numcpus, flags
printf "
}'
)
EOF
#ORIGINAL CPU VERSION
[[ $cpu = y || $verbose = y ]] &&
cat >> $cmdscript <<\EOF
model_cpu=$(awk -F: '/model name/{print$2}' /proc/cpuinfo | sort -u | sed -e "s/(R)//g" -e "s/(TM)//g" -e "s/ */ /g")
num_cpu=$(grep processor /proc/cpuinfo | sort -u | wc -l)
num_cpu_phys=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)
[[ $num_cpu_phys -eq 0 ]] && num_cpu_phys=$num_cpu
if [[ $num_cpu_phys -ne $num_cpu ]]; then
num_cores_per_cpu=$(grep cores /proc/cpuinfo|head -n1|awk {print\$4})
[[ -n $num_cores_per_cpu ]] && cores=", ${num_cores_per_cpu} cores/ea"
fi
cpu_flags=$(egrep -o "pae|lm|vmx|svm|ht" /proc/cpuinfo|sort -u|sed ':a;N;$!ba;s/\n/,/g')
echo -e "CPU: ${num_cpu} logical cpus (${cpu_flags})"
echo -e " ${num_cpu_phys}${model_cpu}${cores}"
[[ -n $dmi ]] && echo -e " ${BIOS_model_cpu}"
[[ -n $dmi ]] && echo -e " ${BIOS_cpu_count_info}"
EOF
[[ $ram = y || $verbose = y ]] &&
cat >> $cmdscript <<\EOF
sum_ram=$(free -m | awk '/^Mem:/ {printf "%s MB (%.1f GB)\n", $2, $2/1024}')
echo -e "RAM: ${sum_ram}"
[[ -n $dmi ]] && echo -e " ${BIOS_ram}"
EOF
[[ $multipath = y ]] &&
cat >> $cmdscript <<\EOF
if command -v multipath >/dev/null && [[ $UID -eq 0 ]]; then
mpath=$(multipath -v4 -ll 2>/dev/null)
if ! echo "$mpath" | egrep -q 'no.paths|multipath.conf.*not.exist'; then
mpath_devs=$(echo "$mpath" | grep -B1 '^\[size=' |
awk '
BEGIN{ RS = "--" }
{ printf " %s@%s\n", $1, gensub(/.*\[size=([0-9]+\.?[0-9]*) ?([[:alpha:]]{1,2})\].*/, "\\1 \\2", 1)
}' | sort | column -ts@
)
scsi_blacklist=$(echo "$mpath" | awk '/\\_ .* sd[[:alpha:]]+ / {printf "%s|", $3}')
echo -e "MPATH:\n${mpath_devs}"
fi
fi
EOF
[[ $disks = y || $verbose = y ]] &&
cat >> $cmdscript <<\EOF
scsi_blacklist="$scsi_blacklist"$(
awk '
/^md./ {
printf gensub(/.* ([[:alpha:]]+)[0-9]*\[[0-9]+\] .*/, "\\1|", "g")
}' /proc/mdstat
)
[[ -n $scsi_blacklist ]] && bl=y || { bl=n; scsi_blacklist=NULL; }
hdds=$(
egrep -v "${scsi_blacklist%?}" /proc/partitions |
awk -v blacklisted=$bl '
$4 ~ /^hd.$|^sd[[:alpha:]]{1,2}$|^md.$|^r+om.$|^r?flash.$|^rd\/c.{1,2}d.{1,2}$|^ida\/c.d.$|^i2o\/hd[[:alpha:]]+$|^amiraid\/ar.{1,2}$|cbd\/.$|^cciss\/c.d.{1,2}$|^iseries\/vd[[:alpha:]]{1,2}$|^ataraid\/d.{1,2}$|^emd\/.{1,2}$|^carmel\/.{1,2}$|^mmcblk.$|^ub.$|^xvd.$|^vd.$/ {
numdisks ++
disksize = $3/1024/1024
sum_gb += disksize
disk[$4] = disksize
}
END {
printf "%d, totaling %.0f GiB (%.2f TiB)\n", numdisks, sum_gb, sum_gb/1024
if (blacklisted == "y") {
print " [Multipath and/or software raid components hidden]"
}
n = asorti(disk, disk_sorted)
for (i = 1; i <= n; i++) {
printf " %s %.1f G\n", disk_sorted[i], disk[disk_sorted[i]]
}
}'
)
echo -e "DISKS: ${hdds}"
EOF
[[ $net = y || $verbose = y ]] &&
cat >> $cmdscript <<\EOF
lspci_netdevs=$(lspci |
awk '
!/Ethernet controller:|Network controller:/ {
next
}
{
split($1, slot, ":");
$1 = "";
sub(" ", ""); split($0, type, ":");
iface[type[2]]++;
if (!(slot[1] SUBSEP type[2] in slots)) {
slots[slot[1], type[2]];
slotcount[type[2]]++
}
}
END {
for (ifacetype in iface) {
slotc = slotcount[ifacetype];
typec = iface[ifacetype]
ports = "";
if (typec > 1) {
ports = " {" slotc " x " typec/slotc "-port}"
};
printf " %s%s%s\n", typec, ifacetype, ports
}
}'
)
echo -e "NETDEVS:\n${lspci_netdevs}"
EOF
[[ $ethtool = y || $verbose = y ]] &&
cat >> $cmdscript <<\EOF
if command -v ethtool >/dev/null && [[ $UID -eq 0 ]]; then
#ethdevs=$(ip link | awk -F: '/ peth| eth| em| wlan| usb/{print$2}')
ethdevs=$(ls /sys/class/net | egrep -v 'lo|sit0')
ethtool_linkinfo=$(
for i in $ethdevs; do echo -e "\
$i~$(ethtool $i |
awk '
/Link detected:/ { link = $3; sub(/yes/, "UP", link); sub(/no/, "DOWN", link) }
/Speed:/ { spd = $2 }
/Duplex:/ { dup = tolower($2) }
/Auto-negotiation:/ { aneg = $2; sub(/on/, "Y", aneg); sub(/off/, "N", aneg) }
END {
if (link == "UP" && spd != "")
linkdetails = " "spd" "dup" (autoneg="aneg")"
printf "link=%s%s~", link, linkdetails
}'
)$(ethtool -i $i |
awk '
BEGIN {
driver="UNKNOWN"; drv_vers=""; fw_vers=""
}
/^driver:/ { if ($2 != "") driver=$2 }
/^version:/ { if ($2 != "") drv_vers=" v"$2 }
/^firmware-version:/ { if ($2 != "") fw_vers=" / fw "$2 }
END {
printf "drv %s%s%s\n", driver, drv_vers, fw_vers
}'
)"
done | column -ts~)
echo -e "ETHTOOL:\n${ethtool_linkinfo}"
fi
EOF
[[ $graphics = y || $verbose = y ]] &&
cat >> $cmdscript <<\EOF
lspci_vga=$(lspci | awk -F: '/VGA/{print " "$3}')
echo -e "VGA:\n${lspci_vga}"
EOF
[[ $multipath = y || $ethtool = y || $bios = y || $verbose = y ]] &&
cat >> $cmdscript <<\EOF
[[ $UID -ne 0 ]] && echo -e "\E[00;1m\E[41m[ Note: Some of requested information requires root-access ]\E[0m"
EOF
# what to do if no other display options are used
[[ $opts = n ]] &&
cat > $cmdscript <<\EOF
if [[ $UID -eq 0 ]] && command -v dmidecode >/dev/null && ! dmidecode -t memory|grep -q "table is broken"; then
BIOS_ram=$(dmidecode -t memory|awk '/Size: [0-9]/{sumram+=$2} END {printf "<bios: %s MB>", sumram}')
BIOS_sysinfo="$(dmidecode -s system-manufacturer) $(dmidecode -s system-product-name)"
fi
model_cpu=$(awk -F: '/model name/{print$2}' /proc/cpuinfo | sort -u | sed -e "s/(R)//g" -e "s/(TM)//g" -e "s/ */ /g")
num_cpu=$(grep processor /proc/cpuinfo | sort -u | wc -l)
num_cpu_phys=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)
[[ $num_cpu_phys -eq 0 ]] && num_cpu_phys=$num_cpu
if [[ $num_cpu_phys -ne $num_cpu ]]; then
num_cores_per_cpu=$(grep cores /proc/cpuinfo|head -n1|awk {print\$4})
[[ -n $num_cores_per_cpu ]] && cores=", ${num_cores_per_cpu} cores/ea"
fi
cpu_flags=$(egrep -o 'pae|lm|vmx|svm|ht' /proc/cpuinfo|sort -u|sed ':a;N;$!ba;s/\n/,/g')
sum_ram=$(free -m | awk '/^Mem:/ {printf "%s MB (%.1f GB)\n", $2, $2/1024}')
hdds=$(
awk '
$4 ~ /^hd.$|^sd[[:alpha:]]{1,2}$|^md.$|^r+om.$|^r?flash.$|^rd\/c.{1,2}d.{1,2}$|^ida\/c.d.$|^i2o\/hd[[:alpha:]]+$|^amiraid\/ar.{1,2}$|cbd\/.$|^cciss\/c.d.{1,2}$|^iseries\/vd[[:alpha:]]{1,2}$|^ataraid\/d.{1,2}$|^emd\/.{1,2}$|^carmel\/.{1,2}$|^mmcblk.$|^ub.$|^xvd.$|^vd.$/ {
numdisks ++ ; sum_kbytes += $3
}
END {
gb = sum_kbytes/1024/1024
printf "%d, totaling %.0f GiB (%.2f TiB)\n", numdisks, gb, gb/1024
}' /proc/partitions
)
[[ -n $BIOS_sysinfo ]] && echo "${BIOS_sysinfo}"
echo "${num_cpu_phys}${model_cpu}${cores}
(${num_cpu} logical cpus; flags:${cpu_flags})
RAM: ${sum_ram} ${BIOS_ram}
DISKS: ${hdds}"
EOF
#-------------------------------------------------------------------------------
# finally, we run our script either on localhost or remotely over ssh
if [[ $nocolor = y ]]; then
unset c_sep c_h c_text black
elif [[ $localhost = y && $opts != n ]]; then
sed -i -e 's/HOST: /\\E[01;31m&\\E[00;31m/' -e 's/CPU: /\\E[01;33m&\\E[00;33m/' -e 's/RAM: /\\E[01;34m&\\E[00;34m/' -e 's/MPATH:/\\E[01;36m&\\E[00;36m/' -e 's/DISKS: /\\E[01;36m&\\E[00;36m/' -e 's/NETDEVS:/\\E[01;32m&\\E[00;32m/' -e 's/ETHTOOL:/\\E[01;32m&\\E[00;32m/' -e 's/VGA:/\\E[01;35m&\\E[00;35m/' $cmdscript
#cat $cmdscript
fi
if [[ $localhost = y ]]; then
bash $cmdscript
else
echo -e "${c_sep} operating on: ${c_h}$pre{`echo $hosts|sed 's/ /,/g'`}$suf"
for HOST in $hosts; do
echo -e "${c_sep}------------------------------------------------{${c_h}$pre$HOST$suf${c_text}"
ssh ${pre}${HOST}${suf} "$(cat $cmdscript)"
done
fi
echo -en "$reset"