diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-12 22:36:35 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-12 22:36:35 +0200 |
commit | ffad261eabd2eceb945a604c6c4f95465a2dfcc3 (patch) | |
tree | 9296e2251ee852947cb3e8cd26a1f893f404bd23 /plugins/check_tcp.c | |
parent | 7573aa16169e80baec80440463a524e5f4e92911 (diff) | |
download | monitoring-plugins-ffad261eabd2eceb945a604c6c4f95465a2dfcc3.tar.gz |
check_tcp: Fix checks without --expect string
Commit e8044713d41f5ef1d9ce814df4a079d8f92306b0 broke check_tcp checks
without --expect string, this commit fixes that regression.
Diffstat (limited to 'plugins/check_tcp.c')
-rw-r--r-- | plugins/check_tcp.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 517b6b5d..e7342f35 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -289,6 +289,8 @@ main (int argc, char **argv) match_flags)) != NP_MATCH_RETRY) break; } + if (match == NP_MATCH_RETRY) + match = NP_MATCH_FAILURE; /* no data when expected, so return critical */ if (len == 0) @@ -320,7 +322,7 @@ main (int argc, char **argv) result = STATE_WARNING; /* did we get the response we hoped? */ - if(match != NP_MATCH_SUCCESS && result != STATE_CRITICAL) + if(match == NP_MATCH_FAILURE && result != STATE_CRITICAL) result = expect_mismatch_state; /* reset the alarm */ @@ -331,10 +333,10 @@ main (int argc, char **argv) * the response we were looking for. if-else */ printf("%s %s - ", SERVICE, state_text(result)); - if(match != NP_MATCH_SUCCESS && len && !(flags & FLAG_HIDE_OUTPUT)) + if(match == NP_MATCH_FAILURE && len && !(flags & FLAG_HIDE_OUTPUT)) printf("Unexpected response from host/socket: %s", status); else { - if(match != NP_MATCH_SUCCESS) + if(match == NP_MATCH_FAILURE) printf("Unexpected response from host/socket on "); else printf("%.3f second response time on ", elapsed_time); @@ -344,13 +346,13 @@ main (int argc, char **argv) printf("socket %s", server_address); } - if (match == NP_MATCH_SUCCESS && !(flags & FLAG_HIDE_OUTPUT) && len) + if (match != NP_MATCH_FAILURE && !(flags & FLAG_HIDE_OUTPUT) && len) printf (" [%s]", status); /* perf-data doesn't apply when server doesn't talk properly, * so print all zeroes on warn and crit. Use fperfdata since * localisation settings can make different outputs */ - if(match != NP_MATCH_SUCCESS) + if(match == NP_MATCH_FAILURE) printf ("|%s", fperfdata ("time", elapsed_time, "s", (flags & FLAG_TIME_WARN ? TRUE : FALSE), 0, |