From 37b27e058cc8a352a588c865e0319c23f6cb23d5 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 15 Feb 2025 17:45:53 -0500 Subject: [PATCH 1/3] configure.ac: update net-snmp homepage --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6b443263..0308f5cb 100644 --- a/configure.ac +++ b/configure.ac @@ -1491,7 +1491,7 @@ then AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary]) EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)" else - AC_MSG_WARN([Get snmpget from http://net-snmp.sourceforge.net to make check_hpjd and check_snmp plugins]) + AC_MSG_WARN([Get snmpget from https://net-snmp.sourceforge.io/ to make check_hpjd and check_snmp plugins]) fi AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext) From 8246d9c987b45586b5ceca2c81a671c642ad7106 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 15 Feb 2025 17:47:34 -0500 Subject: [PATCH 2/3] configure.ac: use AS_IF in net-snmp tests Not strictly required here, but the AS_IF macro is generally safer because it handles (often unintentional) AC_REQUIRE calls. --- configure.ac | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 0308f5cb..5aaf4eee 100644 --- a/configure.ac +++ b/configure.ac @@ -1486,23 +1486,21 @@ AC_ARG_WITH(snmpget_command, ACX_HELP_STRING([--with-snmpget-command=PATH], [Path to snmpget command]), PATH_TO_SNMPGET=$withval) -if test -n "$PATH_TO_SNMPGET" -then +AS_IF([test -n "$PATH_TO_SNMPGET"], [ AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary]) EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)" -else +], [ AC_MSG_WARN([Get snmpget from https://net-snmp.sourceforge.io/ to make check_hpjd and check_snmp plugins]) -fi +]) AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext) AC_ARG_WITH(snmpgetnext_command, ACX_HELP_STRING([--with-snmpgetnext-command=PATH], [Path to snmpgetnext command]), PATH_TO_SNMPGETNEXT=$withval) -if test -n "$PATH_TO_SNMPGETNEXT" -then +AS_IF([test -n "$PATH_TO_SNMPGETNEXT"], [ AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary]) -fi +]) if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null ) then From 1ceac49405e77b28e75118c5b537db84d73866a5 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 15 Feb 2025 18:10:06 -0500 Subject: [PATCH 3/3] configure.ac: require snmpgetnext for check_snmp PATH_TO_SNMPGETNEXT is used unconditionally in plugins/check_snmp.c, and the build will fail if it is left undefined (that is, if we are building check_snmp but snmpgetnext was neither found on the user's PATH or supplied manually). To avoid this build failure, we now test for snmpgetnext inside the case for snmpget, and skip check_snmp unless BOTH are found. Closes GH-788 --- configure.ac | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 5aaf4eee..ae2ea796 100644 --- a/configure.ac +++ b/configure.ac @@ -1486,20 +1486,29 @@ AC_ARG_WITH(snmpget_command, ACX_HELP_STRING([--with-snmpget-command=PATH], [Path to snmpget command]), PATH_TO_SNMPGET=$withval) -AS_IF([test -n "$PATH_TO_SNMPGET"], [ - AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary]) - EXTRAS="$EXTRAS check_hpjd check_snmp\$(EXEEXT)" -], [ - AC_MSG_WARN([Get snmpget from https://net-snmp.sourceforge.io/ to make check_hpjd and check_snmp plugins]) -]) AC_PATH_PROG(PATH_TO_SNMPGETNEXT,snmpgetnext) AC_ARG_WITH(snmpgetnext_command, ACX_HELP_STRING([--with-snmpgetnext-command=PATH], [Path to snmpgetnext command]), PATH_TO_SNMPGETNEXT=$withval) -AS_IF([test -n "$PATH_TO_SNMPGETNEXT"], [ - AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary]) + +AS_IF([test -n "$PATH_TO_SNMPGET"], [ + AC_DEFINE_UNQUOTED(PATH_TO_SNMPGET,"$PATH_TO_SNMPGET",[path to snmpget binary]) + EXTRAS="$EXTRAS check_hpjd" + + dnl PATH_TO_SNMPGETNEXT is used unconditionally in check_snmp: + dnl + dnl https://github.com/nagios-plugins/nagios-plugins/issues/788 + dnl + AS_IF([test -n "$PATH_TO_SNMPGETNEXT"], [ + AC_DEFINE_UNQUOTED(PATH_TO_SNMPGETNEXT,"$PATH_TO_SNMPGETNEXT",[path to snmpgetnext binary]) + EXTRAS="$EXTRAS check_snmp\$(EXEEXT)" + ], [ + AC_MSG_WARN([Get snmpgetnext from https://net-snmp.sourceforge.io/ to build the check_snmp plugin]) + ]) +], [ + AC_MSG_WARN([Get snmpget from https://net-snmp.sourceforge.io/ to build the check_hpjd and check_snmp plugins]) ]) if ( $PERL -M"Net::SNMP 3.6" -e 'exit' 2>/dev/null )