summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_dig.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index ae02a6e..ecd80a2 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -140,29 +140,32 @@ main (int argc, char **argv)
140 if (output == NULL || strlen (output) == 0) 140 if (output == NULL || strlen (output) == 0)
141 asprintf (&output, _(" Probably a non-existent host/domain")); 141 asprintf (&output, _(" Probably a non-existent host/domain"));
142 142
143 if (elapsed_time > critical_interval) 143 if (critical_interval > 0 && elapsed_time > critical_interval)
144 die (STATE_CRITICAL, 144 printf (_("DNS OK - %.3f seconds response time (%s)"), elapsed_time, output);
145 _("DNS OK - %.3f seconds response time (%s)|time=%ldus\n"),
146 elapsed_time, output, microsec);
147 145
148 else if (result == STATE_CRITICAL) 146 else if (result == STATE_CRITICAL)
149 printf (_("DNS CRITICAL - %s|time=%ldus\n"), output, microsec); 147 printf (_("DNS CRITICAL - %s"), output);
150 148
151 else if (elapsed_time > warning_interval) 149 else if (warning_interval > 0 && elapsed_time > warning_interval)
152 die (STATE_WARNING, 150 printf (_("DNS OK - %.3f seconds response time (%s)"), elapsed_time, output);
153 _("DNS OK - %.3f seconds response time (%s)|time=%ldus\n"),
154 elapsed_time, output, microsec);
155 151
156 else if (result == STATE_WARNING) 152 else if (result == STATE_WARNING)
157 printf (_("DNS WARNING - %s|time=%ldus\n"), output, microsec); 153 printf (_("DNS WARNING - %s"), output);
158 154
159 else if (result == STATE_OK) 155 else if (result == STATE_OK)
160 printf (_("DNS OK - %.3f seconds response time (%s)|time=%ldus\n"), 156 printf (_("DNS OK - %.3f seconds response time (%s)"),
161 elapsed_time, output, microsec); 157 elapsed_time, output);
162 158
163 else 159 else
164 printf (_("DNS problem - %s|time=%ldus\n"), output, microsec); 160 printf (_("DNS problem - %s"), output);
165 161
162 printf ("|%s\n",
163 perfdata("time", microsec, "us",
164 (warning_interval>0?TRUE:FALSE),
165 (int)1e6*warning_interval,
166 (critical_interval>0?TRUE:FALSE),
167 (int)1e6*critical_interval,
168 TRUE, 0, FALSE, 0));
166 return result; 169 return result;
167} 170}
168 171
@@ -180,7 +183,10 @@ process_arguments (int argc, char **argv)
180 int option = 0; 183 int option = 0;
181 static struct option longopts[] = { 184 static struct option longopts[] = {
182 {"hostname", required_argument, 0, 'H'}, 185 {"hostname", required_argument, 0, 'H'},
183 {"query_address", required_argument, 0, 'e'}, 186 {"query_address", required_argument, 0, 'l'},
187 {"warning", required_argument, 0, 'w'},
188 {"critical", required_argument, 0, 'c'},
189 {"timeout", required_argument, 0, 't'},
184 {"verbose", no_argument, 0, 'v'}, 190 {"verbose", no_argument, 0, 'v'},
185 {"version", no_argument, 0, 'V'}, 191 {"version", no_argument, 0, 'V'},
186 {"help", no_argument, 0, 'h'}, 192 {"help", no_argument, 0, 'h'},
@@ -191,7 +197,7 @@ process_arguments (int argc, char **argv)
191 return ERROR; 197 return ERROR;
192 198
193 while (1) { 199 while (1) {
194 c = getopt_long (argc, argv, "hVvt:l:H:", longopts, &option); 200 c = getopt_long (argc, argv, "hVvt:l:H:w:c:", longopts, &option);
195 201
196 if (c == -1 || c == EOF) 202 if (c == -1 || c == EOF)
197 break; 203 break;
@@ -213,7 +219,7 @@ process_arguments (int argc, char **argv)
213 usage2 (_("Invalid host name"), optarg); 219 usage2 (_("Invalid host name"), optarg);
214 } 220 }
215 break; 221 break;
216 case 'p': 222 case 'p': /* server port */
217 if (is_intpos (optarg)) { 223 if (is_intpos (optarg)) {
218 server_port = atoi (optarg); 224 server_port = atoi (optarg);
219 } 225 }
@@ -221,10 +227,10 @@ process_arguments (int argc, char **argv)
221 usage2 (_("Server port must be a nonnegative integer\n"), optarg); 227 usage2 (_("Server port must be a nonnegative integer\n"), optarg);
222 } 228 }
223 break; 229 break;
224 case 'l': /* username */ 230 case 'l': /* address to lookup */
225 query_address = optarg; 231 query_address = optarg;
226 break; 232 break;
227 case 'w': /* timeout */ 233 case 'w': /* warning */
228 if (is_intnonneg (optarg)) { 234 if (is_intnonneg (optarg)) {
229 warning_interval = atoi (optarg); 235 warning_interval = atoi (optarg);
230 } 236 }
@@ -232,7 +238,7 @@ process_arguments (int argc, char **argv)
232 usage2 (_("Warning interval must be a nonnegative integer\n"), optarg); 238 usage2 (_("Warning interval must be a nonnegative integer\n"), optarg);
233 } 239 }
234 break; 240 break;
235 case 'c': /* timeout */ 241 case 'c': /* critical */
236 if (is_intnonneg (optarg)) { 242 if (is_intnonneg (optarg)) {
237 critical_interval = atoi (optarg); 243 critical_interval = atoi (optarg);
238 } 244 }