Sponsored Content
Top Forums Shell Programming and Scripting Need urgent help with korn shell script Post 302718765 by aix_admin_007 on Saturday 20th of October 2012 08:52:46 PM
Old 10-20-2012
Need urgent help with korn shell script

Hi All,

Need urgent help with korn shell script, which monitors AIX WPARs Status. Basically WPARs run on a LPAR, So there is a Command "lswpar" which displays WPARs status. This script should be checking the WPARs Status and email support if WPAR is down or broken. General lswpar output is as below, I just need the script to check the "Name" and "State" coloumn below, If State is A Server is Active, If State is B Server is Broken, If State is T server is in Transition, If State is D Server is Defined. Script should check the State if its "A" send mail saying State Active with Server Names, If State is B, T, D scricpt should mail saying State Broken or Transition or Defined with Server Names. Please see below for script i tried so far, which is giving error as awk: Field is not correct.
The input line number is 1. The file is /tmp/wpar_state_ck.out.
The source line number is 1.
wpar_status_check_workinprogress[29]: A: bad number

Code:
lswpar command output below:
root@wparsprd01:/#lswpar
Name State Type Hostname Directory RootVG WPAR
-----------------------------------------------------------------------
usprd02 A S usprd02 /wpars/usprd02 yes 
usprd03 A S usprd03 /wpars/usprd03 yes 
usprd03 B S usprd03 /wpars/usprd03 yes 
usprd03 T S usprd03 /wpars/usprd03 yes 
usprd03 D S usprd03 /wpars/usprd03 yes

Script below:
Code:
#!/usr/bin/ksh
#set -x 
state=A
echo "************************ WPAR Clients Status Check **************************" >> /tmp/wpar_state_ck.out
echo "--------------------------------------------------------------------------------" >> /tmp/wpar_state_ck.out
lswpar | grep -e Name -e State | awk '{print $1,"\t","\t","\t",$2}' >> /tmp/wpar_state_ck.out
echo "--------------------------------------------------------------------------------" >> /tmp/wpar_state_ck.out
lswpar | awk '{print $1,"\t",$2}' | grep -v Name | grep A >> /tmp/wpar_state_ck.out
# Mail the Status with State Active if A or (Defined or Transition or Broken) if D, T, B 
cat /tmp/wpar_state_ck.out | grep -e A | grep -v WPAR | grep -v State | awk '{print $2}' | wc -l | while read i
do
check=$(awk 'FNR == $i {print}' /tmp/wpar_state_ck.out) 
if [ "$check" = "$state" ];
then
echo "******************************* WPAR_State = Active *********************************" >> /tmp/wpar_state_ck.out
else
echo "****************** WPAR_State = Defined or Transition or Broken *********************" >> /tmp/wpar_state_ck.out
fi
done
#echo "################################################################################" >> /tmp/wpar_state_ck.out
#echo "A : Active State" >> /tmp/wpar_state_ck.out
#echo "D : Defined State" >> /tmp/wpar_state_ck.out
#echo "T : Transition State" >> /tmp/wpar_state_ck.out
#echo "################################################################################" >> /tmp/wpar_state_ck.out
cat /tmp/wpar_state_ck.out | mail -s "WPAR `hostname` Server monitoring Status of Client WPARs" unix_support@xyz.com
# remove the file
rm -f /tmp/wpar_state_ck.out

Error Message am getting:
Code:
awk: Field is not correct.
The input line number is 1. The file is /tmp/wpar_state_ck.out.
The source line number is 1.
wpar_status_check_workinprogress[29]: A: bad number

Moderator's Comments:
Mod Comment Please use code tags

Last edited by jim mcnamara; 10-20-2012 at 10:32 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

demineur in korn shell:urgent.

hello. have please a demineur programmed in shell korn (unix).???? can you send it to me??? thanks. (0 Replies)
Discussion started by: raul
0 Replies

2. UNIX for Advanced & Expert Users

Minesweeper in korn shell:urgent

if you have the programme of Minesweeper;take me it because i need it. thank u very much. (1 Reply)
Discussion started by: raul
1 Replies

3. UNIX for Dummies Questions & Answers

korn shell script

hello., i have 2 files.. 1 file is in this folder /home/test/ssk/DSA.WLG.20050713211544.20050710.20050713211544 (this part) other file is in this folder /home/kk/dev/DSA.WLG.20050711210100.20050710.20050711210100 ... (1 Reply)
Discussion started by: pavan_test
1 Replies

4. UNIX Desktop Questions & Answers

korn shell script

hi all i am writing the korn shell script. i have a SQL script which gives me the folowing output DSA.WLG.20050713211544.20051025.20050713211544 28991 1130198400 DSA.WLG.20050713211544.20051025.20050713211544 25881 1130198400 DSA.WLG.20050711210100.20051025.20050711210100 25881 ... (3 Replies)
Discussion started by: pavan_test
3 Replies

5. AIX

Help with Korn Shell script

I have this Korn shell script that runs via a cron entry. It runs in a loop "watching" a specific file system for files with a certain name. The file system that it is watching is an upload file system for an FTP server. When files that are the correct name come in, it takes the extension of the... (1 Reply)
Discussion started by: heprox
1 Replies

6. Shell Programming and Scripting

Urgent Korn Shell scripting Help Pleaaaase...

Hello All, Can someone help me to set a user's password from the script using korn shell. The password change is a one time password after user account creation. I tried providing the input file as the value for password field but password change requires tty so my password from an input file... (3 Replies)
Discussion started by: solaix14
3 Replies

7. Shell Programming and Scripting

Korn Shell Script

I have to solve some exercises in Korn Shell, but i'm having some problems. For example: Write a korn shell script with an alfanumeric string as argument. The script lists the file's names in the current directory that contain the given string as substring and that can be read and written. I... (3 Replies)
Discussion started by: burm
3 Replies

8. Homework & Coursework Questions

Korn Shell Script

1. The problem statement, all variables and given/known data: Write a korn shell script with an alfanumeric string as argument. The script lists the file's names in the current directory that contain the given string as substring and that can be read and written. 2. Relevant commands, code,... (3 Replies)
Discussion started by: burm
3 Replies

9. Shell Programming and Scripting

pass null value to sql script from korn shell script

There are 4 parameters that I have to pass from korn shell to sql script. 1) I have to check if $1 , $2 , $3 and $4 are null values or not . How can I do that ? 2) Once its determined that these values are null (in the sense they are empty) how can I pass null values to sql script... (11 Replies)
Discussion started by: megha2525
11 Replies

10. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies
All times are GMT -4. The time now is 04:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy