Forum Discussion

Joe_Tran's avatar
Joe_Tran
Icon for Advisor rankAdvisor
6 years ago

Collector Debug - TCP/Telnet command

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. 

8 Replies

Replies have been turned off for this discussion
  • 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"

  • 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)
    }

     

  • 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:

    /topic/1508-traceroute-configsources/

    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.

  • @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.