diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 6db38e8..ea7a673 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -100,7 +100,9 @@ char *user_agent; | |||
100 | int server_url_length; | 100 | int server_url_length; |
101 | int server_expect_yn = 0; | 101 | int server_expect_yn = 0; |
102 | char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; | 102 | char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; |
103 | char header_expect[MAX_INPUT_BUFFER] = ""; | ||
103 | char string_expect[MAX_INPUT_BUFFER] = ""; | 104 | char string_expect[MAX_INPUT_BUFFER] = ""; |
105 | char output_header_search[30] = ""; | ||
104 | char output_string_search[30] = ""; | 106 | char output_string_search[30] = ""; |
105 | char *warning_thresholds = NULL; | 107 | char *warning_thresholds = NULL; |
106 | char *critical_thresholds = NULL; | 108 | char *critical_thresholds = NULL; |
@@ -205,6 +207,7 @@ process_arguments (int argc, char **argv) | |||
205 | {"port", required_argument, 0, 'p'}, | 207 | {"port", required_argument, 0, 'p'}, |
206 | {"authorization", required_argument, 0, 'a'}, | 208 | {"authorization", required_argument, 0, 'a'}, |
207 | {"proxy_authorization", required_argument, 0, 'b'}, | 209 | {"proxy_authorization", required_argument, 0, 'b'}, |
210 | {"header-string", required_argument, 0, 'd'}, | ||
208 | {"string", required_argument, 0, 's'}, | 211 | {"string", required_argument, 0, 's'}, |
209 | {"expect", required_argument, 0, 'e'}, | 212 | {"expect", required_argument, 0, 'e'}, |
210 | {"regex", required_argument, 0, 'r'}, | 213 | {"regex", required_argument, 0, 'r'}, |
@@ -243,7 +246,7 @@ process_arguments (int argc, char **argv) | |||
243 | } | 246 | } |
244 | 247 | ||
245 | while (1) { | 248 | while (1) { |
246 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:e:p:s:R:r:u:f:C:nlLS::m:M:N:E", longopts, &option); | 249 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:nlLS::m:M:N:E", longopts, &option); |
247 | if (c == -1 || c == EOF) | 250 | if (c == -1 || c == EOF) |
248 | break; | 251 | break; |
249 | 252 | ||
@@ -392,6 +395,10 @@ process_arguments (int argc, char **argv) | |||
392 | free(http_method); | 395 | free(http_method); |
393 | http_method = strdup (optarg); | 396 | http_method = strdup (optarg); |
394 | break; | 397 | break; |
398 | case 'd': /* string or substring */ | ||
399 | strncpy (header_expect, optarg, MAX_INPUT_BUFFER - 1); | ||
400 | header_expect[MAX_INPUT_BUFFER - 1] = 0; | ||
401 | break; | ||
395 | case 's': /* string or substring */ | 402 | case 's': /* string or substring */ |
396 | strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1); | 403 | strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1); |
397 | string_expect[MAX_INPUT_BUFFER - 1] = 0; | 404 | string_expect[MAX_INPUT_BUFFER - 1] = 0; |
@@ -1085,6 +1092,17 @@ check_http (void) | |||
1085 | } | 1092 | } |
1086 | 1093 | ||
1087 | /* Page and Header content checks go here */ | 1094 | /* Page and Header content checks go here */ |
1095 | if (strlen (header_expect)) { | ||
1096 | if (!strstr (header, header_expect)) { | ||
1097 | strncpy(&output_header_search[0],header_expect,sizeof(output_header_search)); | ||
1098 | if(output_header_search[sizeof(output_header_search)-1]!='\0') { | ||
1099 | bcopy("...",&output_header_search[sizeof(output_header_search)-4],4); | ||
1100 | } | ||
1101 | xasprintf (&msg, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); | ||
1102 | result = STATE_CRITICAL; | ||
1103 | } | ||
1104 | } | ||
1105 | |||
1088 | 1106 | ||
1089 | if (strlen (string_expect)) { | 1107 | if (strlen (string_expect)) { |
1090 | if (!strstr (page, string_expect)) { | 1108 | if (!strstr (page, string_expect)) { |
@@ -1434,6 +1452,8 @@ print_help (void) | |||
1434 | printf (" %s", _("the first (status) line of the server response (default: ")); | 1452 | printf (" %s", _("the first (status) line of the server response (default: ")); |
1435 | printf ("%s)\n", HTTP_EXPECT); | 1453 | printf ("%s)\n", HTTP_EXPECT); |
1436 | printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)")); | 1454 | printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)")); |
1455 | printf (" %s\n", "-d, --header-string=STRING"); | ||
1456 | printf (" %s\n", _("String to expect in the response headers")); | ||
1437 | printf (" %s\n", "-s, --string=STRING"); | 1457 | printf (" %s\n", "-s, --string=STRING"); |
1438 | printf (" %s\n", _("String to expect in the content")); | 1458 | printf (" %s\n", _("String to expect in the content")); |
1439 | printf (" %s\n", "-u, --url=PATH"); | 1459 | printf (" %s\n", "-u, --url=PATH"); |
@@ -1535,7 +1555,7 @@ print_usage (void) | |||
1535 | printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname); | 1555 | printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname); |
1536 | printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-a auth]\n"); | 1556 | printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-a auth]\n"); |
1537 | printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n"); | 1557 | printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n"); |
1538 | printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); | 1558 | printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); |
1539 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); | 1559 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); |
1540 | printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <warn_age>[,<crit_age>]]\n"); | 1560 | printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <warn_age>[,<crit_age>]]\n"); |
1541 | printf (" [-T <content-type>] [-j method]\n"); | 1561 | printf (" [-T <content-type>] [-j method]\n"); |
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index ad3d86f..11d4a2f 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c | |||
@@ -59,6 +59,32 @@ unsigned int db_port = MYSQL_PORT; | |||
59 | int check_slave = 0, warn_sec = 0, crit_sec = 0; | 59 | int check_slave = 0, warn_sec = 0, crit_sec = 0; |
60 | int verbose = 0; | 60 | int verbose = 0; |
61 | 61 | ||
62 | static double warning_time = 0; | ||
63 | static double critical_time = 0; | ||
64 | |||
65 | #define LENGTH_METRIC_UNIT 6 | ||
66 | static const char *metric_unit[LENGTH_METRIC_UNIT] = { | ||
67 | "Open_files", | ||
68 | "Open_tables", | ||
69 | "Qcache_free_memory", | ||
70 | "Qcache_queries_in_cache", | ||
71 | "Threads_connected", | ||
72 | "Threads_running" | ||
73 | }; | ||
74 | |||
75 | #define LENGTH_METRIC_COUNTER 9 | ||
76 | static const char *metric_counter[LENGTH_METRIC_COUNTER] = { | ||
77 | "Connections", | ||
78 | "Qcache_hits", | ||
79 | "Qcache_inserts", | ||
80 | "Qcache_lowmem_prunes", | ||
81 | "Qcache_not_cached", | ||
82 | "Queries", | ||
83 | "Questions", | ||
84 | "Table_locks_waited", | ||
85 | "Uptime" | ||
86 | }; | ||
87 | |||
62 | thresholds *my_threshold = NULL; | 88 | thresholds *my_threshold = NULL; |
63 | 89 | ||
64 | int process_arguments (int, char **); | 90 | int process_arguments (int, char **); |
@@ -79,6 +105,9 @@ main (int argc, char **argv) | |||
79 | char *result = NULL; | 105 | char *result = NULL; |
80 | char *error = NULL; | 106 | char *error = NULL; |
81 | char slaveresult[SLAVERESULTSIZE]; | 107 | char slaveresult[SLAVERESULTSIZE]; |
108 | char* perf; | ||
109 | |||
110 | perf = strdup (""); | ||
82 | 111 | ||
83 | setlocale (LC_ALL, ""); | 112 | setlocale (LC_ALL, ""); |
84 | bindtextdomain (PACKAGE, LOCALEDIR); | 113 | bindtextdomain (PACKAGE, LOCALEDIR); |
@@ -126,6 +155,37 @@ main (int argc, char **argv) | |||
126 | die (STATE_CRITICAL, "%s\n", mysql_error (&mysql)); | 155 | die (STATE_CRITICAL, "%s\n", mysql_error (&mysql)); |
127 | } | 156 | } |
128 | 157 | ||
158 | /* try to fetch some perf data */ | ||
159 | if (mysql_query (&mysql, "show global status") == 0) { | ||
160 | if ( (res = mysql_store_result (&mysql)) == NULL) { | ||
161 | error = strdup(mysql_error(&mysql)); | ||
162 | mysql_close (&mysql); | ||
163 | die (STATE_CRITICAL, _("status store_result error: %s\n"), error); | ||
164 | } | ||
165 | |||
166 | while ( (row = mysql_fetch_row (res)) != NULL) { | ||
167 | int i; | ||
168 | |||
169 | for(i = 0; i < LENGTH_METRIC_UNIT; i++) { | ||
170 | if (strcmp(row[0], metric_unit[i]) == 0) { | ||
171 | xasprintf(&perf, "%s%s ", perf, perfdata(metric_unit[i], | ||
172 | atol(row[1]), "", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0)); | ||
173 | continue; | ||
174 | } | ||
175 | } | ||
176 | for(i = 0; i < LENGTH_METRIC_COUNTER; i++) { | ||
177 | if (strcmp(row[0], metric_counter[i]) == 0) { | ||
178 | xasprintf(&perf, "%s%s ", perf, perfdata(metric_counter[i], | ||
179 | atol(row[1]), "c", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0)); | ||
180 | continue; | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | /* remove trailing space */ | ||
185 | if (strlen(perf) > 0) | ||
186 | perf[strlen(perf) - 1] = '\0'; | ||
187 | } | ||
188 | |||
129 | if(check_slave) { | 189 | if(check_slave) { |
130 | /* check the slave status */ | 190 | /* check the slave status */ |
131 | if (mysql_query (&mysql, "show slave status") != 0) { | 191 | if (mysql_query (&mysql, "show slave status") != 0) { |
@@ -218,11 +278,17 @@ main (int argc, char **argv) | |||
218 | 278 | ||
219 | status = get_status(value, my_threshold); | 279 | status = get_status(value, my_threshold); |
220 | 280 | ||
281 | xasprintf (&perf, "%s %s", perf, fperfdata ("seconds behind master", value, "s", | ||
282 | TRUE, (double) warning_time, | ||
283 | TRUE, (double) critical_time, | ||
284 | FALSE, 0, | ||
285 | FALSE, 0)); | ||
286 | |||
221 | if (status == STATE_WARNING) { | 287 | if (status == STATE_WARNING) { |
222 | printf("SLOW_SLAVE %s: %s\n", _("WARNING"), slaveresult); | 288 | printf("SLOW_SLAVE %s: %s|%s\n", _("WARNING"), slaveresult, perf); |
223 | exit(STATE_WARNING); | 289 | exit(STATE_WARNING); |
224 | } else if (status == STATE_CRITICAL) { | 290 | } else if (status == STATE_CRITICAL) { |
225 | printf("SLOW_SLAVE %s: %s\n", _("CRITICAL"), slaveresult); | 291 | printf("SLOW_SLAVE %s: %s|%s\n", _("CRITICAL"), slaveresult, perf); |
226 | exit(STATE_CRITICAL); | 292 | exit(STATE_CRITICAL); |
227 | } | 293 | } |
228 | } | 294 | } |
@@ -237,9 +303,9 @@ main (int argc, char **argv) | |||
237 | 303 | ||
238 | /* print out the result of stats */ | 304 | /* print out the result of stats */ |
239 | if (check_slave) { | 305 | if (check_slave) { |
240 | printf ("%s %s\n", result, slaveresult); | 306 | printf ("%s %s|%s\n", result, slaveresult, perf); |
241 | } else { | 307 | } else { |
242 | printf ("%s\n", result); | 308 | printf ("%s|%s\n", result, perf); |
243 | } | 309 | } |
244 | 310 | ||
245 | return STATE_OK; | 311 | return STATE_OK; |
@@ -339,9 +405,11 @@ process_arguments (int argc, char **argv) | |||
339 | break; | 405 | break; |
340 | case 'w': | 406 | case 'w': |
341 | warning = optarg; | 407 | warning = optarg; |
408 | warning_time = strtod (warning, NULL); | ||
342 | break; | 409 | break; |
343 | case 'c': | 410 | case 'c': |
344 | critical = optarg; | 411 | critical = optarg; |
412 | critical_time = strtod (critical, NULL); | ||
345 | break; | 413 | break; |
346 | case 'V': /* version */ | 414 | case 'V': /* version */ |
347 | print_revision (progname, NP_VERSION); | 415 | print_revision (progname, NP_VERSION); |
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 7c5d0ec..7c3bc4b 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -63,6 +63,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
63 | #define L_CALCULATE_RATE CHAR_MAX+1 | 63 | #define L_CALCULATE_RATE CHAR_MAX+1 |
64 | #define L_RATE_MULTIPLIER CHAR_MAX+2 | 64 | #define L_RATE_MULTIPLIER CHAR_MAX+2 |
65 | #define L_INVERT_SEARCH CHAR_MAX+3 | 65 | #define L_INVERT_SEARCH CHAR_MAX+3 |
66 | #define L_OFFSET CHAR_MAX+4 | ||
66 | 67 | ||
67 | /* Gobble to string - stop incrementing c when c[0] match one of the | 68 | /* Gobble to string - stop incrementing c when c[0] match one of the |
68 | * characters in s */ | 69 | * characters in s */ |
@@ -138,6 +139,7 @@ char *output_delim; | |||
138 | char *miblist = NULL; | 139 | char *miblist = NULL; |
139 | int needmibs = FALSE; | 140 | int needmibs = FALSE; |
140 | int calculate_rate = 0; | 141 | int calculate_rate = 0; |
142 | double offset = 0.0; | ||
141 | int rate_multiplier = 1; | 143 | int rate_multiplier = 1; |
142 | state_data *previous_state; | 144 | state_data *previous_state; |
143 | double previous_value[MAX_OIDS]; | 145 | double previous_value[MAX_OIDS]; |
@@ -274,35 +276,36 @@ main (int argc, char **argv) | |||
274 | snmpcmd = strdup (PATH_TO_SNMPGET); | 276 | snmpcmd = strdup (PATH_TO_SNMPGET); |
275 | } | 277 | } |
276 | 278 | ||
277 | /* 9 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */ | 279 | /* 10 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */ |
278 | command_line = calloc (9 + numauthpriv + 1 + numoids + 1, sizeof (char *)); | 280 | command_line = calloc (10 + numauthpriv + 1 + numoids + 1, sizeof (char *)); |
279 | command_line[0] = snmpcmd; | 281 | command_line[0] = snmpcmd; |
280 | command_line[1] = strdup ("-t"); | 282 | command_line[1] = strdup ("-Le"); |
281 | xasprintf (&command_line[2], "%d", timeout_interval); | 283 | command_line[2] = strdup ("-t"); |
282 | command_line[3] = strdup ("-r"); | 284 | xasprintf (&command_line[3], "%d", timeout_interval); |
283 | xasprintf (&command_line[4], "%d", retries); | 285 | command_line[4] = strdup ("-r"); |
284 | command_line[5] = strdup ("-m"); | 286 | xasprintf (&command_line[5], "%d", retries); |
285 | command_line[6] = strdup (miblist); | 287 | command_line[6] = strdup ("-m"); |
286 | command_line[7] = "-v"; | 288 | command_line[7] = strdup (miblist); |
287 | command_line[8] = strdup (proto); | 289 | command_line[8] = "-v"; |
290 | command_line[9] = strdup (proto); | ||
288 | 291 | ||
289 | for (i = 0; i < numauthpriv; i++) { | 292 | for (i = 0; i < numauthpriv; i++) { |
290 | command_line[9 + i] = authpriv[i]; | 293 | command_line[10 + i] = authpriv[i]; |
291 | } | 294 | } |
292 | 295 | ||
293 | xasprintf (&command_line[9 + numauthpriv], "%s:%s", server_address, port); | 296 | xasprintf (&command_line[10 + numauthpriv], "%s:%s", server_address, port); |
294 | 297 | ||
295 | /* This is just for display purposes, so it can remain a string */ | 298 | /* This is just for display purposes, so it can remain a string */ |
296 | xasprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s", | 299 | xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s:%s", |
297 | snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]", | 300 | snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]", |
298 | server_address, port); | 301 | server_address, port); |
299 | 302 | ||
300 | for (i = 0; i < numoids; i++) { | 303 | for (i = 0; i < numoids; i++) { |
301 | command_line[9 + numauthpriv + 1 + i] = oids[i]; | 304 | command_line[10 + numauthpriv + 1 + i] = oids[i]; |
302 | xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]); | 305 | xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]); |
303 | } | 306 | } |
304 | 307 | ||
305 | command_line[9 + numauthpriv + 1 + numoids] = NULL; | 308 | command_line[10 + numauthpriv + 1 + numoids] = NULL; |
306 | 309 | ||
307 | if (verbose) | 310 | if (verbose) |
308 | printf ("%s\n", cl_hidden_auth); | 311 | printf ("%s\n", cl_hidden_auth); |
@@ -429,7 +432,7 @@ main (int argc, char **argv) | |||
429 | ptr = strpbrk (show, "0123456789"); | 432 | ptr = strpbrk (show, "0123456789"); |
430 | if (ptr == NULL) | 433 | if (ptr == NULL) |
431 | die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); | 434 | die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); |
432 | response_value[i] = strtod (ptr, NULL); | 435 | response_value[i] = strtod (ptr, NULL) + offset; |
433 | 436 | ||
434 | if(calculate_rate) { | 437 | if(calculate_rate) { |
435 | if (previous_state!=NULL) { | 438 | if (previous_state!=NULL) { |
@@ -618,6 +621,7 @@ process_arguments (int argc, char **argv) | |||
618 | {"next", no_argument, 0, 'n'}, | 621 | {"next", no_argument, 0, 'n'}, |
619 | {"rate", no_argument, 0, L_CALCULATE_RATE}, | 622 | {"rate", no_argument, 0, L_CALCULATE_RATE}, |
620 | {"rate-multiplier", required_argument, 0, L_RATE_MULTIPLIER}, | 623 | {"rate-multiplier", required_argument, 0, L_RATE_MULTIPLIER}, |
624 | {"offset", required_argument, 0, L_OFFSET}, | ||
621 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, | 625 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, |
622 | {"perf-oids", no_argument, 0, 'O'}, | 626 | {"perf-oids", no_argument, 0, 'O'}, |
623 | {0, 0, 0, 0} | 627 | {0, 0, 0, 0} |
@@ -832,6 +836,9 @@ process_arguments (int argc, char **argv) | |||
832 | if(!is_integer(optarg)||((rate_multiplier=atoi(optarg))<=0)) | 836 | if(!is_integer(optarg)||((rate_multiplier=atoi(optarg))<=0)) |
833 | usage2(_("Rate multiplier must be a positive integer"),optarg); | 837 | usage2(_("Rate multiplier must be a positive integer"),optarg); |
834 | break; | 838 | break; |
839 | case L_OFFSET: | ||
840 | offset=strtod(optarg,NULL); | ||
841 | break; | ||
835 | case L_INVERT_SEARCH: | 842 | case L_INVERT_SEARCH: |
836 | invert_search=1; | 843 | invert_search=1; |
837 | break; | 844 | break; |
@@ -1080,6 +1087,8 @@ print_help (void) | |||
1080 | printf (" %s\n", _("Enable rate calculation. See 'Rate Calculation' below")); | 1087 | printf (" %s\n", _("Enable rate calculation. See 'Rate Calculation' below")); |
1081 | printf (" %s\n", "--rate-multiplier"); | 1088 | printf (" %s\n", "--rate-multiplier"); |
1082 | printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute")); | 1089 | printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute")); |
1090 | printf (" %s\n", "--offset=OFFSET"); | ||
1091 | printf (" %s\n", _("Add/substract the specified OFFSET to numeric sensor data")); | ||
1083 | 1092 | ||
1084 | /* Tests Against Strings */ | 1093 | /* Tests Against Strings */ |
1085 | printf (" %s\n", "-s, --string=STRING"); | 1094 | printf (" %s\n", "-s, --string=STRING"); |