From bc8d4ecfe25dc9a485a197cd4d985bff5d5daaa0 Mon Sep 17 00:00:00 2001 From: nemo Date: Sat, 1 Jun 2019 11:05:25 +0200 Subject: [PATCH] Add sysContact, informsink and trap2sink verifications for SNMPD. --- recipes/recipe_check_snmp_config.sh | 62 +++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/recipes/recipe_check_snmp_config.sh b/recipes/recipe_check_snmp_config.sh index c23ae28..c9e12b4 100755 --- a/recipes/recipe_check_snmp_config.sh +++ b/recipes/recipe_check_snmp_config.sh @@ -64,3 +64,65 @@ case ${?} in esac +check_value_in_conf_file "SNMP" "/etc/snmp/snmpd.conf" "informsink" "${NAME_MASTER_MONITORING}[[:space:]]*public" + +case ${?} in +0) # OK, nothing to do + ;; +1) # Error (wrong number of param or other) + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during informsink check with function check_value_in_conf_file, maybe incorrect number of parameter;" + ;; +2) # Unexpected value is set + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" informsink are not well configured or has other value, set 'informsink ${NAME_MASTER_MONITORING} public;" + ;; +3) # All expected values are NOT configured + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" informsink are not well configured, set 'informsink ${NAME_MASTER_MONITORING} public';" + ;; +*) # Unknown return code... + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check informsink;" + ;; +esac + + +check_value_in_conf_file "SNMP" "/etc/snmp/snmpd.conf" "sysLocation" "${DC_for_function_check_value_in_conf_file}" + +case ${?} in +0) # OK, nothing to do + ;; +1) # Error (wrong number of param or other) + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during sysLocation check with function check_value_in_conf_file, maybe incorrect number of parameter;" + ;; +2) # Unexpected value is set + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" sysLocation are not well configured or has other value, set 'sysLocation ${DC}';" + ;; +3) # All expected values are NOT configured + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" sysLocation are not well configured, set 'sysLocation ${DC}';" + ;; +*) # Unknown return code... + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check sysLocation;" + ;; +esac + + +check_value_in_conf_file "SNMP" "/etc/snmp/snmpd.conf" "sysContact" "${ENTITY_for_function_check_value_in_conf_file}[[:space:]]*<${MAIL_ALIAS_ROOT}>" + +case ${?} in +0) # OK, nothing to do + ;; +1) # Error (wrong number of param or other) + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during sysContact check with function check_value_in_conf_file, maybe incorrect number of parameter;" + ;; +2) # Unexpected value is set + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" sysContact are not well configured or has other value, set 'sysContact ${ENTITY} <${MAIL_ALIAS_ROOT}>';" + ;; +3) # All expected values are NOT configured + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" sysContact are not well configured, set 'sysContact ${ENTITY} <${MAIL_ALIAS_ROOT}>';" + ;; +*) # Unknown return code... + SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check sysContact;" + ;; +esac + + + +