Sponsored Content
Top Forums Shell Programming and Scripting How to check if a Port is accepting connections. Post 302341855 by RiSk on Thursday 6th of August 2009 06:05:08 PM
Old 08-06-2009
netcat

nc -vz -w 10 ip port

just be aware that the [[:digit:]] will not work in hpux, nor do you really need it, you can take my bash code below and fill in your details.



Code:
#!/bin/bash

lolb=`awk '/[[:digit:]]/ { print $5}' /var/www/htdocs/vip/.form.php | cut -d \" -f 2 | grep [[:digit:]]`
EMAIL_TXT=/home/svcsuprt/email.txt
NEED_MAIL=0

# This is where we make the EMAIl_TXT data, first we remove the old one to ensure there is no munged data, 
# then add a header with some info in it.

cat /dev/null > /home/svcsuprt/email.txt
echo "Cannot connect the the following Load Balancers, please correct this asap as it impacts http://sitescope/vip" > $EMAIL_TXT
echo " " >> $EMAIL_TXT

# This is the main loop of the script that uses netcat to see if it can connect to 22, if it cannot, it goes in EMAIL_TXT

for ip in $lolb; 

        do /usr/bin/nc -vz -w 10 $ip 22;
                if [ $? -eq 1 ]
        then
                echo "$ip failed connectivity testing" >> $EMAIL_TXT; export NEED_MAIL=1
        fi; 
done;

## Send email

if [ ${NEED_MAIL} -eq 1 ]
        then
        cat /home/svcsuprt/email.txt | /bin/mailx -s "Load Balancer SSH test" email@tld.com

fi

 

10 More Discussions You Might Find Interesting

1. HP-UX

Oracle not accepting new connections

Hi UNIX guru's, Have recently upgraded Oracle from 8i to 10g on an HP-UX (RISC) 11.11 box. At least twice a day the database stops accepting incoming connections and the following errors are observed in the various logs. The box needs to be rebooted to get everything going again. The... (4 Replies)
Discussion started by: mat_cottrell
4 Replies

2. IP Networking

how can i check if port is busy or if someone is using it ?

Hello i have application that using ports , how can i check if the port im using is not captured by any applications? (1 Reply)
Discussion started by: umen
1 Replies

3. AIX

how to check status of various services and port?

How can i check which service is activated on my AIX Box? how one can check particular port is open or not (like ftp/telnet port)? I dont have admin rights (1 Reply)
Discussion started by: ashish4422
1 Replies

4. Shell Programming and Scripting

Check SMB-Connections (Resources in use?)

Hi, is it possible to check smb-connections of my server? I want to see, which files are opened from which station (ip). The command who only works local (via terminal). Regards. (4 Replies)
Discussion started by: inoxx
4 Replies

5. UNIX for Dummies Questions & Answers

How do you check whether a port currently being used?

Hi, Please help me out, how to check whether a port currently being used or not. is there any command which give the result? Thanks Rajesh (6 Replies)
Discussion started by: rajesh08
6 Replies

6. Shell Programming and Scripting

Script to check if Port is Active

is there a better way to check if a port is active on linux and sunos systems? this is currently what I'm using in my script: netstat -an | egrep -i "$PORT" i know this isn't the best way as there could be numbers in that output that has my port number in it but isn't necessarily a... (0 Replies)
Discussion started by: SkySmart
0 Replies

7. UNIX for Dummies Questions & Answers

Server has more TIME_WAIT connections in Apache(port 80)

Server has more TIME_WAIT connections in Apache(port 80) Hi, My webserver has 16GB of RAM and CentOS 5.5, Apache 2.2.3, It's shared webserver used of for webhosting. I have optmized the server as : <IfModule prefork.c>... (4 Replies)
Discussion started by: chandranjoy
4 Replies

8. Shell Programming and Scripting

Perl- check the port used

hi everybody; my code is cheking if a port is an actif or not with the cmd netstat -ln,I want first to enter the number of the port which I want to check it but I think that the value of $con in the second "if" is always "0" so the code give me always that the port is not used!!! ... (5 Replies)
Discussion started by: bassma
5 Replies

9. Red Hat

How to check port used for SSL?

I have RHEL 5.8 in our production environment. We are using SSL, my query is how to find the port used for SSL. In /etc/services, it shows 443 but when I give netstat -tulpn | grep 443 Or netstat -tulp | grep https I do not get any output. I hope, my question is clear of how to find... (4 Replies)
Discussion started by: RHCE
4 Replies

10. Shell Programming and Scripting

How to check the IP:PORT firewall uses?

I have my firewall process running # ps -ef | grep firewall root 21169 1 0 08:50 ? 00:00:00 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid I wish to know what ip : port number it is using. Can you please tell me how can i find out ? I tried the below command... (4 Replies)
Discussion started by: mohtashims
4 Replies
filetea(8)						      System Manager's Manual							filetea(8)

NAME
filetea - Web based file sharing service daemon SYNOPSIS
filetea [OPTIONS] DESCRIPTION
This manual page documents briefly the filetea command. FileTea is a Web service that provides instant and anonymous file-sharing using only a standard browser as client. Unlike traditional Web based file-sharing services, FileTea does not store files server-side. Instead, files are just routed on-the-fly from seeder to leecher, through the server. filetea is the service daemon that runs on a FileTea server. It handles peer synchronization, file routing and status reporting; and also acts as web-server for static HTML content when run in standalone mode. OPTIONS
-h, --help Display a brief summary of the command-line options and their default values. -c config, --conf=config Absolute path for the configuration file to use, default is /etc/filetea/filetea.conf. -D, --daemonize Run the service in the background. -p port, --http-port=port Port to listen on for plain HTTP service, overriding the value specified in configuration file. -P port, --https-port=port Port to listen on for secure HTTP service (https), overriding the value specified in configuration file. FILES
/etc/filetea/filetea.conf Filetea config file. AUTHOR
This manpage has been written by Eduardo Lima Mitev <elima@igalia.com> 2011-10-21 filetea(8)
All times are GMT -4. The time now is 09:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy