summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_disk.c5
-rw-r--r--plugins/check_http.c2
-rw-r--r--plugins/check_mysql.c35
-rw-r--r--plugins/check_snmp.c10
-rw-r--r--plugins/runcmd.c4
5 files changed, 37 insertions, 19 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 39dc6cd..05e5502 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -131,9 +131,6 @@ bool stat_path (struct parameter_list *p);
131void get_stats (struct parameter_list *p, struct fs_usage *fsp); 131void get_stats (struct parameter_list *p, struct fs_usage *fsp);
132void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); 132void get_path_stats (struct parameter_list *p, struct fs_usage *fsp);
133 133
134double w_dfp = -1.0;
135double c_dfp = -1.0;
136char *path;
137char *exclude_device; 134char *exclude_device;
138char *units; 135char *units;
139uintmax_t mult = 1024 * 1024; 136uintmax_t mult = 1024 * 1024;
@@ -889,7 +886,7 @@ process_arguments (int argc, char **argv)
889 if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c])) 886 if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c]))
890 crit_usedspace_percent = argv[c++]; 887 crit_usedspace_percent = argv[c++];
891 888
892 if (argc > c && path == NULL) { 889 if (argc > c) {
893 se = np_add_parameter(&path_select_list, strdup(argv[c++])); 890 se = np_add_parameter(&path_select_list, strdup(argv[c++]));
894 path_selected = TRUE; 891 path_selected = TRUE;
895 set_all_thresholds(se); 892 set_all_thresholds(se);
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 1288c41..718c8ee 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1279,7 +1279,7 @@ check_http (void)
1279 1279
1280 regmatch_t chre_pmatch[1]; // We actually do not care about this, since we only want to know IF it was found 1280 regmatch_t chre_pmatch[1]; // We actually do not care about this, since we only want to know IF it was found
1281 1281
1282 if (regexec(&chunked_header_regex, header, 1, chre_pmatch, 0) == 0) { 1282 if (!no_body && regexec(&chunked_header_regex, header, 1, chre_pmatch, 0) == 0) {
1283 if (verbose) { 1283 if (verbose) {
1284 printf("Found chunked content\n"); 1284 printf("Found chunked content\n");
1285 } 1285 }
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 91e150f..7d85554 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -34,7 +34,7 @@ const char *progname = "check_mysql";
34const char *copyright = "1999-2011"; 34const char *copyright = "1999-2011";
35const char *email = "devel@monitoring-plugins.org"; 35const char *email = "devel@monitoring-plugins.org";
36 36
37#define SLAVERESULTSIZE 70 37#define SLAVERESULTSIZE 96
38 38
39#include "common.h" 39#include "common.h"
40#include "utils.h" 40#include "utils.h"
@@ -89,6 +89,8 @@ static const char *metric_counter[LENGTH_METRIC_COUNTER] = {
89 "Uptime" 89 "Uptime"
90}; 90};
91 91
92#define MYSQLDUMP_THREADS_QUERY "SELECT COUNT(1) mysqldumpThreads FROM information_schema.processlist WHERE info LIKE 'SELECT /*!40001 SQL_NO_CACHE */%'"
93
92thresholds *my_threshold = NULL; 94thresholds *my_threshold = NULL;
93 95
94int process_arguments (int, char **); 96int process_arguments (int, char **);
@@ -108,7 +110,7 @@ main (int argc, char **argv)
108 110
109 char *result = NULL; 111 char *result = NULL;
110 char *error = NULL; 112 char *error = NULL;
111 char slaveresult[SLAVERESULTSIZE]; 113 char slaveresult[SLAVERESULTSIZE] = { 0 };
112 char* perf; 114 char* perf;
113 115
114 perf = strdup (""); 116 perf = strdup ("");
@@ -278,11 +280,30 @@ main (int argc, char **argv)
278 /* Save slave status in slaveresult */ 280 /* Save slave status in slaveresult */
279 snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s Seconds Behind Master: %s", row[slave_io_field], row[slave_sql_field], seconds_behind_field!=-1?row[seconds_behind_field]:"Unknown"); 281 snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s Seconds Behind Master: %s", row[slave_io_field], row[slave_sql_field], seconds_behind_field!=-1?row[seconds_behind_field]:"Unknown");
280 282
281 /* Raise critical error if SQL THREAD or IO THREAD are stopped */ 283 /* Raise critical error if SQL THREAD or IO THREAD are stopped, but only if there are no mysqldump threads running */
282 if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) { 284 if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) {
283 mysql_free_result (res); 285 MYSQL_RES *res_mysqldump;
284 mysql_close (&mysql); 286 MYSQL_ROW row_mysqldump;
285 die (STATE_CRITICAL, "%s\n", slaveresult); 287 unsigned int mysqldump_threads = 0;
288
289 if (mysql_query (&mysql, MYSQLDUMP_THREADS_QUERY) == 0) {
290 /* store the result */
291 if ( (res_mysqldump = mysql_store_result (&mysql)) != NULL) {
292 if (mysql_num_rows(res_mysqldump) == 1) {
293 if ( (row_mysqldump = mysql_fetch_row (res_mysqldump)) != NULL) {
294 mysqldump_threads = atoi(row_mysqldump[0]);
295 }
296 }
297 /* free the result */
298 mysql_free_result (res_mysqldump);
299 }
300 mysql_close (&mysql);
301 }
302 if (mysqldump_threads == 0) {
303 die (STATE_CRITICAL, "%s\n", slaveresult);
304 } else {
305 strncat(slaveresult, " Mysqldump: in progress", SLAVERESULTSIZE-1);
306 }
286 } 307 }
287 308
288 if (verbose >=3) { 309 if (verbose >=3) {
@@ -294,7 +315,7 @@ main (int argc, char **argv)
294 } 315 }
295 316
296 /* Check Seconds Behind against threshold */ 317 /* Check Seconds Behind against threshold */
297 if ((seconds_behind_field != -1) && (strcmp (row[seconds_behind_field], "NULL") != 0)) { 318 if ((seconds_behind_field != -1) && (row[seconds_behind_field] != NULL && strcmp (row[seconds_behind_field], "NULL") != 0)) {
298 double value = atof(row[seconds_behind_field]); 319 double value = atof(row[seconds_behind_field]);
299 int status; 320 int status;
300 321
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 2acada2..56a586a 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -159,6 +159,7 @@ int perf_labels = 1;
159char* ip_version = ""; 159char* ip_version = "";
160double multiplier = 1.0; 160double multiplier = 1.0;
161char *fmtstr = ""; 161char *fmtstr = "";
162bool fmtstr_set = false;
162char buffer[DEFAULT_BUFFER_SIZE]; 163char buffer[DEFAULT_BUFFER_SIZE];
163bool ignore_mib_parsing_errors = false; 164bool ignore_mib_parsing_errors = false;
164 165
@@ -437,7 +438,8 @@ main (int argc, char **argv)
437 } 438 }
438 else if (strstr (response, "INTEGER: ")) { 439 else if (strstr (response, "INTEGER: ")) {
439 show = multiply (strstr (response, "INTEGER: ") + 9); 440 show = multiply (strstr (response, "INTEGER: ") + 9);
440 if (fmtstr != "") { 441
442 if (fmtstr_set) {
441 conv = fmtstr; 443 conv = fmtstr;
442 } 444 }
443 } 445 }
@@ -611,8 +613,9 @@ main (int argc, char **argv)
611 len = sizeof(perfstr)-strlen(perfstr)-1; 613 len = sizeof(perfstr)-strlen(perfstr)-1;
612 strncat(perfstr, show, len>ptr-show ? ptr-show : len); 614 strncat(perfstr, show, len>ptr-show ? ptr-show : len);
613 615
614 if (type) 616 if (strcmp(type, "") != 0) {
615 strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1); 617 strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
618 }
616 619
617 if (warning_thresholds) { 620 if (warning_thresholds) {
618 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 621 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
@@ -988,6 +991,7 @@ process_arguments (int argc, char **argv)
988 case 'f': 991 case 'f':
989 if (multiplier != 1.0) { 992 if (multiplier != 1.0) {
990 fmtstr=optarg; 993 fmtstr=optarg;
994 fmtstr_set = true;
991 } 995 }
992 break; 996 break;
993 case L_IGNORE_MIB_PARSING_ERRORS: 997 case L_IGNORE_MIB_PARSING_ERRORS:
@@ -1204,7 +1208,7 @@ multiply (char *str)
1204 if(verbose>2) 1208 if(verbose>2)
1205 printf(" multiply extracted double: %f\n", val); 1209 printf(" multiply extracted double: %f\n", val);
1206 val *= multiplier; 1210 val *= multiplier;
1207 if (fmtstr != "") { 1211 if (fmtstr_set) {
1208 conv = fmtstr; 1212 conv = fmtstr;
1209 } 1213 }
1210 if (val == (int)val) { 1214 if (val == (int)val) {
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index c1d675d..102191e 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -116,10 +116,6 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
116 env[0] = strdup("LC_ALL=C"); 116 env[0] = strdup("LC_ALL=C");
117 env[1] = '\0'; 117 env[1] = '\0';
118 118
119 /* if no command was passed, return with no error */
120 if (cmdstring == NULL)
121 return -1;
122
123 /* make copy of command string so strtok() doesn't silently modify it */ 119 /* make copy of command string so strtok() doesn't silently modify it */
124 /* (the calling program may want to access it later) */ 120 /* (the calling program may want to access it later) */
125 cmdlen = strlen(cmdstring); 121 cmdlen = strlen(cmdstring);