Jeff Abrahamson on 10 Jun 2004 13:59:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] check for process on other machine


On Thu, Jun 10, 2004 at 09:18:52AM -0400, Mattison, Jacob wrote:
>   [10 lines, 118 words, 869 characters]  Top characters: _entiroh
> 
> My website (running on a redhat 9 server) utilizes a service that
> runs on another machine on our network (which is running AIX).  I'd
> like to be able to periodically check, from the web server machine,
> whether the other service is running.  What are my options?  I know
> I can use nmap to scan for open ports and grep to see if the
> appropriate port is among them.  Since I know the port in advance,
> is there a more efficient way to check just that port?  Is there
> another way to check whether the service is running?

If it is running on some port, why not just try to use the service and
see if that succeeds?

Alternately, assuming you are using TCP,

    nmap -sT -p portnum hostname

man nmap(1):

       -sT    TCP connect() scan: This is the most basic form  of  TCP  scan-
              ning. The connect() system call provided by your operating sys-
              tem is used to open a connection to every interesting  port  on
              the  machine. If the port is listening, connect() will succeed,
              otherwise the port isn't reachable.  One  strong  advantage  to
              this  technique  is that you don't need any special privileges.
              Any user on most UNIX boxes is free to use this call.
                                                                               
              This sort of scan is easily detectable as target host logs will
              show  a bunch of connection and error messages for the services
              which accept() the connection just to have it immediately shut-
              down.  This is the default scan type for unprivileged users.
                                                                               
       -p <port ranges>
              This option specifies what ports you want to specify. For exam-
              ple  "-p  23" will only try port 23 of the target host(s).  "-p
              20-30,139,60000-" scans ports between 20 and 30, port 139,  and
              all ports greater than 60000.  The default is to scan all ports
              between 1 and 1024 as well as any ports listed in the  services
              file  which  comes  with nmap.  For IP protocol scanning (-sO),
              this specifies  the  protocol  number  you  wish  to  scan  for
              (0-255).
 
              When scanning both TCP and UDP ports, you can specify a partic-
              ular protocol by preceding the port numbers by  "T:"  or  "U:".
              The  qualifier  lasts until you specify another qualifier.  For
              example,  the  argument  "-p  U:53,111,137,T:21-25,80,139,8080"
              would  scan UDP ports 53,111,and 137, as well as the listed TCP
              ports.  Note that to scan both UDP & TCP, you have  to  specify
              -sU  and at least one TCP scan type (such as -sS, -sF, or -sT).
              If no protocol qualifier is given, the port numbers  are  added
              to all protocol lists.

-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>
 GPG fingerprint: 1A1A BA95 D082 A558 A276  63C6 16BF 8C4C 0D1D AE4B

 A cool book of games, highly worth checking out:
 http://www.amazon.com/exec/obidos/ASIN/1931686963/purple-20

Attachment: signature.asc
Description: Digital signature