X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcheck_real.c;h=30424656ef411a3c3af0646865b7298e5de2d172;hb=3438df79d1fbf7d929467855ffe7b9f1c181c09e;hp=7cd17eea34c7f962ef22cdbcbadc190dc8f7c228;hpb=589d4664919638bedd6e2e1710c323887d19584a;p=nagiosplug.git diff --git a/plugins/check_real.c b/plugins/check_real.c index 7cd17ee..3042465 100644 --- a/plugins/check_real.c +++ b/plugins/check_real.c @@ -14,11 +14,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + $Id$ + ******************************************************************************/ const char *progname = "check_real"; const char *revision = "$Revision$"; -const char *copyright = "2000-2003"; +const char *copyright = "2000-2004"; const char *email = "nagiosplug-devel@lists.sourceforge.net"; #include "common.h" @@ -50,14 +52,11 @@ int verbose = FALSE; - - - int main (int argc, char **argv) { int sd; - int result; + int result = STATE_UNKNOWN; char buffer[MAX_INPUT_BUFFER]; char *status_line = NULL; @@ -65,8 +64,8 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - if (process_arguments (argc, argv) != OK) - usage (_("Incorrect arguments supplied\n")); + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); @@ -251,9 +250,6 @@ main (int argc, char **argv) - - - /* process command-line arguments */ int process_arguments (int argc, char **argv) @@ -303,7 +299,7 @@ process_arguments (int argc, char **argv) else if (is_host (optarg)) server_address = optarg; else - usage (_("Invalid host name\n")); + usage2 (_("Invalid hostname/address"), optarg); break; case 'e': /* string to expect in response header */ server_expect = optarg; @@ -316,7 +312,7 @@ process_arguments (int argc, char **argv) server_port = atoi (optarg); } else { - usage (_("Server port must be a positive integer\n")); + usage4 (_("Port must be a positive integer")); } break; case 'w': /* warning time threshold */ @@ -325,7 +321,7 @@ process_arguments (int argc, char **argv) check_warning_time = TRUE; } else { - usage (_("Warning time must be a nonnegative integer\n")); + usage4 (_("Warning time must be a positive integer")); } break; case 'c': /* critical time threshold */ @@ -334,7 +330,7 @@ process_arguments (int argc, char **argv) check_critical_time = TRUE; } else { - usage (_("Critical time must be a nonnegative integer\n")); + usage4 (_("Critical time must be a nonnegative integer")); } break; case 'v': /* verbose */ @@ -345,17 +341,19 @@ process_arguments (int argc, char **argv) socket_timeout = atoi (optarg); } else { - usage (_("Time interval must be a nonnegative integer\n")); + usage4 (_("Time interval must be a nonnegative integer")); } break; case 'V': /* version */ - print_revision (progname, "$Revision$"); + print_revision (progname, revision); exit (STATE_OK); case 'h': /* help */ print_help (); exit (STATE_OK); case '?': /* usage */ - usage (_("Invalid argument\n")); + printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); + print_usage (); + exit (STATE_UNKNOWN); } } @@ -365,7 +363,7 @@ process_arguments (int argc, char **argv) server_address = argv[c++]; } else { - usage (_("Invalid host name")); + usage2 (_("Invalid hostname/address"), argv[c]); } } @@ -383,8 +381,6 @@ process_arguments (int argc, char **argv) - - int validate_arguments (void) { @@ -393,18 +389,16 @@ validate_arguments (void) - - void print_help (void) { char *myport; asprintf (&myport, "%d", PORT); - print_revision (progname, "$Revision$"); + print_revision (progname, revision); - printf (_("Copyright (c) 1999 Pedro Leite \n")); - printf (_(COPYRIGHT), copyright, email); + printf ("Copyright (c) 1999 Pedro Leite \n"); + printf (COPYRIGHT, copyright, email); printf (_("This plugin tests the REAL service on the specified host.\n\n")); @@ -439,13 +433,10 @@ values.")); - - void print_usage (void) { printf ("\ Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\ - [-t timeout] [-v]\n", progname); - printf (_(UT_HLP_VRS), progname, progname); + [-t timeout] [-v]\n", progname); }