check processes on remote system?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting check processes on remote system?
# 1  
Old 10-21-2008
check processes on remote system?

I have a script that counts the number of oracle processes running on the system:

Code:
if [ `ps -ef | grep ora_ | wc -l` -gt 0 ]
then

and it continues based on whether or not it finds running processes. Now we would like to move oracle to a separate server, but keep the application (and this script) on the old machine.

Is there a way for a script to perform a similar check (count number of running oracle processes) on a remote host? Smilie

The systems are all HP-UX 11iv1 and shell is KSH.

TIA!! Smilie
# 2  
Old 10-21-2008
Code:
if [ `ssh remote 'ps -ef | grep ora_ | wc -l'` -gt 0 ]
then

Note: grep can count!
# 3  
Old 10-21-2008
you need to share ssh keys between the two servers and then you can run your command like so...

Code:
if [ `ssh server "ps -ef | grep ora_ | grep -v grep | wc -l"` -gt 0 ]
then

grep will often count and so you can remove it by grep -v grep...
# 4  
Old 10-21-2008
Quote:
Originally Posted by sethcoop
Code:
if [ `ssh server "ps -ef | grep ora_ | grep -v grep | wc -l"` -gt 0 ]
then

grep will often count and so you can remove it by grep -v grep...
This is a very common mistake, you don't need the second grep and wc
Code:
grep -c "[o]ra_"

# 5  
Old 10-21-2008
Or:

Code:
ssh host 'pgrep oracle' && ... || ...

It seams that pgrep is not available on HP-UX, so:

Code:
ssh host 'grep [o]ra_' && ... || ...


Last edited by radoulov; 10-21-2008 at 04:24 PM.. Reason: corrected ...
# 6  
Old 10-21-2008
Quote:
Originally Posted by danmero
This is a very common mistake, you don't need the second grep and wc
Code:
grep -c "[o]ra_"

When using "grep -c" to count and you use it to count how many processes are running the "grep" is a process and will get counted... if you are grep'ing to count processes then it is probably best to do "grep -v grep | wc -l" to count.
# 7  
Old 10-21-2008
Quote:
Originally Posted by sethcoop
When using "grep -c" to count and you use it to count how many processes are running the "grep" is a process and will get counted... if you are grep'ing to count processes then it is probably best to do "grep -v grep | wc -l" to count.
I think danmero meant this:

Code:
$ ps -ef|grep ora_
  oracle  3294     1  0   Sep 05 ?        1:10 ora_dbw1_xxx
  oracle 11443 11433  0 23:02:34 pts/1    0:00 grep ora_
  oracle  3292     1  0   Sep 05 ?        1:18 ora_dbw0_xxx
  oracle  3290     1  0   Sep 05 ?        0:00 ora_pmon_xxx
  oracle  3302     1  0   Sep 05 ?        0:00 ora_reco_xxx
  oracle  3304     1  0   Sep 05 ?        0:00 ora_cjq0_xxx
  oracle  3296     1  0   Sep 05 ?        2:35 ora_lgwr_xxx
  oracle  3298     1  0   Sep 05 ?        7:08 ora_ckpt_xxx
  oracle  3310     1  0   Sep 05 ?        0:02 ora_arc1_xxx
  oracle  3300     1  0   Sep 05 ?        1:32 ora_smon_xxx
  oracle  3306     1  0   Sep 05 ?        0:11 ora_qmn0_xxx
  oracle  3308     1  0   Sep 05 ?        0:05 ora_arc0_xxx
$ ps -ef|grep [o]ra_
  oracle  3294     1  0   Sep 05 ?        1:10 ora_dbw1_xxx
  oracle  3292     1  0   Sep 05 ?        1:18 ora_dbw0_xxx
  oracle  3290     1  0   Sep 05 ?        0:00 ora_pmon_xxx
  oracle  3302     1  0   Sep 05 ?        0:00 ora_reco_xxx
  oracle  3304     1  0   Sep 05 ?        0:00 ora_cjq0_xxx
  oracle  3296     1  0   Sep 05 ?        2:35 ora_lgwr_xxx
  oracle  3298     1  0   Sep 05 ?        7:08 ora_ckpt_xxx
  oracle  3310     1  0   Sep 05 ?        0:02 ora_arc1_xxx
  oracle  3300     1  0   Sep 05 ?        1:32 ora_smon_xxx
  oracle  3306     1  0   Sep 05 ?        0:11 ora_qmn0_xxx
  oracle  3308     1  0   Sep 05 ?        0:05 ora_arc0_xxx
$

Anyway, the oracle background processes will be running even if the instance is in nomount state (i.e. even if the database is not accessible).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Check processes running on remote server

Hello Guys, I need some help to find out if processes are running on remote server or not. I could do 'ssh' to do that but due to some security reasons, I need to avoid the ssh & get result from remote server. Could you please suggest some that can be done without ssh or similar sort of... (8 Replies)
Discussion started by: UnknownGuy
8 Replies

2. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

3. Shell Programming and Scripting

Pause processes in remote host and resume execution in another remote host

Hi, Given addresses of 2 remote machines, using a shell script is it possible to get the state of running processes in "src" stop all the processes in "src" exit out of "src" ssh into "dest" resume the state of executing processes captured in step 1 in "dest" Assumption: "src" is... (3 Replies)
Discussion started by: Saeya Darsan
3 Replies

4. Shell Programming and Scripting

Remote nodes - login and find number of processes

Hello all, This is my requirement: 1. I have 6 VMs running Apache (for Oracle EBS) as Linux user oracle. 2. From a central server (VM), I need to login to all the 6 VMs as oracle user (I have already set up ssh equivalence, so it is password less authentication). 3. Find the number of... (4 Replies)
Discussion started by: sunpraveen
4 Replies

5. Shell Programming and Scripting

csh Check if file exists on remote system

I've seen this question posed a few times with shell scripting, but have not found anything with csh. I am trying to download multiple txt files from a source using wget. These are archived tornado warning files; however, the files only exist if there were tornado warnings issued that day. I'm... (3 Replies)
Discussion started by: meteorologistks
3 Replies

6. Infrastructure Monitoring

Using SNMP to monitor remote processes and disk space

snmpget -v 1 -c COMMUNITYSTR hostname OID what OIDs would I use to get information on all the processes and disk space information that are on a particular host. where can i find out information on all of this? thanks (3 Replies)
Discussion started by: SkySmart
3 Replies

7. Solaris

how to login with ssh to remote system with out applying the remote root/usr password

how to login with ssh to remote system with out applying the remote root/user password with rlogin we can ujse .rhosts file but with ssh howits possible plz guide (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

8. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

9. Shell Programming and Scripting

check if file exists on remote system ?

Hi there, I am designing a software rollout script and need to check if a particular file exists on a remote system something along the lines of if ; then blah blah The above doesnt work but you get the general idea....is there a way I can do this on a single line ?? any help would... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

10. 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
Login or Register to Ask a Question