Checking LB status.. stuck in script syntax of code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking LB status.. stuck in script syntax of code
# 1  
Old 04-16-2014
Checking LB status.. stuck in script syntax of code

Code:
#!/bin/ksh
#This script will check status of load balancer in AIX servers from hopbox
#Steps to do as folows :
#Login to server
#netstat -ani | grep <IP>
#check if the output contains either lo0 OR en0
#if the above condition matches, validation looks good
#else, send an email with impacted server names
file="/export/home/vinil/scripts/LB_check/server.txt"
while read line
do
ssh -t -t <IP_address_of_server>|v1=`netstat -ani|grep $IP|awk '{print $1}`;
if [ v1 -eq lo0 -o v1 -eq en0 ]; then
echo $v1
echo  LB is running on host $host>>log.txt;
else
echo "LB is not working ">>log.txt ;
fi
done <$file


The highlighted line is not working as expected. Please correct and let me know any modifications needed.
Thanks
# 2  
Old 04-16-2014
Well you can help including the error message you get rather expecting us to guess
# 3  
Old 04-16-2014
quote is missing
Code:
netstat -ani|grep $IP|awk '{print $1}'`;

# 4  
Old 04-16-2014
Code:
ssh -t -t $IP|v1=`netstat -ani|grep $IP_2|awk '{print $1}'`;

the issue is this is not running at all. While debugging, it is giving same result upon changing the value to be grep
# 5  
Old 04-16-2014
can you try to split below line
Code:
ssh -t -t $IP|v1=`netstat -ani|grep $IP_2|awk '{print $1}`;

to
Code:
ssh -t -t $IP
v1=`netstat -ani|grep $IP_2|awk '{print $1}'`

Also could you please let us know from where you will be getting values for $IP_2 & $IP
# 6  
Old 04-16-2014
Quote:
Originally Posted by Makarand Dodmis
can you try to split below line
Code:
ssh -t -t $IP|v1=`netstat -ani|grep $IP_2|awk '{print $1}`;

to
Code:
ssh -t -t $IP
v1=`netstat -ani|grep $IP_2|awk '{print $1}'`

Also could you please let us know from where you will be getting values for $IP_2 & $IP

I will try this for you and post the update. Meanwhile, please note that the variable mentioned ($IP and $IP_2)are different server names used in production for client.I have already defined their values in script.
# 7  
Old 04-21-2014
Code:
ssh -q <server_name>| netstat -ani | grep -i <IP> | awk '{print $1}'

Failed again. Can some one correct me or provide me better code that can check particular on specific server and print if the IP is associated with lo0 or en0 (these are LB components )
Thanks

---------- Post updated 04-21-14 at 10:46 AM ---------- Previous update was 04-20-14 at 04:31 PM ----------

Code:
ssh -t -t <server_name> netstat -ani | grep -i <IP> | awk '{print $1}'

the above works as expected but failed to complete the loop of reading input file having list of servers one per line. Any help appreciated

Last edited by vinil; 04-21-2014 at 04:00 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

2. Shell Programming and Scripting

Shell Script for continuously checking status of a another script running in background, and immedia

Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some... (9 Replies)
Discussion started by: ketanraut
9 Replies

3. Shell Programming and Scripting

Script for SFTP Status Checking

Greetings... I have to construct shell script to check the SFTP status, Define a global variable (say sftpStatus). Set it to default value "success" when you define it first time outside the script. check the current SFTP status (say currentStatus - local variable within the script) if... (16 Replies)
Discussion started by: manju98458
16 Replies

4. Shell Programming and Scripting

Checking directory status

Can I use -ctime/-mtime to verify if a particular directory has been updated or not? I don't care about number of days. I just want to perform some operations only if the folder is modified (or it's metadata is modified), i.e. some files are added to the directory. This thread has a more... (1 Reply)
Discussion started by: Pramit
1 Replies

5. Shell Programming and Scripting

Checking ksh script syntax

To check a bash script syntax without executing it we use: bash -n scriptname What should be the equivalent command for checking a ksh script? (8 Replies)
Discussion started by: proactiveaditya
8 Replies

6. Homework & Coursework Questions

i get stuck with this shell script code

i get stuck here . Anyone could check my work? the user type a group of upper case letters at a time with 0 at the end. Find and display the first letter in alphabetic order. For example, input of F, G, K, S, U, G, D, Q, P , the result should be D Any invalid input character (eg. #, $, 3, a,... (5 Replies)
Discussion started by: sbcvn
5 Replies

7. Shell Programming and Scripting

Checking the status of the script on remote machine

Hi! I have a script, which calls another script on a remote machine using ssh. I need to check if the remote running script is succesful. If it is succesful I need to continue the for loop (run it on another machine) or break the loop. Please let me know if anyone has an idea on checking the... (3 Replies)
Discussion started by: nua7
3 Replies

8. Shell Programming and Scripting

.sh file syntax checking script

This isn't a question--its a solution! Below is a script that I wrote for my own script file development which does what the title says. Its the closest that you can get to compiling what are otherwise purely interpreted script files. I offer it here simply for the benefit of anyone else writing... (12 Replies)
Discussion started by: fabulous2
12 Replies

9. Shell Programming and Scripting

checking exit status of a shell script

Hi, I have tried with the following code; if ;then echo "Failure." else echo "Success." fi to test the exit status of the test.ksh shell script. But whatever is the exit status of the test.ksh shell script Failure. is always printed. Please help. regards, Dipankar. (2 Replies)
Discussion started by: kdipankar
2 Replies

10. UNIX for Dummies Questions & Answers

Script syntax checking

Is it possible to check the script syntax with some sort of command...? Without running the script . I'm using Sun Solaris (3 Replies)
Discussion started by: bjornrud
3 Replies
Login or Register to Ask a Question