Joe Tran

Collector Debug - TCP/Telnet command

Recommended Posts

I would like to see a !tcp <host> <port> OR a !telnet <host> <port> like command in the Collector Debug utility. It should return back the connection status and response time. 

  • Upvote 1

Share this post


Link to post
Share on other sites

A workaround using the !groovy command:

def sout = new StringBuilder();
def serr = new StringBuilder();

// Shell command for your OS
def proc = 'cmd.exe /c tracert www.google.com'.execute();

proc.consumeProcessOutput(sout, serr);

// Adjust timeout as needed
proc.waitForOrKill(20 * 1000);

println "out> $sout err> $serr"

  • Upvote 2

Share this post


Link to post
Share on other sites

Since we're posting !groovy workarounds---here is one I'm using for telnet: 

hostname = 'internal.server.local'
port = 22
try {
    s = new Socket(hostname, port)
    println "Connected to $hostname on port $port"
    s.close()
    return(0)
} catch (ConnectException ce) {
    println ce.toString()
    return(1)
} catch (BindException be) {
    println be.toString()
    return(4)
} catch (NoRouteToHostException re) {
    println re.toString()
    return(2)
} catch (PortUnreachableException pe) {
    println pe.toString()
    return(3)
} catch (Exception e) {
    println e.toString()
    return(5)
}

 

Edited by Joe Tran
word

Share this post


Link to post
Share on other sites
On 22/08/2018 at 9:31 PM, Joe Williams said:

To tag on !traceroute or !tracert would be a nice addition as well.

 

@Joe Williams there is a traceroute ConfigSource, if you have LM Config:

It's not a debug command (obviously!) but you can lift the groovy out of it and use it via the debug window and the !groovy command as a workaround in the meantime.

Share this post


Link to post
Share on other sites

@Mosh it's not a core ConfigSource, just something I threw together on the side. Follow the link above to the thread and you'll find the locator ID which you can use to get the ConfigSource from the Exchange.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.