[Nagiosplug-checkins] CVS: nagiosplug/plugins check_smtp.c,1.9.2.1,1.9.2.2
Karl DeBisschop
kdebisschop at users.sourceforge.net
Thu Mar 6 23:16:01 CET 2003
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv26035
Modified Files:
Tag: r1_3_0
check_smtp.c
Log Message:
whole timer loop was on the wrong side of connection close code
Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.2
diff -C2 -r1.9.2.1 -r1.9.2.2
*** check_smtp.c 5 Mar 2003 05:59:01 -0000 1.9.2.1
--- check_smtp.c 7 Mar 2003 07:15:40 -0000 1.9.2.2
***************
*** 80,84 ****
{
int sd;
! int result;
char buffer[MAX_INPUT_BUFFER] = "";
char *from_str = NULL;
--- 80,84 ----
{
int sd;
! int result = STATE_UNKNOWN;
char buffer[MAX_INPUT_BUFFER] = "";
char *from_str = NULL;
***************
*** 115,132 ****
if (result == STATE_OK) {
! /* watch for the SMTP connection string */
! result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
!
! /* strip the buffer of carriage returns */
! strip (buffer);
!
/* return a WARNING status if we couldn't read any data */
! if (result == -1) {
printf ("recv() failed\n");
result = STATE_WARNING;
}
-
else {
!
/* make sure we find the response we are looking for */
if (!strstr (buffer, server_expect)) {
--- 115,127 ----
if (result == STATE_OK) {
! /* watch for the SMTP connection string and */
/* return a WARNING status if we couldn't read any data */
! if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) {
printf ("recv() failed\n");
result = STATE_WARNING;
}
else {
! /* strip the buffer of carriage returns */
! strip (buffer);
/* make sure we find the response we are looking for */
if (!strstr (buffer, server_expect)) {
***************
*** 138,165 ****
result = STATE_WARNING;
}
-
- else {
-
- time (&end_time);
-
- result = STATE_OK;
-
- if (check_critical_time == TRUE
- && (end_time - start_time) > critical_time) result =
- STATE_CRITICAL;
- else if (check_warning_time == TRUE
- && (end_time - start_time) > warning_time) result =
- STATE_WARNING;
-
- if (verbose == TRUE)
- printf ("SMTP %s - %d sec. response time, %s\n",
- state_text (result), (int) (end_time - start_time), buffer);
-
- }
}
! /* close the connection */
!
! /* first send the HELO command */
send(sd, helocmd, strlen(helocmd), 0);
--- 133,139 ----
result = STATE_WARNING;
}
}
! /* send the HELO command */
send(sd, helocmd, strlen(helocmd), 0);
***************
*** 187,191 ****
alarm (0);
! printf ("SMTP %s - %d second response time\n", state_text (result), (int) (end_time - start_time));
return result;
--- 161,176 ----
alarm (0);
! time (&end_time);
!
! if (check_critical_time == TRUE && (end_time - start_time) > critical_time)
! result = STATE_CRITICAL;
! else if (check_warning_time == TRUE && (end_time - start_time) > warning_time)
! result = STATE_WARNING;
!
! if (verbose == TRUE)
! printf ("SMTP %s - %d sec. response time, %s\n",
! state_text (result), (int) (end_time - start_time), buffer);
! else
! printf ("SMTP %s - %d second response time\n", state_text (result), (int) (end_time - start_time));
return result;
More information about the Commits
mailing list