Skip to content

Commit

Permalink
worked the help and completed testing, 2 programs work
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleyA committed Feb 27, 2018
1 parent d14768e commit d1cfbe6
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 58 deletions.
42 changes: 26 additions & 16 deletions scroll-phat/create-message.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# create-message.sh 2.5.35 2018-02-26_19:38:46_CST uadmin three-rpi3b.cptx86.com 2.4-1-gd14768e
# worked the help and completed testing, 2 programs work
# create-message.sh 2.4.33 2018-02-26_17:06:02_CST uadmin three-rpi3b.cptx86.com 2.3
# rewrote uptime todisplay-board.py
# display-board-1.sh 2.3.32 2018-02-26_15:14:25_CST uadmin three-rpi3b.cptx86.com 2.2-9-gfd85103
Expand All @@ -20,16 +22,25 @@
# set -v
###
display_help() {
echo -e "\n${0} - display display container status"
echo " UNDER DEVELOPMENT . . . . ."
echo -e "\nUSAGE\n ${0}"
echo -e "\n${0} - stores information about containers and images"
echo -e "\n >>> UNDER DEVELOPMENT . . . . ."
echo -e "\nUSAGE\n ${0} [<cluster>] [<administrator>] [<data_directory>] [<sshport>"
echo " ${0} [--help | -help | help | -h | h | -? | ?] [--version | -v]"
echo -e "\nDESCRIPTION\nThis script "
echo -e "\nDESCRIPTION\nThis script stores Docker information about containers and images in a file"
echo "on each system in a cluster. These files are copied to a host and totaled"
echo "in a file, /usr/local/data/cluster-1/MESSAGE. The MESSAGE file includes the"
echo "total number of conntainers, running containers, paused containers, stopped"
echo "containers, and number of images. The MESSAGE file is used to display the"
echo "information on a Raspberry Pi Scroll-pHAT display."
echo -e "\n >>> NEED to finish this... run script in a container every two minutes on a Raspberry Pi that includes Scroll-pHAT display."
echo -e "\nOPTIONS"
echo " arg1 XXXXXX"
echo -e "\nDOCUMENTATION\n https://github.com/BradleyA/display-board-2-project"
echo -e "\nEXAMPLES\n xxxxxxxx "
echo -e " xxxxxXXXXxxxxXXXX, x\n\tsudo ${0}\n"
echo " CLUSTER name of cluster directory, dafault cluster-1/"
echo " ADMUSER site SRE administrator, default is user running script"
echo " DATA_DIR path to cluster directory, dafault /usr/local/data/"
echo " SSHPORT SSH server port, default port 22"
echo -e "\nDOCUMENTATION\n https://github.com/BradleyA/pi-display-board"
echo -e "\nEXAMPLES"
echo -e " Store information for a different cluster\n\t${0} cluster-2\n"
}
if [ "$1" == "--help" ] || [ "$1" == "-help" ] || [ "$1" == "help" ] || [ "$1" == "-h" ] || [ "$1" == "h" ] || [ "$1" == "-?" ] || [ "$1" == "?" ] ; then
display_help
Expand All @@ -41,7 +52,7 @@ if [ "$1" == "--version" ] || [ "$1" == "-v" ] || [ "$1" == "version" ] ; then
fi
###
CLUSTER=${1:-cluster-1/}
USER=${2:-${USER}}
ADMUSER=${2:-${USER}}
DATA_DIR=${3:-/usr/local/data/}
SSHPORT=${4:-22}
CONTAINERS=0
Expand Down Expand Up @@ -83,8 +94,8 @@ for NODE in ${NODE_LIST} ; do
# Check if ${NODE} is available on port ${SSHPORT}
if $(nc -z ${NODE##*/} ${SSHPORT} >/dev/null) ; then
TEMP="docker system info | head -5 > ${NODE}"
ssh -q -t -i ~/.ssh/id_rsa -p ${SSHPORT} ${USER}@${NODE##*/} ${TEMP}
scp -q -i ~/.ssh/id_rsa -P ${SSHPORT} ${USER}@${NODE##*/}:${NODE} ${DATA_DIR}${CLUSTER}
ssh -q -t -i ~/.ssh/id_rsa -p ${SSHPORT} ${ADMUSER}@${NODE##*/} ${TEMP}
scp -q -i ~/.ssh/id_rsa -P ${SSHPORT} ${ADMUSER}@${NODE##*/}:${NODE} ${DATA_DIR}${CLUSTER}
else
echo -e "${NORMAL}${0} ${LINENO} [${BOLD}WARN${NORMAL}]: ${NODE##*/} not responding on port ${SSHPORT}.\n" 1>&2
fi
Expand All @@ -97,11 +108,10 @@ for NODE in ${NODE_LIST} ; do
STOPPED=`grep -i STOPPED ${NODE} | awk -v v=$STOPPED '{print $2 + v}'`
IMAGES=`grep -i IMAGES ${NODE} | awk -v v=$IMAGES '{print $2 + v}'`
done
# echo "${0} ${LINENO} -->${LOCALHOST}<--->${NODE##*/}<--->${SSHPORT}<--->${USER}<--"
# echo "${0} ${LINENO} -->${CONTAINERS}<--->${RUNNING}<--->${PAUSED}<---->${STOPPED}<---->${IMAGES}<----"
# echo "${0} ${LINENO} -->${LOCALHOST}<--n-->${NODE}<--dd-->${DATA_DIR}<--c-->${CLUSTER}<--P-->${SSHPORT}<--U-->${USER}<--"
# echo ${MESSAGE} > ${DATA_DIR}${CLUSTER}/MESSAGE
MESSAGE=" CONTAINERS ${CONTAINERS} RUNNING ${RUNNING} PAUSED ${PAUSED} STOPPED ${STOPPED} IMAGES ${IMAGES} "
echo ${MESSAGE} > ${DATA_DIR}${CLUSTER}/MESSAGE
./scroll-text-rotated.py "${MESSAGE}"
# echo "${0} ${LINENO} -->${LOCALHOST}<--->${NODE##*/}<--->${SSHPORT}<--->${ADMUSER}<--"
# echo "${0} ${LINENO} -->${CONTAINERS}<--->${RUNNING}<--->${PAUSED}<---->${STOPPED}<---->${IMAGES}<----"
# echo "${0} ${LINENO} -->${LOCALHOST}<--n-->${NODE}<--dd-->${DATA_DIR}<--c-->${CLUSTER}<--P-->${SSHPORT}<--U-->${ADMUSER}<--"
# echo ${MESSAGE} > ${DATA_DIR}${CLUSTER}/MESSAGE
###
44 changes: 2 additions & 42 deletions scroll-phat/docker-client-status.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,42 +1,2 @@
#!/bin/bash
# docker-client-status.sh 2.1.21 2018-02-25_12:07:56_CST uadmin three-rpi3b.cptx86.com 1.2-1-g87d879f
# change design to do all the work but don't know how to fork the process and the kill -9 the fork
#
# set -x
# set -v
###
display_help() {
echo -e "\n${0} - display display container status"
echo " UNDER DEVELOPMENT to add REMOTEHOST. Currently works for local host only."
echo -e "\nUSAGE\n ${0}"
echo " ${0} [--help | -help | help | -h | h | -? | ?] [--version | -v]"
echo -e "\nDESCRIPTION\nThis script "
echo -e "\nOPTIONS"
echo " arg1 XXXXXX"
echo -e "\nDOCUMENTATION\n https://github.com/BradleyA/display-board-2-project"
echo -e "\nEXAMPLES\n xxxxxxxx "
echo -e " xxxxxXXXXxxxxXXXX, x\n\tsudo ${0}\n"
}
if [ "$1" == "--help" ] || [ "$1" == "-help" ] || [ "$1" == "help" ] || [ "$1" == "-h" ] || [ "$1" == "h" ] || [ "$1" == "-?" ] || [ "$1" == "?" ] ; then
display_help
exit 0
fi
if [ "$1" == "--version" ] || [ "$1" == "-v" ] || [ "$1" == "version" ] ; then
head -2 ${0} | awk {'print$2"\t"$3'}
exit 0
fi
###
CLUSTER=${1:-docker-cluster-1}
DISPLAY_HOST=${2:-three-rpi3b}
DATA_DIR=${3:-/usr/local/data/}
HOSTNAME=`hostname`
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
# >>> write to file in ${DATA_DIR}${CLUSTER}/${HOSTNAME}
# mkdir -p ${DATA_DIR}${CLUSTER}
# docker system info | head -5 > ${DATA_DIR}${CLUSTER}/${HOSTNAME}
# Copy file to scroll-display
# echo "copy file"
# scp -i ~/.ssh/id_rsa ${DATA_DIR}${CLUSTER}/${HOSTNAME} uadmin@`hostname -f`:${DATA_DIR}${CLUSTER}
scp -i ~/.ssh/id_rsa [email protected]:${DATA_DIR}${CLUSTER}/one-rpi3b ${DATA_DIR}${CLUSTER}
###
# docker-client-status.sh 2.5.35 2018-02-26_19:38:46_CST uadmin three-rpi3b.cptx86.com 2.4-1-gd14768e
# worked the help and completed testing, 2 programs work
42 changes: 42 additions & 0 deletions scroll-phat/docker-client-status.sh.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# docker-client-status.sh 2.1.21 2018-02-25_12:07:56_CST uadmin three-rpi3b.cptx86.com 1.2-1-g87d879f
# change design to do all the work but don't know how to fork the process and the kill -9 the fork
#
# set -x
# set -v
###
display_help() {
echo -e "\n${0} - display display container status"
echo " UNDER DEVELOPMENT to add REMOTEHOST. Currently works for local host only."
echo -e "\nUSAGE\n ${0}"
echo " ${0} [--help | -help | help | -h | h | -? | ?] [--version | -v]"
echo -e "\nDESCRIPTION\nThis script "
echo -e "\nOPTIONS"
echo " arg1 XXXXXX"
echo -e "\nDOCUMENTATION\n https://github.com/BradleyA/display-board-2-project"
echo -e "\nEXAMPLES\n xxxxxxxx "
echo -e " xxxxxXXXXxxxxXXXX, x\n\tsudo ${0}\n"
}
if [ "$1" == "--help" ] || [ "$1" == "-help" ] || [ "$1" == "help" ] || [ "$1" == "-h" ] || [ "$1" == "h" ] || [ "$1" == "-?" ] || [ "$1" == "?" ] ; then
display_help
exit 0
fi
if [ "$1" == "--version" ] || [ "$1" == "-v" ] || [ "$1" == "version" ] ; then
head -2 ${0} | awk {'print$2"\t"$3'}
exit 0
fi
###
CLUSTER=${1:-docker-cluster-1}
DISPLAY_HOST=${2:-three-rpi3b}
DATA_DIR=${3:-/usr/local/data/}
HOSTNAME=`hostname`
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
# >>> write to file in ${DATA_DIR}${CLUSTER}/${HOSTNAME}
# mkdir -p ${DATA_DIR}${CLUSTER}
# docker system info | head -5 > ${DATA_DIR}${CLUSTER}/${HOSTNAME}
# Copy file to scroll-display
# echo "copy file"
# scp -i ~/.ssh/id_rsa ${DATA_DIR}${CLUSTER}/${HOSTNAME} uadmin@`hostname -f`:${DATA_DIR}${CLUSTER}
scp -i ~/.ssh/id_rsa [email protected]:${DATA_DIR}${CLUSTER}/one-rpi3b ${DATA_DIR}${CLUSTER}
###

0 comments on commit d1cfbe6

Please sign in to comment.