check_tcp - how to check for immediately closed connection

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
naguser
Posts: 4
Joined: Tue Jul 30, 2013 6:47 am

check_tcp - how to check for immediately closed connection

Post by naguser »

I'm trying to test a telnet connection with check_tcp. When the end-service is not working, it still accepts connections, but closes them immediately. So check_tcp always passes.

Is there anyway to make check_tcp require a few seconds of open connection? I tried using delay parameter - no good. I tried sending commands and using expected text, but I'm not familiar with what commands to send and via a manual test connection, it doesn't really respond to anything.

Thanks.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: check_tcp - how to check for immediately closed connecti

Post by jdalrymple »

What does the TCP connection do? Generally you can use --send and expect some sort of reply. If your device is closing the connection you won't get that reply and that would be where you'd error out.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_tcp - how to check for immediately closed connecti

Post by ssax »

Code: Select all

-m, --maxbytes=INTEGER
    Close connection once more than this number of bytes are received
OR

Code: Select all

-e, --expect=STRING
    String to expect in server response (may be repeated)
I can't replicate your setup so you'll have to test it, I don't think there is any other way to do it without you modifying the code and recompiling or writing your own script.
Locked