• 1

Monitor arbitrary TCP port

Go to solution Solved by Jon Blake,


Greetings LM community.

We would like to monitor arbitrary TCP ports. The result we would like to achieve is a simple service is listening or not result.

Is this possible ?




Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0
  • LogicMonitor Staff

Hi Tom,

This is definitely possible - I am attaching the LM locator code for a "PortMulti"datasource. Once you've imported the datasource, navigate to a device, and select the dropdown next the the big blue 'Manage' button. In the dropdown there is an option to 'Add Monitored Instance' - see the attached screenshot for configuration parameters. For additional ports to monitor, repeat the process.

The datasource name will be 'PortMulti-' and the LM locator code is PX4D7W.








Edited by Kerry DeVilbiss
update images
  • Like 1
Link to post
Share on other sites
  • 0

Message when attempting to add the Datasource


503 : This LogicModule is currently undergoing security review. It will be available for import only after our engineers have validated the scripted elements.

Link to post
Share on other sites
  • 0

I had DIY'd a scripted Groovy datasource ages. Not sure if this was exactly what PortMulti- did, but the results should be similar. 

(host, port) = "##WILDVALUE##".split(':')
try {
    s = new Socket(host, port.toInteger())
    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

You would just then setup a datapoint to capture the exitCode and alert if it was > 0. 

  • Like 1
Link to post
Share on other sites
  • 0
  • Administrators

It's there. There's just a different search box for locator codes. (Yes, I know.) In the Exchange, in the top right, there's a locator search option. 

I have enhanced my version of this DS to include automatic discovery using this discovery script:

        target = it.tokenize("|")
        println(target[0] + "##" + target[1])
    return 0
} catch (Exception e){return 1}

Set a property called "pingmulti.targets" in the format:

This also allows the appliesTo to be simplified to just "pingmulti.targets". 

However, keep in mind that this still only pings from the collector. If you want to ping from the target device to some other destination, consider these two DSs. Only works on Windows or Linux, but that's usually what people are going for.

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.

Answer this question...

×   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.