From 9f15dac8e789a4b13d4f9e8897ee03fee84f494a Mon Sep 17 00:00:00 2001 From: phowen Date: Wed, 26 Apr 2017 13:40:27 +0100 Subject: add extra output to pgsql check --- plugins/check_pgsql.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index c26cd439..05fdc156 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c @@ -517,7 +517,10 @@ print_help (void) printf (" %s\n", _("connecting to the server. The result from the query has to be numeric.")); printf (" %s\n", _("Multiple SQL commands, separated by semicolon, are allowed but the result ")); printf (" %s\n", _("of the last command is taken into account only. The value of the first")); - printf (" %s\n\n", _("column in the first row is used as the check result.")); + printf (" %s\n", _("column in the first row is used as the check result. If a second column is")); + printf (" %s\n", _("present in the result set, this is added to the plugin output with a")); + printf (" %s\n", _("prefix of \"Extra Info:\". This information can be displayed in the system")); + printf (" %s\n\n", _("executing the plugin.")); printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual")); 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) PGresult *res; char *val_str; + char *extra_info; double value; char *endptr = NULL; @@ -621,6 +625,12 @@ do_query (PGconn *conn, char *query) printf ("|query=%f;%s;%s;;\n", value, query_warning ? query_warning : "", query_critical ? query_critical : ""); + if (PQnfields (res) > 1) { + extra_info = PQgetvalue (res, 0, 1); + if (extra_info != NULL) { + printf ("Extra Info: %s\n", extra_info); + } + } return my_status; } -- cgit v1.2.3-74-g34f1 From 1568940b3ea871ffb29d9bf1990cfa0528712b8d Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 5 Mar 2023 10:09:45 +0100 Subject: Implicit function declarations --- plugins/runcmd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/runcmd.c b/plugins/runcmd.c index 1bd2ca1f..c1d675d0 100644 --- a/plugins/runcmd.c +++ b/plugins/runcmd.c @@ -44,6 +44,8 @@ # include #endif +#include "./utils.h" + /** macros **/ #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) -- cgit v1.2.3-74-g34f1 From cee364f219ed73c75a4c4bfb5ac148b8a721780c Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 5 Mar 2023 15:50:48 +0100 Subject: Remove unused variable from check_http --- plugins/check_http.c | 1 - 1 file changed, 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_http.c b/plugins/check_http.c index 8c03bc8b..6956a726 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -1391,7 +1391,6 @@ char *unchunk_content(const char *content) { // https://en.wikipedia.org/wiki/Chunked_transfer_encoding // https://www.rfc-editor.org/rfc/rfc7230#section-4.1 char *result = NULL; - size_t content_length = strlen(content); char *start_of_chunk; char* end_of_chunk; long size_of_chunk; -- cgit v1.2.3-74-g34f1 From 6c78f0b5ea82a4bea71ae2024f27d3916175a7a2 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 12 Mar 2023 14:16:35 +0100 Subject: Fixes for -Wunused * lib/utils_base.c * plugins/check_curl.c * plugins-root/check_dhcp.c Removed a line which theoretically can not do anything, but there was comment which indicated something else. Still trying this though. --- lib/utils_base.c | 8 ++++---- plugins-root/check_dhcp.c | 4 ---- plugins/check_curl.c | 5 ++--- 3 files changed, 6 insertions(+), 11 deletions(-) (limited to 'plugins') diff --git a/lib/utils_base.c b/lib/utils_base.c index eb1823bb..c458cf61 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c @@ -24,7 +24,7 @@ * *****************************************************************************/ -#include "common.h" +#include "../plugins/common.h" #include #include "utils_base.h" #include @@ -319,18 +319,18 @@ char *np_extract_value(const char *varlist, const char *name, char sep) { while (1) { /* Strip any leading space */ - for (varlist; isspace(varlist[0]); varlist++); + for (; isspace(varlist[0]); varlist++); if (strncmp(name, varlist, strlen(name)) == 0) { varlist += strlen(name); /* strip trailing spaces */ - for (varlist; isspace(varlist[0]); varlist++); + for (; isspace(varlist[0]); varlist++); if (varlist[0] == '=') { /* We matched the key, go past the = sign */ varlist++; /* strip leading spaces */ - for (varlist; isspace(varlist[0]); varlist++); + for (; isspace(varlist[0]); varlist++); if (tmp = index(varlist, sep)) { /* Value is delimited by a comma */ diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index ad673237..147db6b3 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c @@ -470,10 +470,6 @@ int send_dhcp_discover(int sock){ packet_xid=random(); discover_packet.xid=htonl(packet_xid); - /**** WHAT THE HECK IS UP WITH THIS?!? IF I DON'T MAKE THIS CALL, ONLY ONE SERVER RESPONSE IS PROCESSED!!!! ****/ - /* downright bizzarre... */ - ntohl(discover_packet.xid); - /*discover_packet.secs=htons(65535);*/ discover_packet.secs=0xFF; diff --git a/plugins/check_curl.c b/plugins/check_curl.c index be5740d7..100a97aa 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -2217,11 +2217,10 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line) if( strchr( p, '.' ) != NULL ) { /* HTTP 1.x case */ - char *ppp; - ppp = strtok( p, "." ); + strtok( p, "." ); status_line->http_major = (int)strtol( p, &pp, 10 ); if( *pp != '\0' ) { free( first_line_buf ); return -1; } - ppp = strtok( NULL, " " ); + strtok( NULL, " " ); status_line->http_minor = (int)strtol( p, &pp, 10 ); if( *pp != '\0' ) { free( first_line_buf ); return -1; } p += 4; /* 1.x SP */ -- cgit v1.2.3-74-g34f1 From b2659391aba7e4a79b678aba5cc21b443626f81f Mon Sep 17 00:00:00 2001 From: Lorenz Kästle Date: Wed, 26 Apr 2023 10:13:51 +0200 Subject: check_nt: change encoding from latin1 to utf8 --- plugins/check_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_nt.c b/plugins/check_nt.c index 59c135db..babe3b64 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c @@ -341,7 +341,7 @@ int main(int argc, char **argv){ 2) If the counter you're going to measure is percent-based, the code will detect the percent sign in its name and will attribute minimum (0%) and maximum (100%) - values automagically, as well the ¨%" sign to graph units. + values automagically, as well the ¨%" sign to graph units. 3) OTOH, if the counter is "absolute", you'll have to provide the following the counter unit - that is, the dimensions of the counter you're getting. Examples: -- cgit v1.2.3-74-g34f1 From fcf68d702e590bd3e58fb7556f420330ddf0a0ae Mon Sep 17 00:00:00 2001 From: Lorenz <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 27 Apr 2023 00:42:30 +0200 Subject: Update plugins/check_nt.c Co-authored-by: datamuc --- plugins/check_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_nt.c b/plugins/check_nt.c index babe3b64..d73d83ce 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c @@ -341,7 +341,7 @@ int main(int argc, char **argv){ 2) If the counter you're going to measure is percent-based, the code will detect the percent sign in its name and will attribute minimum (0%) and maximum (100%) - values automagically, as well the ¨%" sign to graph units. + values automagically, as well the "%" sign to graph units. 3) OTOH, if the counter is "absolute", you'll have to provide the following the counter unit - that is, the dimensions of the counter you're getting. Examples: -- cgit v1.2.3-74-g34f1 From d10ee31d89c2c599ee4c502e82d632aef8554020 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle Date: Fri, 28 Apr 2023 16:51:39 +0200 Subject: Typo in check_mysql --- plugins/check_mysql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 0cba50e6..6cfa70ed 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c @@ -551,7 +551,7 @@ print_help (void) printf (" %s\n", _("Exit with CRITICAL status if slave server is more then INTEGER seconds")); printf (" %s\n", _("behind master")); printf (" %s\n", "-l, --ssl"); - printf (" %s\n", _("Use ssl encryptation")); + printf (" %s\n", _("Use ssl encryption")); printf (" %s\n", "-C, --ca-cert=STRING"); printf (" %s\n", _("Path to CA signing the cert")); printf (" %s\n", "-a, --cert=STRING"); -- cgit v1.2.3-74-g34f1 From bf8eb6dcc7f9d1318ddeac16fe62a5b5f818524b Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 26 May 2023 08:43:24 +0200 Subject: check_disk: Display SI units correctly --- plugins/check_disk.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/check_disk.c b/plugins/check_disk.c index a99f35e3..39dc6cd2 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -626,21 +626,36 @@ process_arguments (int argc, char **argv) if (! strcasecmp (optarg, "bytes")) { mult = (uintmax_t)1; units = strdup ("B"); - } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) { + } else if (!strcmp(optarg, "KiB")) { mult = (uintmax_t)1024; - units = strdup ("kiB"); - } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) { + units = strdup ("KiB"); + } else if (! strcmp (optarg, "kB")) { + mult = (uintmax_t)1000; + units = strdup ("kB"); + } else if (!strcmp(optarg, "MiB")) { mult = (uintmax_t)1024 * 1024; units = strdup ("MiB"); - } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) { + } else if (! strcmp (optarg, "MB")) { + mult = (uintmax_t)1000 * 1000; + units = strdup ("MB"); + } else if (!strcmp(optarg, "GiB")) { mult = (uintmax_t)1024 * 1024 * 1024; units = strdup ("GiB"); - } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) { + } else if (! strcmp (optarg, "GB")){ + mult = (uintmax_t)1000 * 1000 * 1000; + units = strdup ("GB"); + } else if (!strcmp(optarg, "TiB")) { mult = (uintmax_t)1024 * 1024 * 1024 * 1024; units = strdup ("TiB"); - } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) { + } else if (! strcmp (optarg, "TB")) { + mult = (uintmax_t)1000 * 1000 * 1000 * 1000; + units = strdup ("TB"); + } else if (!strcmp(optarg, "PiB")) { mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024; units = strdup ("PiB"); + } else if (! strcmp (optarg, "PB")){ + mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000; + units = strdup ("PB"); } else { die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); } -- cgit v1.2.3-74-g34f1 From 10863265324a9a9fdf8ce771271af15b7e2f5a4a Mon Sep 17 00:00:00 2001 From: Platon Pronko Date: Fri, 19 May 2023 15:05:02 +0800 Subject: check_mysql: handle ER_ACCESS_DENIED_NO_PASSWORD_ERROR if ignore_auth=1 In some situations MySQL might return ER_ACCESS_DENIED_NO_PASSWORD_ERROR instead of ER_ACCESS_DENIED_ERROR. Semantically these errors are the same. --- plugins/check_mysql.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 6cfa70ed..91e150fb 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c @@ -138,7 +138,10 @@ main (int argc, char **argv) mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers); /* establish a connection to the server and error checking */ if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) { - if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR) + /* Depending on internally-selected auth plugin MySQL might return */ + /* ER_ACCESS_DENIED_NO_PASSWORD_ERROR or ER_ACCESS_DENIED_ERROR. */ + /* Semantically these errors are the same. */ + if (ignore_auth && (mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR || mysql_errno (&mysql) == ER_ACCESS_DENIED_NO_PASSWORD_ERROR)) { printf("MySQL OK - Version: %s (protocol %d)\n", mysql_get_server_info(&mysql), -- cgit v1.2.3-74-g34f1 From ce85affd208cd8c873dd88c17b8d3d0540c8872e Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Thu, 13 Dec 2018 18:24:53 +0100 Subject: check_smtp: Add option to prefix PROXY header This enables checks of SMTP servers that expect the haproxy PROXY protocol: -o smtpd_upstream_proxy_protocol=haproxy. Backported from nagios-plugins: https://github.com/nagios-plugins/nagios-plugins/commit/3246efe923b5482c5024c40e593ce942e628a3cb --- plugins/check_smtp.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index eaa7eeba..addabfc6 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -52,6 +52,7 @@ int days_till_exp_warn, days_till_exp_crit; enum { SMTP_PORT = 25 }; +#define PROXY_PREFIX "PROXY TCP4 0.0.0.0 0.0.0.0 25 25\r\n" #define SMTP_EXPECT "220" #define SMTP_HELO "HELO " #define SMTP_EHLO "EHLO " @@ -102,6 +103,7 @@ double critical_time = 0; int check_critical_time = FALSE; int verbose = 0; int use_ssl = FALSE; +short use_proxy_prefix = FALSE; short use_ehlo = FALSE; short use_lhlo = FALSE; short ssl_established = 0; @@ -184,6 +186,13 @@ main (int argc, char **argv) if (result == STATE_OK) { /* we connected */ + /* If requested, send PROXY header */ + if (use_proxy_prefix) { + if (verbose) + printf ("Sending header %s\n", PROXY_PREFIX); + send(sd, PROXY_PREFIX, strlen(PROXY_PREFIX), 0); + } + /* watch for the SMTP connection string and */ /* return a WARNING status if we couldn't read any data */ if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) { @@ -478,6 +487,7 @@ process_arguments (int argc, char **argv) {"starttls",no_argument,0,'S'}, {"certificate",required_argument,0,'D'}, {"ignore-quit-failure",no_argument,0,'q'}, + {"proxy",no_argument,0,'r'}, {0, 0, 0, 0} }; @@ -494,7 +504,7 @@ process_arguments (int argc, char **argv) } while (1) { - c = getopt_long (argc, argv, "+hVv46Lt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", + c = getopt_long (argc, argv, "+hVv46Lrt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", longopts, &option); if (c == -1 || c == EOF) @@ -621,6 +631,9 @@ process_arguments (int argc, char **argv) use_ssl = TRUE; use_ehlo = TRUE; break; + case 'r': + use_proxy_prefix = TRUE; + break; case 'L': use_lhlo = TRUE; break; @@ -819,6 +832,8 @@ print_help (void) printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")), printf (" %s\n", "-F, --fqdn=STRING"); printf (" %s\n", _("FQDN used for HELO")); + printf (" %s\n", "-r, --proxy"); + printf (" %s\n", _("Use PROXY protocol prefix for the connection.")); #ifdef HAVE_SSL printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]"); printf (" %s\n", _("Minimum number of days a certificate has to be valid.")); -- cgit v1.2.3-74-g34f1 From 6d5e81fcbadbef557cf3f61ce7fd6ef73e25683e Mon Sep 17 00:00:00 2001 From: Franz Schwartau Date: Mon, 12 Jun 2023 15:55:32 +0200 Subject: check_smtp: add missing -r option in usage --- plugins/check_smtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index addabfc6..a1debd25 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -875,6 +875,6 @@ print_usage (void) printf ("%s\n", _("Usage:")); printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname); printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n"); - printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-v] \n"); + printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-r] [-v] \n"); } -- cgit v1.2.3-74-g34f1 From d762fb137401491270c898febe07e34ba200e388 Mon Sep 17 00:00:00 2001 From: Franz Schwartau Date: Mon, 12 Jun 2023 22:09:54 +0200 Subject: check_smtp: update year in copyright header --- plugins/check_smtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index a1debd25..70191ad9 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -3,7 +3,7 @@ * Monitoring check_smtp plugin * * License: GPL -* Copyright (c) 2000-2007 Monitoring Plugins Development Team +* Copyright (c) 2000-2023 Monitoring Plugins Development Team * * Description: * -- cgit v1.2.3-74-g34f1 From 252272344ea63a164eabc1631e9b77450d2b1c4b Mon Sep 17 00:00:00 2001 From: Arkadiusz MiÅ›kiewicz Date: Fri, 30 Aug 2019 11:30:10 +0200 Subject: Add support for SNI in check_smtp. Add support for SSL/TLS hostname extension support (SNI) for check_smtp plugin. Backported from nagios-plugins: https://github.com/nagios-plugins/nagios-plugins/commit/9f1628f4b5525335ce1d6e48e8ac8b07d0757f82 --- plugins/check_smtp.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 70191ad9..c0ab838a 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -103,6 +103,7 @@ double critical_time = 0; int check_critical_time = FALSE; int verbose = 0; int use_ssl = FALSE; +int use_sni = FALSE; short use_proxy_prefix = FALSE; short use_ehlo = FALSE; short use_lhlo = FALSE; @@ -234,7 +235,7 @@ main (int argc, char **argv) smtp_quit(); return STATE_UNKNOWN; } - result = np_net_ssl_init(sd); + result = np_net_ssl_init_with_hostname(sd, (use_sni ? server_address : NULL)); if(result != STATE_OK) { printf (_("CRITICAL - Cannot create SSL context.\n")); close(sd); @@ -463,6 +464,10 @@ process_arguments (int argc, char **argv) int c; char* temp; + enum { + SNI_OPTION + }; + int option = 0; static struct option longopts[] = { {"hostname", required_argument, 0, 'H'}, @@ -485,6 +490,7 @@ process_arguments (int argc, char **argv) {"help", no_argument, 0, 'h'}, {"lmtp", no_argument, 0, 'L'}, {"starttls",no_argument,0,'S'}, + {"sni", no_argument, 0, SNI_OPTION}, {"certificate",required_argument,0,'D'}, {"ignore-quit-failure",no_argument,0,'q'}, {"proxy",no_argument,0,'r'}, @@ -631,6 +637,13 @@ process_arguments (int argc, char **argv) use_ssl = TRUE; use_ehlo = TRUE; break; + case SNI_OPTION: +#ifdef HAVE_SSL + use_sni = TRUE; +#else + usage (_("SSL support not available - install OpenSSL and recompile")); +#endif + break; case 'r': use_proxy_prefix = TRUE; break; @@ -839,6 +852,8 @@ print_help (void) printf (" %s\n", _("Minimum number of days a certificate has to be valid.")); printf (" %s\n", "-S, --starttls"); printf (" %s\n", _("Use STARTTLS for the connection.")); + printf (" %s\n", "--sni"); + printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)")); #endif printf (" %s\n", "-A, --authtype=STRING"); @@ -875,6 +890,6 @@ print_usage (void) printf ("%s\n", _("Usage:")); printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname); printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n"); - printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-r] [-v] \n"); + printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-r] [--sni] [-v] \n"); } -- cgit v1.2.3-74-g34f1