- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script to check the connection to the server
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2006 06:41 AM
10-25-2006 06:41 AM
Script to check the connection to the server
telnet x.x.x.x 80
thanks,
hunki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2006 06:58 AM
10-25-2006 06:58 AM
Re: Script to check the connection to the server
got an idea.
There is a text based web browser called elinks.
Its an option in linux installations. It is very good for doing this type of work.
run it remotely against the web server and check return codes. Get a non-zero have the script pop someone and email.
also a wget for index.html is another good way and wget runs on hp-ux albeit sometimes badly.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2006 07:08 AM
10-25-2006 07:08 AM
Re: Script to check the connection to the server
http://bb4.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2006 07:09 AM
10-25-2006 07:09 AM
Re: Script to check the connection to the server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2006 07:09 AM
10-25-2006 07:09 AM
Re: Script to check the connection to the server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2006 07:30 AM
10-25-2006 07:30 AM
Re: Script to check the connection to the server
Personally, I would use nmap, nc, curl, or wget for this, but you asked for a script...
# cat mon_port.sh
#!/usr/bin/sh
HOST=$1
PORT=$2
{
telnet ${HOST} ${PORT} << _EOF_
exit
_EOF_
} > /tmp/telnet.$$.txt
if (! grep -q 'Connected' /tmp/telnet.$$.txt)
then
echo "${HOST}:${PORT} unreachable at $(date)" | mailx -m -s "${HOST}:${PORT} ALERT!" your@email.addr
fi
[ -f /tmp/telnet.$$.txt ] && rm /tmp/telnet.$$.txt
exit
# mon_port.sh www.google.com 80
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2006 08:08 AM
10-25-2006 08:08 AM
Re: Script to check the connection to the server
if (! grep -q 'Connected' /tmp/telnet.$$.txt)
any idea why its not able to find "!"
This is the error that I get:
!: not found
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2006 10:46 AM
10-25-2006 10:46 AM
Re: Script to check the connection to the server
ping xxxx.xxxx.xxxx.xxxx 80 -n 5> ping_file.txt
Then check ping_file.txt for reply.
Do this in a while loop.
while [ `date +%H` -lt 20 ]
do
echo "`date`" >> ping_file.txt
ping xxxx.xxxx.xxxx.xxxx 80 -n 5 >> ping_file.txt
echo "========================" >> ping_file.txt
grep 'bytes from' ping_file.txt
echo $? | read RC
If [ $RC -ne 0 ]
then
"Send some sort of notification."
exit 1
fi
done
The notification can be an error message, an email, whatever is your desire.
Regards,
-dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2006 12:18 AM
10-26-2006 12:18 AM
Re: Script to check the connection to the server
ICMP operates below the trasport layer at the network layer, so there is no notion of a port. 'ping x.x.x.x 80 -n 5' will send five, 80-byte packets to x.x.x.x.
Hunki,
Try this:
#!/usr/bin/sh
HOST=$1
typeset -i PORT=$2
typeset -i STAT=0
{
telnet ${HOST} ${PORT} << _EOF_
exit
_EOF_
} > /tmp/telnet.$$.txt &
sleep 5
if [[ "$(jobs|wc -l)" -gt "0" ]]
then
kill %$(jobs | awk 'NR==1 {print $1}' | tr -d '\[\]')
STAT=1
elif [[ "$(grep -q 'Connected' /tmp/telnet.$$.txt)" -eq "0" ]]
then
rm /tmp/telnet.$$.txt
exit ${STAT}
else
STAT=2
fi
echo "${HOST}:${PORT} unreachable at $(date)" | mailx -m -s "${HOST}:${PORT} ALERT!" your@email.addr
rm /tmp/telnet.$$.txt
exit ${STAT}
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2006 12:46 AM
10-26-2006 12:46 AM
Re: Script to check the connection to the server
though I wouldn't consider the plain telnet method the most appropiate for the job
(it's usually ok for a quick command line check if you have no thin agent at hand).
If you have a fairly recent Perl installed there comes with it a neat sample script of LWP API usage, which is called lwp-request.
Depending on your installation you might even have symlinks to it from GET, HEAD, POST,
but they aren't necessary.
For instance you could do a HEAD request for the index page of your webserver like
$ lwp-request -m head -H "Cache-Control: no-cache" http://localhost/
200 OK
Connection: close
Date: Thu, 26 Oct 2006 12:35:11 GMT
Accept-Ranges: bytes
ETag: "8f3d-2028-303d3cc0"
Server: Apache/2.0.55 HP-UX_Apache-based_Web_Server (Unix) DAV/2 PHP/5.0.4 mod_jk/1.2.10
Content-Length: 8232
Content-Type: text/html
Last-Modified: Fri, 10 Feb 2006 14:03:07 GMT
Client-Date: Thu, 26 Oct 2006 12:35:11 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
lwp-request has many options like if you need to authenticate or go over a proxy etc.
You can easily introduce your own custom HTTP headers like the no-cache attribute in the above example,
though it really only makes sense if you need to go over gateways such like a proxy.
The HTTP RFC demands those network devices to respect these headers.
You get a nice manpage if you issue "perldoc lwp-request".
If you want to do some serious monitoring I would suggest to set up a Nagios server.
The Nagios plug-ins include quite a good monitor called check_http which also allows all kind of HTTP options conceivable.
Nagios does the monitoring excellently with a sophisticated alerting and event handling system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2006 01:09 AM
10-26-2006 01:09 AM
Re: Script to check the connection to the server
I do this on my VMS system with a DCL script
which uses wget.
> Can you guys do it through a script. I am
> not really into installation at this point.
I'd prefer to do it the easy way, and I find
wget to be useful for other things, too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2006 09:44 AM
10-26-2006 09:44 AM
Re: Script to check the connection to the server
There is always the ndd command, albeit more cryptic to work with.
Since port 80 [hex e2e0] should be in a listen state, you could -
ndd -get /dev/tcp tcp_status | grep TCP_LISTEN | grep -i e2e0
A $? -ne 0 would give you a heads up.
Regards,
-dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2006 09:51 AM
10-26-2006 09:51 AM
Re: Script to check the connection to the server
Knowing that somone is LISTENing on a port is
much less useful than knowing that the server
will actually respond to a request.