Websphere Running processes script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Websphere Running processes script
# 1  
Old 04-15-2014
Websphere Running processes script

Hello experts,
I'm trying to run a script that checks the processes listed and returns their name and their PIDs.
Code:
#!/bin/bash
PROCS="DMgr BPM.AppTarget BPM.Support BPM.WebApp BPM.Messaging nodeagent App.Messaging "
for p in $PROCS
do
        PROCEXIST=$(ps aux | grep $p | grep -v grep)

        if [ "$PROCEXIST" != "" ]; then
                BPMPROCID=$(ps aux | grep $p | grep -v grep | awk '{print $2}')
                echo "$p:PID $BPMPROCID"
        fi
done

issue is that there are 2 nodeagent processes running and it just vomits the PID but doesnt really give the Name for the second Nodeagent.

Ideally , I would like the Node Name of the nodeagent also printed so you can differentiate amongst the nodeagents.

Any help is appreciated.
Look forward to your responses,
KKSmilie

---------- Post updated at 02:38 PM ---------- Previous update was at 02:37 PM ----------

I was using this but this stopped working since one of our processes has more than 4096 characters and processes were all wonky and incorrectly being reported by the script.

Code:
ps -fe | grep java | awk -F ' ' ' { print $1," ",$2,"\t",$(NF-2),"\t",$(NF-1),"\t",$NF } ' | sort -k4 | grep coresvcd | grep -v grep | grep -v Seomthing | grep -v com.ibm.ws.bootstrap.WSLauncher


Last edited by Franklin52; 04-16-2014 at 03:17 AM.. Reason: Please use code tags
# 2  
Old 04-15-2014
What's your system?

What output do you want?

Usually there are things like pgrep so you don't need to make ps | grep | awk | sed | cut | kitchen | sink solutions.
# 3  
Old 04-15-2014
The issue is that you are echoing the value of $p after you assign the $BPMPROCID variable. The value of $p is hard coded in $PROCS list. What you would need to do is create a new variable in the same way you created $BPMPROCID to dynamically pick up the actually process name.

I am not sure where the process name (i.e. Nodeagent) gets outputted on the screen, but say if it is the last word on the line when performing 'ps aux' , the below amendments (assigning a PNAME variable and printing that instead of $p) should work for you. Hope this helps.

Code:
#!/bin/bash
PROCS="DMgr BPM.AppTarget BPM.Support BPM.WebApp BPM.Messaging nodeagent App.Messaging "
for p in $PROCS
do
PROCEXIST=$(ps aux | grep $p | grep -v grep)

if [ "$PROCEXIST" != "" ]; then
BPMPROCID=$(ps aux | grep $p | grep -v grep | awk '{print $2}')
PNAME=$(ps aux | grep $p | grep -v grep | awk '{print $NF}')
echo "$PNAME:PID $BPMPROCID"
fi
done

Btw obviously Corona is right, there are of course more effective/efficient ways of doing this, I'm just trying to help to benefit your understanding at the very least.
# 4  
Old 04-16-2014
Corona688,
Im on linux redhat

Im looking for something like,

Dmgr-1234
BPM.AppSvr-2467
BPM.WebSvr-1212
BPM.Messaging-3214
nodeagent(Node1)-9875
nodeagent(Node2)-34323

Everything before the hyphen (-) like dmgr BPM.* nodeagent(Node1/2) is in the process its just that i suck this this whole thing.

---------- Post updated at 05:15 PM ---------- Previous update was at 05:10 PM ----------

pilnet 101 ,
I appreciate you helping me out.I really do.
As i said , i struggle a lot with this kind of stuff....

---------- Post updated 04-16-14 at 11:12 AM ---------- Previous update was 04-15-14 at 05:15 PM ----------

Quote:
Originally Posted by pilnet101
The issue is that you are echoing the value of $p after you assign the $BPMPROCID variable. The value of $p is hard coded in $PROCS list. What you would need to do is create a new variable in the same way you created $BPMPROCID to dynamically pick up the actually process name.

I am not sure where the process name (i.e. Nodeagent) gets outputted on the screen, but say if it is the last word on the line when performing 'ps aux' , the below amendments (assigning a PNAME variable and printing that instead of $p) should work for you. Hope this helps.

Code:
#!/bin/bash
PROCS="DMgr BPM.AppTarget BPM.Support BPM.WebApp BPM.Messaging nodeagent App.Messaging "
for p in $PROCS
do
PROCEXIST=$(ps aux | grep $p | grep -v grep)

if [ "$PROCEXIST" != "" ]; then
BPMPROCID=$(ps aux | grep $p | grep -v grep | awk '{print $2}')
PNAME=$(ps aux | grep $p | grep -v grep | awk '{print $NF}')
echo "$PNAME:PID $BPMPROCID"
fi
done

Btw obviously Corona is right, there are of course more effective/efficient ways of doing this, I'm just trying to help to benefit your understanding at the very least.





tried that and i got this "exact" output


TheNameOfTheCell:PID 22200
BPM.Support:PID 21675
BPM.WebApp:PID 21925
nodeagent
nodeagent:PID 13530
13913

---------- Post updated at 12:22 PM ---------- Previous update was at 11:12 AM ----------

seems like its still messing up on the nodeagent part
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Running processes

Hi guys is it normal to have 5-10 cron/syslog processes running... in my case i got 10 cron process running. (4 Replies)
Discussion started by: batas
4 Replies

2. Solaris

Running processes on GZ/LZ

Hi guys just a question is it normal to see running process on a non-global zone in the global zone... processes such as cron. (3 Replies)
Discussion started by: batas
3 Replies

3. Shell Programming and Scripting

A script that kills previous instances of itself upon running not killing child processes

I'm likely going to explain this clumsily, so apologies in advance: I have the following script: #!/bin/bash pidPrefix="logGen" checkPrime () { if /sbin/ifconfig eth0:0|/bin/grep -wq inet;then isPrime=1;else isPrime=0;fi } killScript () { /usr/bin/find /var/run -name... (4 Replies)
Discussion started by: DeCoTwc
4 Replies

4. Shell Programming and Scripting

Need help with running processes script

I'm doing a script with the Shell. I need that it only show the number of running processes. Ex: echo "There are `command` running processes" Thnx! Pd: Sorry the idiom. I'm spanish. (5 Replies)
Discussion started by: Ikebana
5 Replies

5. Shell Programming and Scripting

Need help with running processes script

I'm doing a script with the Shell. I need that it only show the number of running processes. Ex: echo "There are `command` running processes" Thnx! Pd: Sorry the idiom. I'm spanish. (2 Replies)
Discussion started by: Ikebana
2 Replies

6. Shell Programming and Scripting

Script for long running processes....

I searched the forums but didn't see anything related to what I'm looking for. I need a script that would give me a listing of jobs running longer than, for example, 12 hours or so. Thanks in advance for your assistance!! (2 Replies)
Discussion started by: CyberOptiq
2 Replies

7. Shell Programming and Scripting

Script to check running processes on remote server.

Hi, I am trying to write a script, which queries a db to get the names of processes, stores it in a file and then checks if that process is running on a remote server. However I am not getting it right, could anyone help me out. #!/bin/sh echo "select Address from Device where Cust =... (5 Replies)
Discussion started by: amitsayshii
5 Replies

8. UNIX for Dummies Questions & Answers

Script to kill rsh processes running for more than 10 mins

Hi Friends, I need to write a script to kill some processes running for more than 10 minutes. Can I get some pointers on that. Thanks for ur help in Advance. Thanks&Regards, Amit (3 Replies)
Discussion started by: amitsayshii
3 Replies

9. Shell Programming and Scripting

script to kill rsh processes running for more than 10 minutes

Hi Friends, I need to write a script to kill some processes running for more than 10 minutes. Can I get some pointers on that. Thanks for ur help in Advance. Thanks&Regards, Amit (1 Reply)
Discussion started by: amitsayshii
1 Replies

10. UNIX for Advanced & Expert Users

script to kill rsh processes running for more than 10 minutes

Hi Friends, I need to write a script to kill some processes running for more than 10 minutes. Can I get some pointers on that. Thanks for ur help in Advance. Thanks&Regards, Amit (1 Reply)
Discussion started by: amitsayshii
1 Replies
Login or Register to Ask a Question