LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-24-2013, 11:25 PM   #1
msgforsunil
Member
 
Registered: Jun 2006
Posts: 38

Rep: Reputation: 15
Means to check if some process is running on "n" number of machines


Team,

I would like to know, if we have any command in Solaris to verify, if some process is listening on a port on a set of machines.

for eg: Wrote the below script, and found that when a process is listening on that port, then it just waits there and doesnt come out. Rather, I would like the script to verify, if some process is listening on that port on that machine and then come out with appropriate message and process to verify a port on the next machine.

telnet abc 33
telnet xyz 405
telnet bbb 54

Do we have any other alternative? Does lsof be useful? Please let me know on this.


Thanks
Sunil Kumar
 
Old 01-24-2013, 11:31 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,797
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Make sure that those machnies are reachable (using ping) and your loocal machine has connectivity with them.

In order to check whether a port is working or not, you're doing right. But if cmd is not responding then may be firewall is blocking your connection or port is not open on remote machine. Can you check that?

On remote machine, you can find port details using,
Code:
~$ netstat -i
Or from your local machine, if you've ssh connectivity, then from your local machine you can,
Code:
~$ ssh user@machine "netstat -i"

Last edited by shivaa; 01-24-2013 at 11:34 PM.
 
Old 01-24-2013, 11:38 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,401

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
If you've got nmap, you can specify hosts and ports to check, rather than the default of 'everything'

The other approach is to use (or write) a tool that understands the target port's protocol, so enabling you to get a sane answer.
Lots of these are available as plugins for Nagios and similar tools.
You could use one of these or write your own.
 
1 members found this post helpful.
Old 01-25-2013, 12:10 AM   #4
msgforsunil
Member
 
Registered: Jun 2006
Posts: 38

Original Poster
Rep: Reputation: 15
Hi Siva,

I dont know, if the other process is ssh and I neither have user credentials as well. :-(


Thanks
Sunil Kumar
 
Old 01-25-2013, 12:17 AM   #5
msgforsunil
Member
 
Registered: Jun 2006
Posts: 38

Original Poster
Rep: Reputation: 15
Hi Chris,

I don't have nmap installed on my machine. Is it possible to find using lsof? If yes, can you please tell me the syntax?

Thanks
Sunil Kumar
 
Old 01-25-2013, 01:32 AM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,401

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
lsof lists open files on the local system; it's not a remote network port tool.
If you tell us how many machines & which ports (protocols) you want/need to check, we could help you better.
 
Old 01-25-2013, 02:02 AM   #7
msgforsunil
Member
 
Registered: Jun 2006
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks Chris.

Well, there are about 3000+ machines and I think, most likely to run SSH protocol.

Thanks
Sunil Kumar
 
Old 01-25-2013, 07:02 AM   #8
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,401

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
'most likely ' ???

You need to know what you are looking for, unless you are just doing a random scan.
Ask your Mgr exactly what protocol(s) he wants checked and what for eg just basic up/down?

Assuming you do want ssh, then normally/default it listens on port 22.

You could just run a shell script to ssh to targets, possibly multiple copies as 3000 would take a while if done consecutively.
You could go for Perl, which can do the same, but can be done all in program instead of multiple shell cmds.
(you might want multiple copies for the same reason, but don't swamp the network...)

Another option for that many machines (and particularly if you want more than just ssh checked), is to use a proper monitor tool eg Nagios, OpenNMS etc.
 
Old 01-25-2013, 08:38 AM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 2,690

Rep: Reputation: 687Reputation: 687Reputation: 687Reputation: 687Reputation: 687Reputation: 687
Quote:
Originally Posted by msgforsunil View Post
Thanks Chris.

Well, there are about 3000+ machines and I think, most likely to run SSH protocol.

Thanks
Sunil Kumar
Nmap is what you want. It can scan even large networks efficently, and not take hours to do it.
 
Old 01-25-2013, 09:29 AM   #10
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,863
Blog Entries: 1

Rep: Reputation: Disabled
Code:
echo "quit"| telnet <IP> <port>
and process the result(s).

but for 1000s of systems, this is NOT THE WAY TO GO, as jpollard has said.

Last edited by Habitual; 01-25-2013 at 02:51 PM.
 
Old 01-26-2013, 04:16 AM   #11
msgforsunil
Member
 
Registered: Jun 2006
Posts: 38

Original Poster
Rep: Reputation: 15
Hi All,

Can you please tell me as how to exchange ssh keys with many servers using a script, without user intervention?

Thanks
Sunil Kumar
 
Old 01-26-2013, 06:24 AM   #12
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,863
Blog Entries: 1

Rep: Reputation: Disabled
Code:
ssh-copy-id user@host
http://goo.gl/Rims

Last edited by Habitual; 01-26-2013 at 06:27 AM.
 
Old 01-26-2013, 08:40 AM   #13
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,863
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Can you please tell me as how to exchange ssh keys with many servers using a script, without user intervention?
Getting the keys to the server will require intervention (password) and by your own admission/posts:

3000+ machines.
"most likely to run SSH protocol"
no nmap
"I neither have user credentials as well"

All this amounts to what seems to be inadequate privileges.
 
Old 01-26-2013, 09:21 AM   #14
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 2,690

Rep: Reputation: 687Reputation: 687Reputation: 687Reputation: 687Reputation: 687Reputation: 687
It really just points to "get and install nmap".
 
Old 01-26-2013, 11:32 AM   #15
arun5002
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 555
Blog Entries: 5

Rep: Reputation: Disabled
In your scenerio you can go with what chrism01 has said you with his previous post .Try to install any of monitoring tool like opennms (or) nagios these will do the trick for you in simpler way
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get the port number of the "ajp13" service running on host master? atirasatiras Linux - Server 1 04-01-2011 04:32 AM
"Check if your dcopserver is running" (ASUS Eee Netbook). Need instructions how.. Peter H. Grumbach Linux - Newbie 1 12-17-2010 08:09 PM
Getting "SIOCADDRT: No such process" when running "service network restart" cmlorentz Linux - Networking 1 11-26-2010 01:06 PM
Shell script to check process and restart if "hung" georage Programming 5 10-29-2008 07:10 PM
User "list" running process "python" TroelsSmit Linux - Newbie 2 02-22-2005 04:55 AM


All times are GMT -5. The time now is 07:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration