diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index e850337b59405bdaa741253459e1611aca28e32e..08be937361082a3bf4c291c031230ff75103209d 100644 (file)
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
/*****************************************************************************
-*
+*
* Nagios check_dig plugin
-*
+*
* License: GPL
-* Copyright (c) 1999-2006 nagios-plugins team
-*
-* Last Modified: $Date$
-*
+* Copyright (c) 2002-2008 Nagios Plugins Development Team
+*
* Description:
-*
+*
* This file contains the check_dig plugin
-*
-* License Information:
-*
-* This program is free software; you can redistribute it and/or modify
+*
+*
+* 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
+* the Free Software Foundation, either version 3 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.
-*
-* $Id$
-*
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+*
*****************************************************************************/
/* Hackers note:
* because on some architectures those strings are in non-writable memory */
const char *progname = "check_dig";
-const char *revision = "$Revision$";
-const char *copyright = "2002-2006";
+const char *copyright = "2002-2008";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
#include "common.h"
char *record_type = "A";
char *expected_address = NULL;
char *dns_server = NULL;
+char *dig_args = "";
int verbose = FALSE;
int server_port = DEFAULT_PORT;
double warning_interval = UNDEFINED;
if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR)
usage_va(_("Cannot catch SIGALRM"));
+ /* Parse extra opts if any */
+ argv=np_extra_opts (&argc, argv, progname);
+
if (process_arguments (argc, argv) == ERROR)
usage_va(_("Could not parse arguments"));
/* get the command to run */
- asprintf (&command_line, "%s @%s -p %d %s -t %s",
- PATH_TO_DIG, dns_server, server_port, query_address, record_type);
+ asprintf (&command_line, "%s @%s -p %d %s -t %s %s",
+ PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args);
alarm (timeout_interval);
gettimeofday (&tv, NULL);
}
}
- if (result == STATE_UNKNOWN)
+ if (result == STATE_UNKNOWN) {
msg = (char *)_("No ANSWER SECTION found");
+ result = STATE_CRITICAL;
+ }
/* If we get anything on STDERR, at least set warning */
if(chld_err.buflen > 0) {
{"warning", required_argument, 0, 'w'},
{"critical", required_argument, 0, 'c'},
{"timeout", required_argument, 0, 't'},
+ {"dig-arguments", required_argument, 0, 'A'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
return ERROR;
while (1) {
- c = getopt_long (argc, argv, "hVvt:l:H:w:c:T:p:a:", longopts, &option);
+ c = getopt_long (argc, argv, "hVvt:l:H:w:c:T:p:a:A:", longopts, &option);
if (c == -1 || c == EOF)
break;
print_help ();
exit (STATE_OK);
case 'V': /* version */
- print_revision (progname, revision);
+ print_revision (progname, NP_VERSION);
exit (STATE_OK);
case 'H': /* hostname */
host_or_die(optarg);
usage_va(_("Timeout interval must be a positive integer - %s"), optarg);
}
break;
+ case 'A': /* dig arguments */
+ dig_args = strdup(optarg);
+ break;
case 'v': /* verbose */
verbose = TRUE;
break;
int
validate_arguments (void)
{
- return OK;
+ if (query_address != NULL)
+ return OK;
+ else
+ return ERROR;
}
asprintf (&myport, "%d", DEFAULT_PORT);
- print_revision (progname, revision);
+ print_revision (progname, NP_VERSION);
printf ("Copyright (c) 2000 Karl DeBisschop <kdebisschop@users.sourceforge.net>\n");
printf (COPYRIGHT, copyright, email);
printf (_(UT_HELP_VRSN));
+ printf (_(UT_EXTRA_OPTS));
+
printf (_(UT_HOST_PORT), 'p', myport);
- printf (" %s\n","-l, --lookup=STRING");
- printf (" %s\n",_("machine name to lookup"));
+ printf (" %s\n","-l, --query_address=STRING");
+ printf (" %s\n",_("Machine name to lookup"));
printf (" %s\n","-T, --record_type=STRING");
- printf (" %s\n",_("record type to lookup (default: A)"));
+ printf (" %s\n",_("Record type to lookup (default: A)"));
printf (" %s\n","-a, --expected_address=STRING");
- printf (" %s\n",_("an address expected to be in the answer section.if not set, uses whatever was in -l"));
+ printf (" %s\n",_("An address expected to be in the answer section. If not set, uses whatever"));
+ printf (" %s\n",_("was in -l"));
+ printf (" %s\n","-A, --dig-arguments=STRING");
+ printf (" %s\n",_("Pass STRING as argument(s) to dig"));
printf (_(UT_WARN_CRIT));
printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
printf (_(UT_VERBOSE));
+
+ printf ("\n");
+ printf ("%s\n", _("Examples:"));
+ printf (" %s\n", "check_dig -H DNSSERVER -l www.example.com -A \"+tcp\"");
+ printf (" %s\n", "This will send a tcp query to DNSSERVER for www.example.com");
+
+#ifdef NP_EXTRA_OPTS
+ printf ("\n");
+ printf ("%s\n", _("Notes:"));
+ printf (_(UT_EXTRA_OPTS_NOTES));
+#endif
+
printf (_(UT_SUPPORT));
}
print_usage (void)
{
printf (_("Usage:"));
- printf ("%s -H host -l lookup [-p <server port>] [-T <query type>]", progname);
- printf (" [-w <warning interval>] [-c <critical interval>] [-t <timeout>]");
- printf (" [-a <expected answer address>] [-v]\n");
+ printf ("%s -l <query_address> [-H <host>] [-p <server port>]\n", progname);
+ printf (" [-T <query type>] [-w <warning interval>] [-c <critical interval>]\n");
+ printf (" [-t <timeout>] [-a <expected answer address>] [-v]\n");
}