Operating System - HP-UX
1748013 Members
3786 Online
108757 Solutions
New Discussion юеВ

Re: Script to get the report of the process running in 30 Servers

 
SOLVED
Go to solution
Kadavan
Occasional Advisor

Re: Script to get the report of the process running in 30 Servers

Thank you all your help ..I was able to do completed the script as foollows

while read HOST
do
ssh -n ${HOST} hostname
ssh -n ${HOST} ps aux | grep -v root

done < /home/binu/scripts/hostnames 1> /home/binu/scripts/output 2>&

Thanks
-Binu
Steven Schweda
Honored Contributor

Re: Script to get the report of the process running in 30 Servers

> ssh -n ${HOST} hostname

What does that tell you that you didn't
already know?
Kadavan
Occasional Advisor

Re: Script to get the report of the process running in 30 Servers

This entry made to update the output file with hostname and then the Process details ..Other wise we cannot make out which process is from which server

Looks like this
cpaiqp4a

USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND
tauser02 1396842 0.9 9.0 1385060 1385096 - A Mar 22 824:12 /opt/isv/WAS51
tauser02 3653858 0.4 9.0 1380776 1380812 - A Mar 22 350:33 /opt/isv/WAS51
www 4370646 0.1 2.0 283820 283588 - A Feb 28 243:21 /opt/isv/IBMIH
tauser02 4788304 0.0 1.0 136920 136956 - A Feb 28 55:44 /opt/isv/WAS51
Steven Schweda
Honored Contributor

Re: Script to get the report of the process running in 30 Servers

> This entry made to update the output file
> with hostname [...]

Something simple (and local) might be faster:

echo ${HOST}

You're giving the name of the remote host to
"ssh", so that you can ask the remote host to
tell you its name? (I can imagine cases
where you might get a different answer back,
but none seems very likely.)

If you really want the name from the remote
host, do you need two "ssh" sessions?

> ssh -n ${HOST} ps aux | grep -v root

That does the "ps" on the other system, but
it does the "grep" locally, doesn't it? I
haven't tested it, but I'd try to do all the
work on the remote system:

ssh -n ${HOST} 'ps aux | grep -v root'

And, if that worked, then I'd try something
like:
[...] 'hostname ; ps aux | grep [...]'
in _one_ "ssh" command.