Service(Port) Monitoring with Telnet/Ftp/NC(netcat)
pb <[email protected]>
| Newsgroups | gmane.linux.redhat.piranha |
|---|---|
| Message-ID | <[email protected]> |
--- Sébastien Bonnet <[email protected]> wrote: > There's something call nc (for netcat) which might > be way more suitable. Hi all, Ok I modified my port checking shell script to have telnet, ftp, and nc (netcat) options. Just use the script below and comment out the TEST= line you want. I found that nc works the best to avoid unwanted errors logged in your mail or message log. You can also replace "25" with $2 and run the script with two parameters, host and portnumber, but then depending on port, you have to replace your printf string with valid commands, and your grep string with proper keyword. In all honest, only nc was able to correctly pass the commands (ftp and telnet lines did not accept the commands from printf). If you use nc, you need to install the nc or netcat rpm. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #!/bin/sh ## PB's Nutshell Howto - Custom Port Monitoring. TEST=`printf "helo foobar.com\nmail from: [email protected]\nquit\n" | nc -v $1 25 2>/dev/null |grep -i "sender ok"|wc -l` > /dev/null 2>&1 #TEST=`printf "quit\n" | ftp -v -u $1 25 2>/dev/null |grep -i "connected"|wc -l` > /dev/null 2>&1 #TEST=`printf "quit\n" | telnet $1 25 2>/dev/null |grep -i "connected"|wc -l` > /dev/null 2>&1 if [ $TEST -eq 1 ]; then echo "OK" else echo "FAIL" fi ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com