Wednesday, February 17, 2010

Monitoring hosts availability

How  nmap + unix helps to monitor hosts availability





What I had:
  1. /etc/hosts file full of local resources + comments 
  2. Pings packages are filter out in the local network 
F.e.
#****Luxoft hosts******
172.30.16.111           luxoftwebmail.luxoft.com #some comments
172.30.128.32           testdb.other.domain.com


To do:
  1. Use /etc/hosts file
  2. Skip comments
  3. Grab custom hosts names
  4. To monitor the hosts and see what ports are open

Solutions: 
To skip comments
less /etc/hosts |grep ^[^#] 

To grab only custom hosts
|grep -o "\([[:space:]].*luxoft.com\)\||\([[:space:]].*other.domain.com\)"
where
-o - to display only matcher strings

To monitor the hosts and see what ports are open
|nmap -PN -oA hostsMonitoring -iL -
where
-PN     - use no pings
-oA      - out to the file
-iL -     - to get list of host from the input stream

Putting all together
less /etc/hosts |grep ^[^#] |grep -o "\([[:space:]].*luxoft.com\)\|\([[:space:]].*other.domain.com\)"|nmap -PN -oA hostsMonitoring -iL -

0 comments: