Della serie “come aiutarsi con gli strumenti di Linuxxeee”
#!/bin/bash
HOSTS=( "xxxxx.xxx" "xxx" "xxxxxx.xx" "xxxxxxx" "xxxx.xx" )
PWD="/etc/syslog-ng"
THOST=""
function get_remote() {
user=$1
host=$2
logDestination=`ssh ${user}@${host} egrep "^.*remotelog.*udp" ${PWD}/syslog-ng.conf |awk {'print $1'}`
if [ -z ${logDestination} ]
then
echo -n "LOGGING NOK "
else
echo -n "LOGGING OK "
fi
return 0
}
function ctl_host() {
host=$1
if ! ping -c1 -w5 ${host} &>/dev/null
then
#echo "${host} Non raggiungibile provo a cambiare dominio"
for t_index in $(seq 0 $((${#HOSTS[@]} - 1)))
do
#echo "Provo: ${host}.${HOSTS[t_index]} ..."
nHost="${host}.${HOSTS[t_index]}"
if ping -c3 -w10 ${nHost} >/dev/null
then
#echo "Trovato: ${nHost}"
THOST=${nHost}
break
fi
done
else
THOST=${host}
fi
return 0
}
function get_network() {
user=$1
host=$2
vlan202=`ssh ${user}@${host} ip route show |egrep "10.32.0.0" |awk {'print $1'}`
if [ -z ${vlan202} ]
then
echo "VLAN202 NOK"
else
echo "VLAN202 OK"
fi
return 0
}
function main() {
for dbhosts in $(cat listadb.txt)
do
echo -n "${dbhosts}: "
ctl_host ${dbhosts}
get_remote root ${THOST}
get_network root ${THOST}
if [ $? -gt 0 ]
then
echo "Qualcosa e andato storto su: ${dbhosts}."
fi
done
return 0
}
main
exit 0