Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
SERVER=XXXXX
if [ ! -d stress_test_results ]
then
echo You need to create a directory called stress_test_results
exit 1
fi
mkdir stress_test_results/ws
#!/bin/bash
#
# Reboot crashed hosts. A host is rebooted if:
# 1) baseList.pl shows ssh (later, host) and sshalt alert as down for the host
# 2) the switch for the site is up
# 3) the host isn't a straggler from the last run
# 4) The host hasn't been rebooted in the last 24 hours
# 5) There are no more than 5 hosts in the current reboot queue
# Any machines that came back from the previous run are recorded.
#
has_it_been_24_hrs() {
echo "#### Starting has_it_been_24_hrs ####"
echo "Contents of REBOOT_CANDIDATES (/tmp/rebot-testing/ssh_outage/reboot_candidates:"
cat ${REBOOT_CANDIDATES}
echo "Contents of REBOOT_LOG (/tmp/rebot-testing/reboot_history/reboot_log:"
cat ${REBOOT_LOG}
#echo "# Starting timestamp comparison #"
echo ""
rm -f "${REBOOT_CANDIDATES}.tmp" && touch "${REBOOT_CANDIDATES}.tmp"
has_it_been_24_hrs() {
echo "#### Starting has_it_been_24_hrs ####"
echo "Contents of REBOOT_CANDIDATES (/tmp/rebot-testing/ssh_outage/reboot_candidates:"
cat ${REBOOT_CANDIDATES}
echo "Contents of REBOOT_LOG (/tmp/rebot-testing/reboot_history/reboot_log:"
cat ${REBOOT_LOG}
#echo "# Starting timestamp comparison #"
echo ""
rm -f "${REBOOT_CANDIDATES}.tmp" && touch "${REBOOT_CANDIDATES}.tmp"
did_they_come_back() {
echo "#### Starting did_they_come_back() ####"
#TODO: Make this take out bad entries from $REBOOT_CANDIDATES
for line in `cat "${REBOOT_ATTEMPTED}"`; do
attempted_host=`echo $line | awk -F: '{ print $1 }'`
if grep -q "${attempted_host}" "${REBOOT_CANDIDATES}" ; then
echo "${attempted_host} still not up but requested during last run:" \
$line |tee -a ${PROBLEMATIC} "${NOTIFICATION_EMAIL}" > /dev/null
else
did_they_come_back() {
echo "#### Starting did_they_come_back() ####"
#TODO: Make this take out bad entries from $REBOOT_CANDIDATES
for line in `cat "${REBOOT_ATTEMPTED}"`; do
attempted_host=`echo $line | awk -F: '{ print $1 }'`
if grep -q "${attempted_host}" "${REBOOT_CANDIDATES}" ; then
echo "${attempted_host} still not up but requested during last run:" \
$line |tee -a ${PROBLEMATIC} "${NOTIFICATION_EMAIL}" > /dev/null
else
FROM ubuntu
ADD myscript.sh /myscript.sh
RUN chmod +x myscript.sh
CMD /myscript.sh
#!/bin/bash
echo 'This worked!'
@pboothe
pboothe / fake.sh
Created June 6, 2018 17:34
A command that spies on a binary by being run in its place, calling the original and forking all input and output to logfiles as well as the called subprocess
#!/bin/bash
OUTPUT=$(mktemp -d --tmpdir=/tmp "$(date -Iseconds).$(basename $0).XXXXXXX")
echo "$@" > "${OUTPUT}/cmdline"
env > "${OUTPUT}/env"
cat - \
| tee "${OUTPUT}/input" \
| /usr/cni/bin/$(basename $0) $@ \
| tee "${OUTPUT}/output"
cd "${OUTPUT}"
NewConnector() (Connector) {
return &sshConnector{...}
}
type sshConnector struct {
dialer dialer
}
func (s *sshConnector) NewConnection(...) {
s.dialer.Dial()