08-13-2014 07:49 PM
Hello all,
Has anyone had success with developing a script to test for an open port? For example, I'd like to use my router to ocasionally check if port 3389 is open on 192.168.1.1. I've scripted a few tests already, but this is the one thing that I haven't been very successful in completing.
Any and all suggestions / support are welcome. Thanks in advance to anyone who's able to assist.
Solved! Go to Solution.
08-14-2014 08:25 AM
Here's some simple EEM Tcl code that should work:
::cisco::eem::event_register_timer watchdog time 3600
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
if { [catch {socket 192.168.1.1 3389} result] } {
action_syslog msg "tcp/3389 on 192.168.1.1 is no longer open"
}
set fd $result
close $fd
action_syslog msg "tcp/3389 on 192.168.1.1 is open"
08-14-2014 08:25 AM
Here's some simple EEM Tcl code that should work:
::cisco::eem::event_register_timer watchdog time 3600
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
if { [catch {socket 192.168.1.1 3389} result] } {
action_syslog msg "tcp/3389 on 192.168.1.1 is no longer open"
}
set fd $result
close $fd
action_syslog msg "tcp/3389 on 192.168.1.1 is open"
08-14-2014 10:09 AM
Joseph,
As always, thank you very much for your effort and assistance on this.
I ran the following in tclsh and it worked great.
catch {socket 74.125.225.83 443} result
I had omitted another peice of the puzzle, but I was able to find the solution. I needed to source the socket request from a certain interface. Here is what I found:
catch {socket -myaddr 192.168.1.1 74.125.225.83 443} result
Thanks again!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide