summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7f01b73)
raw | patch | inline | side by side (parent: 7f01b73)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 7 Mar 2003 07:17:26 +0000 (07:17 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 7 Mar 2003 07:17:26 +0000 (07:17 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@373 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_smtp.c | patch | blob | history |
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index d8b90597c8ad3489a688faefab2ea6b63ede2447..8c0a246e594d5b56e53157ca723dee857965b5d0 100644 (file)
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
main (int argc, char **argv)
{
int sd;
- int result;
+ int result = STATE_UNKNOWN;
char buffer[MAX_INPUT_BUFFER] = "";
char *from_str = NULL;
char *helocmd = NULL;
/* we connected, so close connection before exiting */
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);
-
+ /* watch for the SMTP connection string and */
/* return a WARNING status if we couldn't read any data */
- if (result == -1) {
+ 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)) {
if (server_port == SMTP_PORT)
server_port);
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);
- else
- printf ("SMTP %s - %d second response time\n", state_text (result),
- (int) (end_time - start_time));
- }
}
- /* close the connection */
-
- /* first send the HELO command */
+ /* send the HELO command */
send(sd, helocmd, strlen(helocmd), 0);
/* allow for response to helo command to reach us */
/* reset the alarm */
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;
}