diff options
| author | Holger Weiss <hweiss@users.sourceforge.net> | 2009-04-22 00:44:15 +0200 |
|---|---|---|
| committer | Holger Weiss <hweiss@users.sourceforge.net> | 2009-04-22 00:47:47 +0200 |
| commit | ff8b447e14451b01d3823393c74e1521e5d4cf9f (patch) | |
| tree | 1a68718ff109dfcbdc01c97e543870293040e24e /plugins/check_dig.c | |
| parent | 92bb86c484c3d52c5ffdfa790f7a5acf68edcc36 (diff) | |
| download | monitoring-plugins-ff8b447e14451b01d3823393c74e1521e5d4cf9f.tar.gz | |
Convert plugins to use the new output functionshw/output/plugins
*** THIS COMMIT WILL BE MODIFIED IN THE FUTURE! ****
Convert some of the C plugins to use the new "configurable output
functions".
Diffstat (limited to 'plugins/check_dig.c')
| -rw-r--r-- | plugins/check_dig.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index e850337b..77bc9b79 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
| @@ -59,7 +59,6 @@ char *query_address = NULL; | |||
| 59 | char *record_type = "A"; | 59 | char *record_type = "A"; |
| 60 | char *expected_address = NULL; | 60 | char *expected_address = NULL; |
| 61 | char *dns_server = NULL; | 61 | char *dns_server = NULL; |
| 62 | int verbose = FALSE; | ||
| 63 | int server_port = DEFAULT_PORT; | 62 | int server_port = DEFAULT_PORT; |
| 64 | double warning_interval = UNDEFINED; | 63 | double warning_interval = UNDEFINED; |
| 65 | double critical_interval = UNDEFINED; | 64 | double critical_interval = UNDEFINED; |
| @@ -77,6 +76,7 @@ main (int argc, char **argv) | |||
| 77 | double elapsed_time; | 76 | double elapsed_time; |
| 78 | int result = STATE_UNKNOWN; | 77 | int result = STATE_UNKNOWN; |
| 79 | 78 | ||
| 79 | np_set_mynames(argv[0], "DNS"); | ||
| 80 | setlocale (LC_ALL, ""); | 80 | setlocale (LC_ALL, ""); |
| 81 | bindtextdomain (PACKAGE, LOCALEDIR); | 81 | bindtextdomain (PACKAGE, LOCALEDIR); |
| 82 | textdomain (PACKAGE); | 82 | textdomain (PACKAGE); |
| @@ -95,13 +95,11 @@ main (int argc, char **argv) | |||
| 95 | alarm (timeout_interval); | 95 | alarm (timeout_interval); |
| 96 | gettimeofday (&tv, NULL); | 96 | gettimeofday (&tv, NULL); |
| 97 | 97 | ||
| 98 | if (verbose) { | 98 | np_verbatim(command_line); |
| 99 | printf ("%s\n", command_line); | 99 | if(expected_address != NULL) { |
| 100 | if(expected_address != NULL) { | 100 | np_verbose(_("Looking for: '%s'"), expected_address); |
| 101 | printf (_("Looking for: '%s'\n"), expected_address); | 101 | } else { |
| 102 | } else { | 102 | np_verbose(_("Looking for: '%s'"), query_address); |
| 103 | printf (_("Looking for: '%s'\n"), query_address); | ||
| 104 | } | ||
| 105 | } | 103 | } |
| 106 | 104 | ||
| 107 | /* run the command */ | 105 | /* run the command */ |
| @@ -117,8 +115,7 @@ main (int argc, char **argv) | |||
| 117 | /* loop through the whole 'ANSWER SECTION' */ | 115 | /* loop through the whole 'ANSWER SECTION' */ |
| 118 | for(; i < chld_out.lines; i++) { | 116 | for(; i < chld_out.lines; i++) { |
| 119 | /* get the host address */ | 117 | /* get the host address */ |
| 120 | if (verbose) | 118 | np_verbatim(chld_out.line[i]); |
| 121 | printf ("%s\n", chld_out.line[i]); | ||
| 122 | 119 | ||
| 123 | if (strstr (chld_out.line[i], (expected_address == NULL ? query_address : expected_address)) != NULL) { | 120 | if (strstr (chld_out.line[i], (expected_address == NULL ? query_address : expected_address)) != NULL) { |
| 124 | msg = chld_out.line[i]; | 121 | msg = chld_out.line[i]; |
| @@ -165,8 +162,9 @@ main (int argc, char **argv) | |||
| 165 | else if (warning_interval > UNDEFINED && elapsed_time > warning_interval) | 162 | else if (warning_interval > UNDEFINED && elapsed_time > warning_interval) |
| 166 | result = STATE_WARNING; | 163 | result = STATE_WARNING; |
| 167 | 164 | ||
| 168 | printf ("DNS %s - %.3f seconds response time (%s)|%s\n", | 165 | np_die(result, |
| 169 | state_text (result), elapsed_time, | 166 | "%.3f seconds response time (%s)|%s\n", |
| 167 | elapsed_time, | ||
| 170 | msg ? msg : _("Probably a non-existent host/domain"), | 168 | msg ? msg : _("Probably a non-existent host/domain"), |
| 171 | fperfdata("time", elapsed_time, "s", | 169 | fperfdata("time", elapsed_time, "s", |
| 172 | (warning_interval>UNDEFINED?TRUE:FALSE), | 170 | (warning_interval>UNDEFINED?TRUE:FALSE), |
| @@ -174,7 +172,6 @@ main (int argc, char **argv) | |||
| 174 | (critical_interval>UNDEFINED?TRUE:FALSE), | 172 | (critical_interval>UNDEFINED?TRUE:FALSE), |
| 175 | critical_interval, | 173 | critical_interval, |
| 176 | TRUE, 0, FALSE, 0)); | 174 | TRUE, 0, FALSE, 0)); |
| 177 | return result; | ||
| 178 | } | 175 | } |
| 179 | 176 | ||
| 180 | 177 | ||
| @@ -257,7 +254,7 @@ process_arguments (int argc, char **argv) | |||
| 257 | } | 254 | } |
| 258 | break; | 255 | break; |
| 259 | case 'v': /* verbose */ | 256 | case 'v': /* verbose */ |
| 260 | verbose = TRUE; | 257 | np_increase_verbosity(1); |
| 261 | break; | 258 | break; |
| 262 | case 'T': | 259 | case 'T': |
| 263 | record_type = optarg; | 260 | record_type = optarg; |
