diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | plugins/check_smtp.c | 30 |
2 files changed, 27 insertions, 4 deletions
@@ -7,6 +7,7 @@ This file documents the major additions and syntax changes between releases. | |||
7 | check_http now uses standard threshold functions (enables floating point and ranges) | 7 | check_http now uses standard threshold functions (enables floating point and ranges) |
8 | check_http now checks for and prints the certificate cn (hostname) in SSL certificate checks (Stéphane Urbanovski) | 8 | check_http now checks for and prints the certificate cn (hostname) in SSL certificate checks (Stéphane Urbanovski) |
9 | Add perfdata to check_ssh (#3244097 - Marco Beck) | 9 | Add perfdata to check_ssh (#3244097 - Marco Beck) |
10 | New option to check_smtp to ignore failures when sending QUIT (#3358348 - Duncan Ferguson) | ||
10 | 11 | ||
11 | FIXES | 12 | FIXES |
12 | Fix check_disk free space calculation if blocksizes differ within a disk group (Bekar - #2973603) | 13 | Fix check_disk free space calculation if blocksizes differ within a disk group (Bekar - #2973603) |
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index ed491638..6c5994c0 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
@@ -114,6 +114,7 @@ enum { | |||
114 | TCP_PROTOCOL = 1, | 114 | TCP_PROTOCOL = 1, |
115 | UDP_PROTOCOL = 2, | 115 | UDP_PROTOCOL = 2, |
116 | }; | 116 | }; |
117 | int ignore_send_quit_failure = FALSE; | ||
117 | 118 | ||
118 | 119 | ||
119 | int | 120 | int |
@@ -129,6 +130,9 @@ main (int argc, char **argv) | |||
129 | char *error_msg = ""; | 130 | char *error_msg = ""; |
130 | struct timeval tv; | 131 | struct timeval tv; |
131 | 132 | ||
133 | /* Catch pipe errors in read/write - sometimes occurs when writing QUIT */ | ||
134 | (void) signal (SIGPIPE, SIG_IGN); | ||
135 | |||
132 | setlocale (LC_ALL, ""); | 136 | setlocale (LC_ALL, ""); |
133 | bindtextdomain (PACKAGE, LOCALEDIR); | 137 | bindtextdomain (PACKAGE, LOCALEDIR); |
134 | textdomain (PACKAGE); | 138 | textdomain (PACKAGE); |
@@ -476,6 +480,7 @@ process_arguments (int argc, char **argv) | |||
476 | {"help", no_argument, 0, 'h'}, | 480 | {"help", no_argument, 0, 'h'}, |
477 | {"starttls",no_argument,0,'S'}, | 481 | {"starttls",no_argument,0,'S'}, |
478 | {"certificate",required_argument,0,'D'}, | 482 | {"certificate",required_argument,0,'D'}, |
483 | {"ignore-quit-failure",no_argument,0,'q'}, | ||
479 | {0, 0, 0, 0} | 484 | {0, 0, 0, 0} |
480 | }; | 485 | }; |
481 | 486 | ||
@@ -492,7 +497,7 @@ process_arguments (int argc, char **argv) | |||
492 | } | 497 | } |
493 | 498 | ||
494 | while (1) { | 499 | while (1) { |
495 | c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:", | 500 | c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", |
496 | longopts, &option); | 501 | longopts, &option); |
497 | 502 | ||
498 | if (c == -1 || c == EOF) | 503 | if (c == -1 || c == EOF) |
@@ -579,6 +584,9 @@ process_arguments (int argc, char **argv) | |||
579 | case 'v': /* verbose */ | 584 | case 'v': /* verbose */ |
580 | verbose++; | 585 | verbose++; |
581 | break; | 586 | break; |
587 | case 'q': | ||
588 | ignore_send_quit_failure++; /* ignore problem sending QUIT */ | ||
589 | break; | ||
582 | case 't': /* timeout */ | 590 | case 't': /* timeout */ |
583 | if (is_intnonneg (optarg)) { | 591 | if (is_intnonneg (optarg)) { |
584 | socket_timeout = atoi (optarg); | 592 | socket_timeout = atoi (optarg); |
@@ -662,8 +670,20 @@ void | |||
662 | smtp_quit(void) | 670 | smtp_quit(void) |
663 | { | 671 | { |
664 | int bytes; | 672 | int bytes; |
673 | int n; | ||
674 | |||
675 | n = my_send(SMTP_QUIT, strlen(SMTP_QUIT)); | ||
676 | if(n < 0) { | ||
677 | if(ignore_send_quit_failure) { | ||
678 | if(verbose) { | ||
679 | printf(_("Connection closed by server before sending QUIT command\n")); | ||
680 | } | ||
681 | return; | ||
682 | } | ||
683 | die (STATE_UNKNOWN, | ||
684 | _("Connection closed by server before sending QUIT command\n")); | ||
685 | } | ||
665 | 686 | ||
666 | my_send(SMTP_QUIT, strlen(SMTP_QUIT)); | ||
667 | if (verbose) | 687 | if (verbose) |
668 | printf(_("sent %s\n"), "QUIT"); | 688 | printf(_("sent %s\n"), "QUIT"); |
669 | 689 | ||
@@ -797,7 +817,9 @@ print_help (void) | |||
797 | printf (" %s\n", _("SMTP AUTH username")); | 817 | printf (" %s\n", _("SMTP AUTH username")); |
798 | printf (" %s\n", "-P, --authpass=STRING"); | 818 | printf (" %s\n", "-P, --authpass=STRING"); |
799 | printf (" %s\n", _("SMTP AUTH password")); | 819 | printf (" %s\n", _("SMTP AUTH password")); |
800 | 820 | printf (" %s\n", "-q, --ignore-quit-failure"); | |
821 | printf (" %s\n", _("Ignore failure when sending QUIT command to server")); | ||
822 | |||
801 | printf (UT_WARN_CRIT); | 823 | printf (UT_WARN_CRIT); |
802 | 824 | ||
803 | printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | 825 | printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); |
@@ -821,6 +843,6 @@ print_usage (void) | |||
821 | printf ("%s\n", _("Usage:")); | 843 | printf ("%s\n", _("Usage:")); |
822 | printf ("%s -H host [-p port] [-e expect] [-C command] [-f from addr]", progname); | 844 | printf ("%s -H host [-p port] [-e expect] [-C command] [-f from addr]", progname); |
823 | printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout]\n"); | 845 | printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout]\n"); |
824 | printf ("[-F fqdn] [-S] [-D days] [-v] [-4|-6]\n"); | 846 | printf ("[-F fqdn] [-S] [-D days] [-v] [-4|-6] [-q]\n"); |
825 | } | 847 | } |
826 | 848 | ||