sshpc_verify.sh
por EDSON - LAMBDA
—
última modificação
13/06/2023 11h33
sshpc_verify.sh — 2 KB
Conteúdo do arquivo
#!/bin/bash ######################################################################################### ## SSHPC - Cluster de processamento distribuído baseado em SSH ## ## ## ## Local: Laboratório Multiusuário de Bioinformática e Análise de Dados (LAMBDA) ## ## Centro de Biotecnologia (CBiotec), Universidade Federal da Paraíba (UFPB) ## ## Data: 30/05/2023 ## ## Coordenador: Edson Luiz Folador ## ## IC: Arthur Araújo de Lacerda ## ######################################################################################### readonly PROGNAME=$(basename "$0") readonly PROGDIR=$(readlink -m $(dirname "$0")) readonly SSHPC_DIRECTORY="/home/sshpc" # debugging flag debugging() { ${debug} && echo -e "$1"; } send_availability() { ### Gets information from connection attempt local invalid_attempt="${1}" while IFS=$'\t' read -r lab mac free_cores ip; do debugging "\nlab: $lab\nmac: $mac\navailable cores: $free_cores\nip: $ip\n" if $debug then "${SSHPC_DIRECTORY}"/.bin/sshpc_run.sh "${ip}" "${mac}" "${free_cores}" "${lab}" & else "${SSHPC_DIRECTORY}"/.bin/sshpc_run.sh -q "${ip}" "${mac}" "${free_cores}" "${lab}" & fi done <<< "${invalid_attempt}" } scan_for_availability() { # Select only the login attempts that are Invalid User attempts # sshpc.log is wherer attemps are stored local invalid_attempt local invalid_attempt=$(grep 'Invalid user sshpc' < "/home/sshpc/sshpc.log" | sed -E 's/ +|_/\t/g'| cut -f 9,10,11,13 | sort -k 3 | awk '!a[$4]++') echo "" > "${SSHPC_DIRECTORY}/sshpc.log" if [[ -z "${invalid_attempt}" ]]; then debugging "no sshpc calls" return 0 else send_availability "${invalid_attempt}" return 0 fi } main () { # Debug local debug=true while true; do case "$1" in -q | --quiet) debug=false; shift;; --) break;; *) break;; esac done debugging "=====================================\n||| Running ${PROGNAME} |||\n=====================================" scan_for_availability } main "$@"