Here is another script I am trying to customize currently,
this script is used to send me disk space information, but at the moment I have to enter all the servers in manually SERVER= "xxx bbb ccc" ect..
how can I script it so that the servers are called off a txt file versus me entering all of them ? my intention is to separate them PROD, QA ect.. and call those txt files and environments when needed.
Like a plug and play.
#!/bin/bash
Date="'date +%m/%d/%y %H:%M:%S'"
SERVERS="xxx bbb ccc"
USR="me"
# Email
SUBJECT="Disk Free Verification for Hosts"
EMAIL="xxx@ex"
EMAILMESSAGE="/u/home/xxx/AccountV.txt"
# create new file
>$EMAILMESSAGE
# connect each host and pull up user listing
for host in $SERVERS
do
echo "--------------------------------" >>$EMAILMESSAGE
echo "* HOST: $host " >>$EMAILMESSAGE
echo "--------------------------------" >>$EMAILMESSAGE
ssh $USR@$host df -h | sed '/platform/d' >> $EMAILMESSAGE
done
# send an email using /bin/mail
#/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
mailx -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE