Tag Archives: SERVERS

While loop problem taking too long

By SkySmart

Code:

while read myhosts
do
while read discovered
do
echo "$discovered"

done < $LOGFILE | grep -Pi "[a-z]|[A-Z]" | egrep "${myhosts}" | egrep "CRITICAL" | awk -F";" '{print $3}' | sort -n | uniq

done < $SERVERS | egrep -v "#"


can the above be fixed? for some weird reason it’s taking forever to complete.

the logfile is only 31MB. the list of servers in “SERVERS” is only 10.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Logging in to multiple Linux servers and running the command.

By jpkumar10

Hi,

I am trying to write a script to run a command on multiple linux based servers and get the o/p. I am using ssh to login. It is a celerra box and EMC NAS product.
I am able login but i am not able to run nas command nas_pool -size -all the NAS server. I am getting the following error.

Code:

bash: /nas/sbin/nas_pool: No such file or directory


here is my code. I have added the directory where the command or found but still the bash is not able to run the command. I tired with #!/bin/bash and #!/bin/sh none of the shell are working here is the code that I am running.

Code:

#!/bin/sh
# Linux/UNIX box with ssh key based login
SERVERS="192.168.1.1" ## I have changed the ip addresses for security reason.
# SSH User name
USR="nasadmin"

# Email
SUBJECT="Server user login report"
EMAIL="abcdefgh@gmail.com"
EMAILMESSAGE="/tmp/emailmessage.txt"

# create new file
>$EMAILMESSAGE

# connect each host and pull up user listing
for host in $SERVERS
do
echo "--------------------------------" >>$EMAILMESSAGE
echo "* HOST: $host capacity report " >>$EMAILMESSAGE
echo "--------------------------------" >>$EMAILMESSAGE
echo "for host $host "
ssh $USR@$host /nas/sbin/nas_pool -size -all >> $EMAILMESSAGE
done

# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE


I am not sure what I am missing. EMC Celerra is a propitiatory LINUX. I did get the o/p for pwd command. I am not sure why /nas/sbin/nas_pool -size -list is not working.

Any help is greatly appreciated.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Efficient rewrite of code?

By SkySmart
Code:
egrep -v "#" ${SERVERS} | while read shosts
do
grep -Pi "[a-z]|[A-Z]" ${LOGFILE} | egrep "${snhosts}" | egrep "NOTIFICATION:" | awk -F";" '{print $3}' | sort -n | uniq | while read CEXIST
do
if [ "$CEXIST" = "$rcheckname" ] ; then
echo "$CEXIST"
fi
done
done

is there a better way to rewrite the above code? im guessing there’s some awk magic out there that could work here?
Source: The UNIX and Linux Forums