CheckScript: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
(Creata pagina con " #!/bin/bash ## Versione 1.0 - Christian Gozzi - Partech ## Script per esecuzione ricorsiva su vari host di una serie di comandi. LOG_FILE=logfile.txt LOG_OK=logmachineok.txt LOG_NONOK=logmachinenook.txt LOG_AGENTHOST=listavmpulire.txt LOG_PULIZIE=logpulizie.txt LOG_CHECK=check.txt rm -f ${LOG_NONOK} rm -f ${LOG_FILE} rm -f ${LOG_OK} rm -f ${LOG_AGENTHOST} rm -f ${LOG_PULIZIE} fileItemString=$(cat lista.txt |tr "\n" " ") fileItemArray=($fileItemString)...") |
Nessun oggetto della modifica |
||
Riga 8: | Riga 8: | ||
LOG_PULIZIE=logpulizie.txt | LOG_PULIZIE=logpulizie.txt | ||
LOG_CHECK=check.txt | LOG_CHECK=check.txt | ||
rm -f ${LOG_NONOK} | rm -f ${LOG_NONOK} | ||
rm -f ${LOG_FILE} | rm -f ${LOG_FILE} | ||
Riga 14: | Riga 13: | ||
rm -f ${LOG_AGENTHOST} | rm -f ${LOG_AGENTHOST} | ||
rm -f ${LOG_PULIZIE} | rm -f ${LOG_PULIZIE} | ||
fileItemString=$(cat lista.txt |tr "\n" " ") | fileItemString=$(cat lista.txt |tr "\n" " ") | ||
fileItemArray=($fileItemString) | fileItemArray=($fileItemString) | ||
# Iterate the string array using for loop | # Iterate the string array using for loop | ||
for val in ${fileItemArray[@]}; do | for val in ${fileItemArray[@]}; do | ||
echo $val | echo $val | ||
( ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$val cat /etc/fstab | grep "cifs\|nfs") & pid=$! | ( ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$val cat /etc/fstab | grep "cifs\|nfs") & pid=$! | ||
( sleep 5 && kill -HUP $pid ) 2>/dev/null & watcher=$! | ( sleep 5 && kill -HUP $pid ) 2>/dev/null & watcher=$! | ||
Riga 36: | Riga 31: | ||
echo "SSH error su: $val" | echo "SSH error su: $val" | ||
echo $val>> ${LOG_NONOK} | echo $val>> ${LOG_NONOK} | ||
fi | fi | ||
done | done |
Versione attuale delle 14:11, 26 apr 2024
#!/bin/bash ## Versione 1.0 - Christian Gozzi - Partech ## Script per esecuzione ricorsiva su vari host di una serie di comandi. LOG_FILE=logfile.txt LOG_OK=logmachineok.txt LOG_NONOK=logmachinenook.txt LOG_AGENTHOST=listavmpulire.txt LOG_PULIZIE=logpulizie.txt LOG_CHECK=check.txt rm -f ${LOG_NONOK} rm -f ${LOG_FILE} rm -f ${LOG_OK} rm -f ${LOG_AGENTHOST} rm -f ${LOG_PULIZIE} fileItemString=$(cat lista.txt |tr "\n" " ") fileItemArray=($fileItemString) # Iterate the string array using for loop for val in ${fileItemArray[@]}; do echo $val ( ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$val cat /etc/fstab | grep "cifs\|nfs") & pid=$! ( sleep 5 && kill -HUP $pid ) 2>/dev/null & watcher=$! if wait $pid 2>/dev/null; then echo "SSH ok su: $val" echo $val>> check.txt echo "---" >> check.txt ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$val cat /etc/fstab | grep "cifs\|nfs" >> check.txt echo "---" >> check.txt pkill -HUP -P $watcher wait $watcher else echo "SSH error su: $val" echo $val>> ${LOG_NONOK} fi done