![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| process status | nicos | High Level Programming | 3 | 12-09-2008 01:52 PM |
| List Process with their Status. | varungupta | UNIX for Advanced & Expert Users | 2 | 03-21-2008 09:27 PM |
| Ftp Service /process Status | GaneshB | Linux | 1 | 03-10-2008 10:15 AM |
| replace first instance(not first instance in line) | IronHorse7 | Shell Programming and Scripting | 3 | 02-07-2008 01:29 PM |
| How to check if another instance of the process is running | sim | Shell Programming and Scripting | 8 | 06-30-2005 07:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Printing the Status of a Process in an Instance
Hi,
I am executing the command: "./opmnctl status" to get the status of the processes in the instance. There are totally 5 processes that are avaialble, out of which 3 are "Alive" and 2 are "Down". How can I use the IF loop to get the status and echo it?? For instance I want to run a check whether all the processes are "Alive" if yes then echo saying "OPMN is up" else "Not all OPMN processes are up" Please help. Thanks. |
|
||||
|
Thanks for your reply....
I am actually new to working with Unix...Could you please explain in detail?? Following is how im getting the process details: [root@SNRBBY34844 bin]# ./opmnctl status Processes in Instance: oc4j_as1.mxb01981s001.naretail.na.com ---------------------------------+--------------------+---------+----- ias-component | process-type |pid | status ---------------------------------+--------------------+---------+----- ASG | ASG |N/A | Down OC4JGroup:default_group | OC4J:IP-BO-C-I~ |21242 |Alive OC4JGroup:default_group | OC4J:P-BO-M10 |N/A | Down OC4JGroup:default_group | OC4J c4j_soa |21240 | Alive HTTP_Server | HTTP_Server |21239 | Alive Thanks in advance. Appreciate your help... |
|
|||||
|
If you post code, logs, data etc. use code-tags for better readability please.
Ok, processing the relevant part of your output: Code:
awk -F"|" '
$NF ~ /Alive/ {r+=1; a+=1; print}
$NF ~ /Down/ {r+=1; d+=1; print}
END{if( a != r ) {print "some not up!"}}
' infile
ASG | ASG |N/A | Down
OC4JGroup:default_group | OC4J:IP-BO-C-I~ |21242 |Alive
OC4JGroup:default_group | OC4J:P-BO-M10 |N/A | Down
OC4JGroup:default_group | OC4Jc4j_soa |21240 | Alive
HTTP_Server | HTTP_Server |21239 | Alive
some not up!
All other lines that don't fit to the 2 rules $NF ~ /Alive/ or $NF ~ /Down/ are just bypassed. Last edited by zaxxon; 02-02-2009 at 12:18 PM.. Reason: Exploring the LIST-tag :) |
|
||||
|
I am trying to execute the set of code u have provided by putting it in a script file for e.g. "Test.sh" and when I am executing the script I get a following error:
awk: cmd. line:2: - awk: cmd. line:2: ^ unexpected newline or end of string Can u pls. help?? Thanks in advance... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|