This commit is contained in:
Oleg Sheynin 2024-10-31 15:39:33 -04:00
parent 87e1a0610b
commit 1387893a14
2 changed files with 15 additions and 9 deletions

View File

@ -1 +1 @@
1.7.6,host avalability check 1.7.6.fx1,host avalability check

View File

@ -1,18 +1,21 @@
#!/bin/bash #!/bin/bash
usage() { # "cryptovaltrading.com": {
echo -n "Usage: ${0}" # "cloud18": {
echo # "users": ["oleg"],
exit 1 # "type": "cloud",
} # "ssh_port": 7822,
# # "to_check": "No"
# },
RootDir="${HOME}/prod" RootDir="${HOME}/prod"
RootDir="${HOME}/develop/cvtt2" # RootDir=/home/oleg/develop/cvtt2 ###### D E B U G
AlertChannel=Alerts-CVTT AlertChannel=Alerts-CVTT
Sender=${RootDir}/ops/utils/send_mmost.sh Sender=${RootDir}/ops/utils/send_mmost.sh
ConfigUrl=http://cloud23.cvtt.vpn:6789/admin/cvtt_hosts
HOSTS_CONFIG=$(curl -s http://cloud23.cvtt.vpn:6789/admin/cvtt_hosts | ${HOME}/bin/hjson -j) HOSTS_CONFIG=$(curl -s ${ConfigUrl} | ${HOME}/bin/hjson -j)
get_domains() { get_domains() {
echo ${HOSTS_CONFIG} | jq -r '. | keys[]' echo ${HOSTS_CONFIG} | jq -r '. | keys[]'
@ -40,7 +43,6 @@ function host_alert() {
} }
User=oleg User=oleg
Hosts=() Hosts=()
DEFAULT_SSH_PORT=22 DEFAULT_SSH_PORT=22
@ -56,6 +58,10 @@ for Host in ${Hosts[@]} ; do
# echo "Host=$Host host=$host Domain=$Domain" # echo "Host=$Host host=$host Domain=$Domain"
# Get SSH port for the host, or use default if not specified # Get SSH port for the host, or use default if not specified
ToCheck=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].to_check // "Yes"')
if [ "${ToCheck}" == "No" ]; then
continue
fi
PortSSH=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'') PortSSH=$(echo "$HOSTS_CONFIG" | jq -r --arg domain "$Domain" --arg host "$host" '.[$domain][$host].ssh_port // '"$DEFAULT_SSH_PORT"'')
echo "Checking host: $Host on port $PortSSH" echo "Checking host: $Host on port $PortSSH"