summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_curl.c5
-rw-r--r--plugins/check_disk.c27
-rw-r--r--plugins/check_http.c1
-rw-r--r--plugins/check_mysql.c7
-rw-r--r--plugins/check_nt.c2
-rw-r--r--plugins/check_pgsql.c12
-rw-r--r--plugins/check_smtp.c38
-rw-r--r--plugins/runcmd.c2
8 files changed, 76 insertions, 18 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 6294fa0..d0871c4 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -2303,11 +2303,10 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line)
2303 if( strchr( p, '.' ) != NULL ) { 2303 if( strchr( p, '.' ) != NULL ) {
2304 2304
2305 /* HTTP 1.x case */ 2305 /* HTTP 1.x case */
2306 char *ppp; 2306 strtok( p, "." );
2307 ppp = strtok( p, "." );
2308 status_line->http_major = (int)strtol( p, &pp, 10 ); 2307 status_line->http_major = (int)strtol( p, &pp, 10 );
2309 if( *pp != '\0' ) { free( first_line_buf ); return -1; } 2308 if( *pp != '\0' ) { free( first_line_buf ); return -1; }
2310 ppp = strtok( NULL, " " ); 2309 strtok( NULL, " " );
2311 status_line->http_minor = (int)strtol( p, &pp, 10 ); 2310 status_line->http_minor = (int)strtol( p, &pp, 10 );
2312 if( *pp != '\0' ) { free( first_line_buf ); return -1; } 2311 if( *pp != '\0' ) { free( first_line_buf ); return -1; }
2313 p += 4; /* 1.x SP */ 2312 p += 4; /* 1.x SP */
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index a99f35e..39dc6cd 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -626,21 +626,36 @@ process_arguments (int argc, char **argv)
626 if (! strcasecmp (optarg, "bytes")) { 626 if (! strcasecmp (optarg, "bytes")) {
627 mult = (uintmax_t)1; 627 mult = (uintmax_t)1;
628 units = strdup ("B"); 628 units = strdup ("B");
629 } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) { 629 } else if (!strcmp(optarg, "KiB")) {
630 mult = (uintmax_t)1024; 630 mult = (uintmax_t)1024;
631 units = strdup ("kiB"); 631 units = strdup ("KiB");
632 } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) { 632 } else if (! strcmp (optarg, "kB")) {
633 mult = (uintmax_t)1000;
634 units = strdup ("kB");
635 } else if (!strcmp(optarg, "MiB")) {
633 mult = (uintmax_t)1024 * 1024; 636 mult = (uintmax_t)1024 * 1024;
634 units = strdup ("MiB"); 637 units = strdup ("MiB");
635 } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) { 638 } else if (! strcmp (optarg, "MB")) {
639 mult = (uintmax_t)1000 * 1000;
640 units = strdup ("MB");
641 } else if (!strcmp(optarg, "GiB")) {
636 mult = (uintmax_t)1024 * 1024 * 1024; 642 mult = (uintmax_t)1024 * 1024 * 1024;
637 units = strdup ("GiB"); 643 units = strdup ("GiB");
638 } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) { 644 } else if (! strcmp (optarg, "GB")){
645 mult = (uintmax_t)1000 * 1000 * 1000;
646 units = strdup ("GB");
647 } else if (!strcmp(optarg, "TiB")) {
639 mult = (uintmax_t)1024 * 1024 * 1024 * 1024; 648 mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
640 units = strdup ("TiB"); 649 units = strdup ("TiB");
641 } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) { 650 } else if (! strcmp (optarg, "TB")) {
651 mult = (uintmax_t)1000 * 1000 * 1000 * 1000;
652 units = strdup ("TB");
653 } else if (!strcmp(optarg, "PiB")) {
642 mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024; 654 mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024;
643 units = strdup ("PiB"); 655 units = strdup ("PiB");
656 } else if (! strcmp (optarg, "PB")){
657 mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000;
658 units = strdup ("PB");
644 } else { 659 } else {
645 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); 660 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
646 } 661 }
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 432a984..1288c41 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1392,7 +1392,6 @@ char *unchunk_content(const char *content) {
1392 // https://en.wikipedia.org/wiki/Chunked_transfer_encoding 1392 // https://en.wikipedia.org/wiki/Chunked_transfer_encoding
1393 // https://www.rfc-editor.org/rfc/rfc7230#section-4.1 1393 // https://www.rfc-editor.org/rfc/rfc7230#section-4.1
1394 char *result = NULL; 1394 char *result = NULL;
1395 size_t content_length = strlen(content);
1396 char *start_of_chunk; 1395 char *start_of_chunk;
1397 char* end_of_chunk; 1396 char* end_of_chunk;
1398 long size_of_chunk; 1397 long size_of_chunk;
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 0cba50e..91e150f 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -138,7 +138,10 @@ main (int argc, char **argv)
138 mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers); 138 mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers);
139 /* establish a connection to the server and error checking */ 139 /* establish a connection to the server and error checking */
140 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) { 140 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
141 if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR) 141 /* Depending on internally-selected auth plugin MySQL might return */
142 /* ER_ACCESS_DENIED_NO_PASSWORD_ERROR or ER_ACCESS_DENIED_ERROR. */
143 /* Semantically these errors are the same. */
144 if (ignore_auth && (mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR || mysql_errno (&mysql) == ER_ACCESS_DENIED_NO_PASSWORD_ERROR))
142 { 145 {
143 printf("MySQL OK - Version: %s (protocol %d)\n", 146 printf("MySQL OK - Version: %s (protocol %d)\n",
144 mysql_get_server_info(&mysql), 147 mysql_get_server_info(&mysql),
@@ -551,7 +554,7 @@ print_help (void)
551 printf (" %s\n", _("Exit with CRITICAL status if slave server is more then INTEGER seconds")); 554 printf (" %s\n", _("Exit with CRITICAL status if slave server is more then INTEGER seconds"));
552 printf (" %s\n", _("behind master")); 555 printf (" %s\n", _("behind master"));
553 printf (" %s\n", "-l, --ssl"); 556 printf (" %s\n", "-l, --ssl");
554 printf (" %s\n", _("Use ssl encryptation")); 557 printf (" %s\n", _("Use ssl encryption"));
555 printf (" %s\n", "-C, --ca-cert=STRING"); 558 printf (" %s\n", "-C, --ca-cert=STRING");
556 printf (" %s\n", _("Path to CA signing the cert")); 559 printf (" %s\n", _("Path to CA signing the cert"));
557 printf (" %s\n", "-a, --cert=STRING"); 560 printf (" %s\n", "-a, --cert=STRING");
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 59c135d..d73d83c 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -341,7 +341,7 @@ int main(int argc, char **argv){
341 341
342 2) If the counter you're going to measure is percent-based, the code will detect 342 2) If the counter you're going to measure is percent-based, the code will detect
343 the percent sign in its name and will attribute minimum (0%) and maximum (100%) 343 the percent sign in its name and will attribute minimum (0%) and maximum (100%)
344 values automagically, as well the ¨%" sign to graph units. 344 values automagically, as well the "%" sign to graph units.
345 345
346 3) OTOH, if the counter is "absolute", you'll have to provide the following 346 3) OTOH, if the counter is "absolute", you'll have to provide the following
347 the counter unit - that is, the dimensions of the counter you're getting. Examples: 347 the counter unit - that is, the dimensions of the counter you're getting. Examples:
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 94a03b2..6199033 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -517,7 +517,10 @@ print_help (void)
517 printf (" %s\n", _("connecting to the server. The result from the query has to be numeric.")); 517 printf (" %s\n", _("connecting to the server. The result from the query has to be numeric."));
518 printf (" %s\n", _("Multiple SQL commands, separated by semicolon, are allowed but the result ")); 518 printf (" %s\n", _("Multiple SQL commands, separated by semicolon, are allowed but the result "));
519 printf (" %s\n", _("of the last command is taken into account only. The value of the first")); 519 printf (" %s\n", _("of the last command is taken into account only. The value of the first"));
520 printf (" %s\n\n", _("column in the first row is used as the check result.")); 520 printf (" %s\n", _("column in the first row is used as the check result. If a second column is"));
521 printf (" %s\n", _("present in the result set, this is added to the plugin output with a"));
522 printf (" %s\n", _("prefix of \"Extra Info:\". This information can be displayed in the system"));
523 printf (" %s\n\n", _("executing the plugin."));
521 524
522 printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual")); 525 printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"));
523 printf (" %s\n\n", _("for details about how to access internal statistics of the database server.")); 526 printf (" %s\n\n", _("for details about how to access internal statistics of the database server."));
@@ -557,6 +560,7 @@ do_query (PGconn *conn, char *query)
557 PGresult *res; 560 PGresult *res;
558 561
559 char *val_str; 562 char *val_str;
563 char *extra_info;
560 double value; 564 double value;
561 565
562 char *endptr = NULL; 566 char *endptr = NULL;
@@ -621,6 +625,12 @@ do_query (PGconn *conn, char *query)
621 printf ("|query=%f;%s;%s;;\n", value, 625 printf ("|query=%f;%s;%s;;\n", value,
622 query_warning ? query_warning : "", 626 query_warning ? query_warning : "",
623 query_critical ? query_critical : ""); 627 query_critical ? query_critical : "");
628 if (PQnfields (res) > 1) {
629 extra_info = PQgetvalue (res, 0, 1);
630 if (extra_info != NULL) {
631 printf ("Extra Info: %s\n", extra_info);
632 }
633 }
624 return my_status; 634 return my_status;
625} 635}
626 636
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index b035aab..996bd87 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -3,7 +3,7 @@
3* Monitoring check_smtp plugin 3* Monitoring check_smtp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Monitoring Plugins Development Team 6* Copyright (c) 2000-2023 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -52,6 +52,7 @@ int days_till_exp_warn, days_till_exp_crit;
52enum { 52enum {
53 SMTP_PORT = 25 53 SMTP_PORT = 25
54}; 54};
55#define PROXY_PREFIX "PROXY TCP4 0.0.0.0 0.0.0.0 25 25\r\n"
55#define SMTP_EXPECT "220" 56#define SMTP_EXPECT "220"
56#define SMTP_HELO "HELO " 57#define SMTP_HELO "HELO "
57#define SMTP_EHLO "EHLO " 58#define SMTP_EHLO "EHLO "
@@ -102,6 +103,8 @@ double critical_time = 0;
102int check_critical_time = FALSE; 103int check_critical_time = FALSE;
103int verbose = 0; 104int verbose = 0;
104int use_ssl = FALSE; 105int use_ssl = FALSE;
106int use_sni = FALSE;
107short use_proxy_prefix = FALSE;
105short use_ehlo = FALSE; 108short use_ehlo = FALSE;
106short use_lhlo = FALSE; 109short use_lhlo = FALSE;
107short ssl_established = 0; 110short ssl_established = 0;
@@ -184,6 +187,13 @@ main (int argc, char **argv)
184 187
185 if (result == STATE_OK) { /* we connected */ 188 if (result == STATE_OK) { /* we connected */
186 189
190 /* If requested, send PROXY header */
191 if (use_proxy_prefix) {
192 if (verbose)
193 printf ("Sending header %s\n", PROXY_PREFIX);
194 send(sd, PROXY_PREFIX, strlen(PROXY_PREFIX), 0);
195 }
196
187 /* watch for the SMTP connection string and */ 197 /* watch for the SMTP connection string and */
188 /* return a WARNING status if we couldn't read any data */ 198 /* return a WARNING status if we couldn't read any data */
189 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) { 199 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
@@ -225,7 +235,7 @@ main (int argc, char **argv)
225 smtp_quit(); 235 smtp_quit();
226 return STATE_UNKNOWN; 236 return STATE_UNKNOWN;
227 } 237 }
228 result = np_net_ssl_init(sd); 238 result = np_net_ssl_init_with_hostname(sd, (use_sni ? server_address : NULL));
229 if(result != STATE_OK) { 239 if(result != STATE_OK) {
230 printf (_("CRITICAL - Cannot create SSL context.\n")); 240 printf (_("CRITICAL - Cannot create SSL context.\n"));
231 close(sd); 241 close(sd);
@@ -454,6 +464,10 @@ process_arguments (int argc, char **argv)
454 int c; 464 int c;
455 char* temp; 465 char* temp;
456 466
467 enum {
468 SNI_OPTION
469 };
470
457 int option = 0; 471 int option = 0;
458 static struct option longopts[] = { 472 static struct option longopts[] = {
459 {"hostname", required_argument, 0, 'H'}, 473 {"hostname", required_argument, 0, 'H'},
@@ -476,8 +490,10 @@ process_arguments (int argc, char **argv)
476 {"help", no_argument, 0, 'h'}, 490 {"help", no_argument, 0, 'h'},
477 {"lmtp", no_argument, 0, 'L'}, 491 {"lmtp", no_argument, 0, 'L'},
478 {"starttls",no_argument,0,'S'}, 492 {"starttls",no_argument,0,'S'},
493 {"sni", no_argument, 0, SNI_OPTION},
479 {"certificate",required_argument,0,'D'}, 494 {"certificate",required_argument,0,'D'},
480 {"ignore-quit-failure",no_argument,0,'q'}, 495 {"ignore-quit-failure",no_argument,0,'q'},
496 {"proxy",no_argument,0,'r'},
481 {0, 0, 0, 0} 497 {0, 0, 0, 0}
482 }; 498 };
483 499
@@ -494,7 +510,7 @@ process_arguments (int argc, char **argv)
494 } 510 }
495 511
496 while (1) { 512 while (1) {
497 c = getopt_long (argc, argv, "+hVv46Lt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", 513 c = getopt_long (argc, argv, "+hVv46Lrt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q",
498 longopts, &option); 514 longopts, &option);
499 515
500 if (c == -1 || c == EOF) 516 if (c == -1 || c == EOF)
@@ -622,6 +638,16 @@ process_arguments (int argc, char **argv)
622 use_ssl = TRUE; 638 use_ssl = TRUE;
623 use_ehlo = TRUE; 639 use_ehlo = TRUE;
624 break; 640 break;
641 case SNI_OPTION:
642#ifdef HAVE_SSL
643 use_sni = TRUE;
644#else
645 usage (_("SSL support not available - install OpenSSL and recompile"));
646#endif
647 break;
648 case 'r':
649 use_proxy_prefix = TRUE;
650 break;
625 case 'L': 651 case 'L':
626 use_lhlo = TRUE; 652 use_lhlo = TRUE;
627 break; 653 break;
@@ -820,11 +846,15 @@ print_help (void)
820 printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")), 846 printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")),
821 printf (" %s\n", "-F, --fqdn=STRING"); 847 printf (" %s\n", "-F, --fqdn=STRING");
822 printf (" %s\n", _("FQDN used for HELO")); 848 printf (" %s\n", _("FQDN used for HELO"));
849 printf (" %s\n", "-r, --proxy");
850 printf (" %s\n", _("Use PROXY protocol prefix for the connection."));
823#ifdef HAVE_SSL 851#ifdef HAVE_SSL
824 printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]"); 852 printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]");
825 printf (" %s\n", _("Minimum number of days a certificate has to be valid.")); 853 printf (" %s\n", _("Minimum number of days a certificate has to be valid."));
826 printf (" %s\n", "-S, --starttls"); 854 printf (" %s\n", "-S, --starttls");
827 printf (" %s\n", _("Use STARTTLS for the connection.")); 855 printf (" %s\n", _("Use STARTTLS for the connection."));
856 printf (" %s\n", "--sni");
857 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
828#endif 858#endif
829 859
830 printf (" %s\n", "-A, --authtype=STRING"); 860 printf (" %s\n", "-A, --authtype=STRING");
@@ -861,6 +891,6 @@ print_usage (void)
861 printf ("%s\n", _("Usage:")); 891 printf ("%s\n", _("Usage:"));
862 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname); 892 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname);
863 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n"); 893 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
864 printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-v] \n"); 894 printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-r] [--sni] [-v] \n");
865} 895}
866 896
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index 1bd2ca1..c1d675d 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -44,6 +44,8 @@
44# include <sys/wait.h> 44# include <sys/wait.h>
45#endif 45#endif
46 46
47#include "./utils.h"
48
47/** macros **/ 49/** macros **/
48#ifndef WEXITSTATUS 50#ifndef WEXITSTATUS
49# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) 51# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)