summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 62291c1)
raw | patch | inline | side by side (parent: 62291c1)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Sat, 9 Nov 2002 04:22:22 +0000 (04:22 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Sat, 9 Nov 2002 04:22:22 +0000 (04:22 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@181 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_by_ssh.c | patch | blob | history | |
plugins/check_dig.c | patch | blob | history | |
plugins/check_ping.c | patch | blob | history | |
plugins/check_time.c | patch | blob | history |
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 97c8672fa668135f854243c68b01cb4528e08e1a..93f1ead53173db1d348db022c74b393f0de4d276 100644 (file)
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
#define PROGNAME "check_by_ssh"
int process_arguments (int, char **);
-int call_getopt (int, char **);
int validate_arguments (void);
void print_help (char *command_name);
void print_usage (void);
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 384b380b8ba5afa291e7847ca8257f349b700639..fcd5d0ddfbadfaf83af9baf4bcb470fb5ac0b06a 100644 (file)
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
/******************************************************************************
-*
-* check_dig.c
-*
-* Program: dig plugin for Nagios
-* License: GPL
-* Copyright (c) 2000
-*
-* $Id$
-*
-*****************************************************************************/
+ *
+ * Program: SNMP plugin for Nagios
+ * License: GPL
+ *
+ * License Information:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *****************************************************************************/
#include "config.h"
#include "common.h"
#include "popen.h"
#define PROGNAME "check_dig"
+#define REVISION "$Revision$"
+#define COPYRIGHT "2000-2002"
+#define AUTHOR "Karl DeBisschop"
+#define EMAIL "karl@debisschop.net"
+#define SUMMARY "Test the DNS service on the specified host using dig\n"
int process_arguments (int, char **);
int call_getopt (int, char **);
{
int c;
- if (argc < 2)
- return ERROR;
-
-
- c = 0;
- while ((c += (call_getopt (argc - c, &argv[c]))) < argc) {
-
- if (is_option (argv[c]))
- continue;
-
- if (dns_server == NULL) {
- if (is_host (argv[c])) {
- dns_server = argv[c];
- }
- else {
- usage ("Invalid host name");
- }
- }
- }
-
- if (dns_server == NULL)
- dns_server = strscpy (NULL, "127.0.0.1");
-
- return validate_arguments ();
-}
-
-
-
-
-
-
-int
-call_getopt (int argc, char **argv)
-{
- int c, i = 0;
-
#ifdef HAVE_GETOPT_H
int option_index = 0;
static struct option long_options[] = {
};
#endif
+ if (argc < 2)
+ return ERROR;
+
while (1) {
#ifdef HAVE_GETOPT_H
- c = getopt_long (argc, argv, "+hVvt:l:H:", long_options, &option_index);
+ c = getopt_long (argc, argv, "hVvt:l:H:", long_options, &option_index);
#else
- c = getopt (argc, argv, "+?hVvt:l:H:");
+ c = getopt (argc, argv, "hVvt:l:H:");
#endif
- i++;
-
- if (c == -1 || c == EOF || c == 1)
+ if (c == -1 || c == EOF)
break;
switch (c) {
- case 't':
- case 'l':
- case 'H':
- i++;
- }
-
- switch (c) {
+ case '?': /* help */
+ usage3 ("Unknown argument", optopt);
case 'H': /* hostname */
if (is_host (optarg)) {
dns_server = optarg;
case 'h': /* help */
print_help ();
exit (STATE_OK);
- case '?': /* help */
- usage ("Invalid argument\n");
}
}
- return i;
+
+ c = optind;
+ if (dns_server == NULL) {
+ if (c < argc) {
+ if (is_host (argv[c])) {
+ dns_server = argv[c];
+ }
+ else {
+ usage ("Invalid host name");
+ }
+ }
+ else {
+ dns_server = strscpy (NULL, "127.0.0.1");
+ }
+ }
+
+ return validate_arguments ();
}
{
print_revision (PROGNAME, "$Revision$");
printf
- ("Copyright (c) 2000 Karl DeBisschop\n\n"
- "This plugin use dig to test the DNS service on the specified host.\n\n");
+ ("Copyright (c) %s %s <%s>\n\n%s\n",
+ COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
print_usage ();
printf
("\nOptions:\n"
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 74aa3b7c6a03f3b7a6992649026214ee8b477a8e..df1d9eb2025c4ec4750538cafce3add20491bd65 100644 (file)
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
#define WARN_DUPLICATES "DUPLICATES FOUND! "
int process_arguments (int, char **);
-int call_getopt (int, char **);
int get_threshold (char *, float *, int *);
int validate_arguments (void);
int run_ping (char *);
diff --git a/plugins/check_time.c b/plugins/check_time.c
index 86c414e2c413853210e7670121f13fb183df4fb4..c38178052d6434b8ba5790520efadd00b3eea4c5 100644 (file)
--- a/plugins/check_time.c
+++ b/plugins/check_time.c
#include "utils.h"
#define PROGNAME "check_time"
+#define REVISION "$Revision$"
+#define COPYRIGHT "1999-2002"
+#define AUTHOR "Ethan Galstad"
+#define EMAIL "nagios@nagios.org"
+#define SUMMARY "Check time on the specified host.\n"
#define TIME_PORT 37
#define UNIX_EPOCH 2208988800UL
int process_arguments (int, char **);
-int call_getopt (int, char **);
void print_usage (void);
void print_help (void);
server_address, server_port);
}
- /* watch for the FTP connection string */
+ /* watch for the connection string */
result = recv (sd, &raw_server_time, sizeof (raw_server_time), 0);
/* close the connection */
{
int c;
- if (argc < 2)
- usage ("\n");
-
- for (c = 1; c < argc; c++) {
- if (strcmp ("-to", argv[c]) == 0)
- strcpy (argv[c], "-t");
- else if (strcmp ("-wd", argv[c]) == 0)
- strcpy (argv[c], "-w");
- else if (strcmp ("-cd", argv[c]) == 0)
- strcpy (argv[c], "-c");
- else if (strcmp ("-wt", argv[c]) == 0)
- strcpy (argv[c], "-W");
- else if (strcmp ("-ct", argv[c]) == 0)
- strcpy (argv[c], "-C");
- }
-
- c = 0;
- while ((c += call_getopt (argc - c, &argv[c])) < argc) {
-
- if (is_option (argv[c]))
- continue;
-
- if (server_address == NULL) {
- if (argc > c) {
- if (is_host (argv[c]) == FALSE)
- usage ("Invalid host name/address\n");
- server_address = argv[c];
- }
- else {
- usage ("Host name was not supplied\n");
- }
- }
- }
-
- return OK;
-}
-
-
-
-
-
-int
-call_getopt (int argc, char **argv)
-{
- int c, i = 0;
-
#ifdef HAVE_GETOPT_H
int option_index = 0;
static struct option long_options[] = {
};
#endif
+ if (argc < 2)
+ usage ("\n");
+
+ for (c = 1; c < argc; c++) {
+ if (strcmp ("-to", argv[c]) == 0)
+ strcpy (argv[c], "-t");
+ else if (strcmp ("-wd", argv[c]) == 0)
+ strcpy (argv[c], "-w");
+ else if (strcmp ("-cd", argv[c]) == 0)
+ strcpy (argv[c], "-c");
+ else if (strcmp ("-wt", argv[c]) == 0)
+ strcpy (argv[c], "-W");
+ else if (strcmp ("-ct", argv[c]) == 0)
+ strcpy (argv[c], "-C");
+ }
+
while (1) {
#ifdef HAVE_GETOPT_H
c =
- getopt_long (argc, argv, "+hVH:w:c:W:C:p:t:", long_options,
+ getopt_long (argc, argv, "hVH:w:c:W:C:p:t:", long_options,
&option_index);
#else
- c = getopt (argc, argv, "+hVH:w:c:W:C:p:t:");
+ c = getopt (argc, argv, "hVH:w:c:W:C:p:t:");
#endif
- i++;
-
- if (c == -1 || c == EOF || c == 1)
+ if (c == -1 || c == EOF)
break;
- switch (c) {
- case 'H':
- case 'w':
- case 'c':
- case 'W':
- case 'C':
- case 'p':
- case 't':
- i++;
- }
-
switch (c) {
case '?': /* print short usage statement if args not parsable */
- printf ("%s: Unknown argument: %s\n\n", my_basename (argv[0]), optarg);
- print_usage ();
- exit (STATE_UNKNOWN);
+ usage3 ("Unknown argument", optopt);
case 'h': /* help */
print_help ();
exit (STATE_OK);
case 'V': /* version */
- print_revision (my_basename (argv[0]), "$Revision$");
+ print_revision (PROGNAME, REVISION);
exit (STATE_OK);
case 'H': /* hostname */
if (is_host (optarg) == FALSE)
break;
}
}
- return i;
+
+ c = optind;
+ if (server_address == NULL) {
+ if (argc > c) {
+ if (is_host (argv[c]) == FALSE)
+ usage ("Invalid host name/address\n");
+ server_address = argv[c];
+ }
+ else {
+ usage ("Host name was not supplied\n");
+ }
+ }
+
+ return OK;
}
print_usage (void)
{
printf
- ("Usage: check_time -H <host_address> [-p port] [-w variance] [-c variance]\n"
- " [-W connect_time] [-C connect_time] [-t timeout]\n");
+ ("Usage:\n"
+ " %s -H <host_address> [-p port] [-w variance] [-c variance]\n"
+ " [-W connect_time] [-C connect_time] [-t timeout]\n"
+ " %s (-h | --help) for detailed help\n"
+ " %s (-V | --version) for version information\n",
+ PROGNAME, PROGNAME, PROGNAME);
}
void
print_help (void)
{
- print_revision (PROGNAME, "$Revision$");
+ print_revision (PROGNAME, REVISION);
printf
- ("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
- "This plugin connects to a time port on the specified host.\n\n");
+ ("Copyright (c) %s %s <%s>\n\n%s\n",
+ COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
print_usage ();
printf
("Options:\n"