parent
5976e4c7bd
commit
1dbccd4f0a
@ -1,33 +1,45 @@
|
||||
print_config_title 'CHECK MAIL ALIAS CONFIG'
|
||||
|
||||
# This does not check if send mail works and if alias have been reloaded
|
||||
# Check /etc/mail/aliases config file
|
||||
echo -e "Check ${BLUE}MAIL ALIAS${NC} config file /etc/mail/aliases"
|
||||
# Check /etc/mail/aliases config file, checked param : root/operator
|
||||
|
||||
# Check if root alias is configured
|
||||
grep -q -E "^[[:space:]]*root:?[[:space:]]*${MAIL_ALIAS_ROOT}[[:space:]]*$" /etc/mail/aliases
|
||||
# root
|
||||
check_value_in_conf_file "MUNIN" "/etc/mail/aliases" "root" "${MAIL_ALIAS_ROOT}"
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
1) # Error (wrong number of param or other)
|
||||
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error during root alias check with function check_value_in_conf_file, maybe incorrect number of parameter;"
|
||||
;;
|
||||
2) # Unexpected value is set
|
||||
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" root alias is not well configured or has other value, set root: ${MAIL_ALIAS_ROOT};"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" root alias is not well configured, set root: ${MAIL_ALIAS_ROOT};"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check root alias;"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Root alias not configured
|
||||
if [ $RC -ne 0 ]
|
||||
then
|
||||
MAIL_ALIAS_CONFIG_CHECK_FAILED="${MAIL_ALIAS_CONFIG_CHECK_FAILED} root alias NOT CONFIGURED or WRONG mail address, check /etc/mail/aliases and reload aliases"
|
||||
echo -e "${RED}Mail alias root NOT CONFIGURED or WRONG mail address : check KO${NC}\n"
|
||||
|
||||
# Root alias configured
|
||||
else
|
||||
# Check multiple root alias line in the file
|
||||
line_number=$(grep -E "^[[:space:]]*root:?" /etc/mail/aliases |wc -l)
|
||||
|
||||
# If linue_number different than 1
|
||||
if [ $line_number -ne 1 ]
|
||||
then
|
||||
MAIL_ALIAS_CONFIG_CHECK_FAILED="${MAIL_ALIAS_CONFIG_CHECK_FAILED} more than 1 line for root mail alias, check /etc/mail/aliases and reload aliases"
|
||||
echo -e "${RED}More than 1 line for root mail alias : check KO${NC}\n"
|
||||
else
|
||||
echo -e "${GREEN}Mail alias root CONFIGURED : check OK${NC}\n"
|
||||
fi
|
||||
fi
|
||||
# root
|
||||
check_value_in_conf_file "MUNIN" "/etc/mail/aliases" "operator" "${MAIL_ALIAS_ROOT}"
|
||||
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
1) # Error (wrong number of param or other)
|
||||
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error during operator alias check with function check_value_in_conf_file, maybe incorrect number of parameter;"
|
||||
;;
|
||||
2) # Unexpected value is set
|
||||
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" operator alias is not well configured or has other value, set operator: ${MAIL_ALIAS_ROOT};"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" operator alias is not well configured, set operator: ${MAIL_ALIAS_ROOT};"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check operator alias;"
|
||||
;;
|
||||
esac
|
||||
|
@ -1,35 +1,67 @@
|
||||
print_config_title 'CHECK NRPE BASIC CONFIG'
|
||||
|
||||
# Check /etc/nagios/nrpe.cfg config file
|
||||
# Check /etc/nagios/nrpe.cfg config file, checked parameters : allowed_hosts/nrpe_user/nrpe_group
|
||||
# This does not check if NRPE 'monitoring server' has configured this machine
|
||||
echo -e "Check ${BLUE}NRPE${NC} config file /etc/nagios/nrpe.cfg"
|
||||
|
||||
# Check if allowed_hosts exist but different than expected (success if return code = 1)
|
||||
grep "^[[:space:]]*allowed_hosts=" /etc/nagios/nrpe.cfg | grep -q -v -e "^[[:space:]]*allowed_hosts=127.0.0.1,[[:space:]]*${IPV4_ADMIN_NETWORK}0/24,[[:space:]]*${IPV6_ADMIN_NETWORK}:/64[[:space:]]*$" -e "^[[:space:]]*allowed_hosts=127.0.0.1,[[:space:]]*${IPV6_ADMIN_NETWORK}:/64,[[:space:]]*${IPV4_ADMIN_NETWORK}0/24[[:space:]]*$"
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
|
||||
# allowed_hosts exist but different than expected
|
||||
if [ $RC -eq 0 ]
|
||||
then
|
||||
NRPE_CONFIG_CHECK_FAILED="${NRPE_CONFIG_CHECK_FAILED} allowed_hosts misconfigured, expected : 'allowed_hosts=127.0.0.1, ${IPV4_ADMIN_NETWORK}0/24, ${IPV6_ADMIN_NETWORK}:/64'"
|
||||
echo -e "${RED}Service NRPE has BAD CONFIGURATION for allowed_hosts, exist but different than expected : check KO${NC}\n"
|
||||
# allowed_hosts well configured or does not exist
|
||||
else
|
||||
# Check if allowed_hosts is well configured (success if return code = 0)
|
||||
grep -q -e "^[[:space:]]*allowed_hosts=127.0.0.1,[[:space:]]*${IPV4_ADMIN_NETWORK}0/24,[[:space:]]*${IPV6_ADMIN_NETWORK}:/64[[:space:]]*$" -e "^[[:space:]]*allowed_hosts=127.0.0.1,[[:space:]]*${IPV6_ADMIN_NETWORK}:/64,[[:space:]]*${IPV4_ADMIN_NETWORK}0/24[[:space:]]*$" /etc/nagios/nrpe.cfg
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
|
||||
# allowed_hosts miscondigured or string mismatch
|
||||
if [ $RC -ne 0 ]
|
||||
then
|
||||
NRPE_CONFIG_CHECK_FAILED="${NRPE_CONFIG_CHECK_FAILED} allowed_hosts misconfigured, expected : 'allowed_hosts=127.0.0.1, ${IPV4_ADMIN_NETWORK}0/24, ${IPV6_ADMIN_NETWORK}:/64'"
|
||||
echo -e "${RED}Service NRPE has BAD CONFIGURATION for allowed_hosts, expected configuration not found : check KO${NC}\n"
|
||||
# allowed_hosts well configured
|
||||
else
|
||||
echo -e "${GREEN}Service NRPE has GOOD CONFIGURATION for allowed_hosts : check OK${NC}\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
# allowed_hosts
|
||||
check_value_in_conf_file "NRPE" "/etc/nagios/nrpe.cfg" "allowed_hosts" "127.0.0.1,[[:space:]]*${IPV4_ADMIN_NETWORK}0/24,[[:space:]]*${IPV6_ADMIN_NETWORK}:/64"
|
||||
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
1) # Error (wrong number of param or other)
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error during allowed_hosts check with function check_value_in_conf_file, maybe incorrect number of parameter;"
|
||||
;;
|
||||
2) # Unexpected value is set
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" allowed_hosts are not well configured or has other value, set 'allowed_hosts=127.0.0.1, ${IPV4_ADMIN_NETWORK}0/24, ${IPV6_ADMIN_NETWORK}:/64';"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" allowed_hosts are not well configured, set 'allowed_hosts=127.0.0.1, ${IPV4_ADMIN_NETWORK}0/24, ${IPV6_ADMIN_NETWORK}:/64';"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check allowed_hosts;"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# nrpe_user
|
||||
check_value_in_conf_file "NRPE" "/etc/nagios/nrpe.cfg" "nrpe_user" "nagios"
|
||||
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
1) # Error (wrong number of param or other)
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error during nrpe_user check with function check_value_in_conf_file, maybe incorrect number of parameter;"
|
||||
;;
|
||||
2) # Unexpected value is set
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" nrpe_user is not well configured or has other value, set 'nrpe_user=nagios';"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" nrpe_user is not well configured, set 'nrpe_user=nagios';"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check nrpe_user;"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# nrpe_group
|
||||
check_value_in_conf_file "NRPE" "/etc/nagios/nrpe.cfg" "nrpe_group" "nagios"
|
||||
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
1) # Error (wrong number of param or other)
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error during nrpe_group check with function check_value_in_conf_file, maybe incorrect number of parameter;"
|
||||
;;
|
||||
2) # Unexpected value is set
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" nrpe_group is not well configured or has other value, set 'nrpe_group=nagios';"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" nrpe_group is not well configured, set 'nrpe_group=nagios';"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check nrpe_group;"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -1,83 +1,111 @@
|
||||
GREP="/bin/grep"
|
||||
ECHO="/bin/echo"
|
||||
EMERGE="/usr/bin/emerge"
|
||||
NSLOOKUP="/usr/bin/nslookup"
|
||||
IP="/bin/ip"
|
||||
HOSTNAME="/bin/hostname"
|
||||
AWK="/bin/awk"
|
||||
SED="/bin/sed"
|
||||
CUT="/bin/cut"
|
||||
TR="/bin/tr"
|
||||
PING="/bin/ping"
|
||||
# Set absolute PATH for tools
|
||||
export GREP="/bin/grep"
|
||||
export ECHO="/bin/echo"
|
||||
export EMERGE="/usr/bin/emerge"
|
||||
export NSLOOKUP="/usr/bin/nslookup"
|
||||
export IP="/bin/ip"
|
||||
export HOSTNAME="/bin/hostname"
|
||||
export AWK="/bin/awk"
|
||||
export SED="/bin/sed"
|
||||
export CUT="/bin/cut"
|
||||
export TR="/bin/tr"
|
||||
export PING="/bin/ping"
|
||||
export CURL="/usr/bin/curl"
|
||||
export JQ="/usr/bin/jq"
|
||||
|
||||
# Packages to check (it's a list to simplify comment)
|
||||
PACKAGES=(
|
||||
# 'virtual/ssh'
|
||||
# 'app-admin/rsyslog'
|
||||
# 'net-misc/ntp'
|
||||
# 'app-backup/borgbackup'
|
||||
# 'virtual/cron'
|
||||
# 'sys-process/cronie'
|
||||
# 'net-analyzer/munin'
|
||||
# 'app-portage/eix',
|
||||
# 'app-portage/gentoolkit',
|
||||
# 'app-portage/genlop',
|
||||
# 'app-misc/tmux',
|
||||
# 'net-analyzer/tcpdump',
|
||||
# 'app-editors/vim',
|
||||
# 'sys-process/htop-2.2.0',
|
||||
# 'app-admin/sysklogd'
|
||||
# 'dev-vcs/git'
|
||||
# 'net-analyzer/nrpe'
|
||||
# 'net-analyzer/net-snmp'
|
||||
# 'net-dns/bind-tools'
|
||||
# 'dev-vcs/git'
|
||||
# 'mail-mta/postfix'
|
||||
# 'mail-mta/eeeepostfix'
|
||||
)
|
||||
export PACKAGES="
|
||||
virtual/ssh
|
||||
app-admin/rsyslog
|
||||
net-misc/ntp
|
||||
app-backup/borgbackup
|
||||
virtual/cron
|
||||
sys-process/cronie
|
||||
net-analyzer/munin
|
||||
app-portage/eix'
|
||||
app-portage/gentoolkit'
|
||||
app-portage/genlop'
|
||||
app-misc/tmux'
|
||||
net-analyzer/tcpdump'
|
||||
app-editors/vim'
|
||||
sys-process/htop-2.2.0'
|
||||
app-admin/sysklogd
|
||||
dev-vcs/git
|
||||
net-analyzer/nrpe
|
||||
net-analyzer/net-snmp
|
||||
net-dns/bind-tools
|
||||
dev-vcs/git
|
||||
mail-mta/postfix
|
||||
mail-mta/postfix
|
||||
app-admin/sudo
|
||||
"
|
||||
|
||||
# Package to check if it's a physical machine
|
||||
PACKAGES_PHYSICAL=(
|
||||
'sys-apps/smartmontools'
|
||||
)
|
||||
export PACKAGES_PHYSICAL="
|
||||
sys-apps/smartmontools
|
||||
"
|
||||
|
||||
NAMES_TO_RESOLV_AND_PING=(
|
||||
'grifon.fr'
|
||||
'arn-fai.net'
|
||||
'grifonfesfdsfdsf.fr'
|
||||
)
|
||||
# Hostname to be resolved in recipes
|
||||
export NAMES_TO_RESOLV_AND_PING="
|
||||
grifon.fr
|
||||
arn-fai.net
|
||||
grifonfesfdsfdsf.fr
|
||||
"
|
||||
|
||||
RESOLVERS=(
|
||||
'2a00:5884::7'
|
||||
'89.234.186.4'
|
||||
)
|
||||
# Resolver to check if they are in /etc/resolv.conf
|
||||
export RESOLVERS="
|
||||
2a00:5884::7
|
||||
89.234.186.4
|
||||
"
|
||||
|
||||
SERVICES_TO_CHECK=(
|
||||
'rsyslog'
|
||||
'ntpd'
|
||||
'munin-node'
|
||||
'iptables'
|
||||
'ip6tables'
|
||||
'sshd'
|
||||
'postfix'
|
||||
'nrpe'
|
||||
'snmpd'
|
||||
'hostname'
|
||||
)
|
||||
# Services to check if they are working/running
|
||||
export SERVICES_TO_CHECK="
|
||||
rsyslog
|
||||
ntpd
|
||||
munin-node
|
||||
iptables
|
||||
ip6tables
|
||||
sshd
|
||||
postfix
|
||||
nrpe
|
||||
snmpd
|
||||
hostname
|
||||
"
|
||||
|
||||
SERVICES_TO_CHECK_PHYSICAL=(
|
||||
'smard'
|
||||
)
|
||||
# Same but with physical host services
|
||||
export SERVICES_TO_CHECK_PHYSICAL="
|
||||
smard
|
||||
"
|
||||
|
||||
IPV4_ADMIN_NETWORK="172.16.0."
|
||||
IPV6_ADMIN_NETWORK="fd01:1e02:40:"
|
||||
# Admin network
|
||||
export IPV4_ADMIN_NETWORK="111.111.111."
|
||||
export IPV6_ADMIN_NETWORK="1111:1111:1111:"
|
||||
|
||||
NAME_MASTER_MONITORING=""
|
||||
# AS IPs ranges
|
||||
export RANGE_IPV4_1_NETWORK="111.111.111."
|
||||
export RANGE_IPV4_2_NETWORK="111.111.112."
|
||||
export RANGE_IPV6_NETWORK="1111:1111:"
|
||||
|
||||
IPV4_MASTER_MUNIN='^172\\\.16\\\.0\\\.13\$'
|
||||
IPV6_MASTER_MUNIN='^fd01:1e02:40::3\$'
|
||||
IPV4_MASTER_MUNIN_PRINT='^172\.16\.0\.13$'
|
||||
IPV6_MASTER_MUNIN_PRINT='^fd01:1e02:40::3$'
|
||||
# Admin hostname of the Monitoring server (Munin + libreNMS)
|
||||
export NAME_MASTER_MONITORING="conan.grif"
|
||||
|
||||
MAIL_ALIAS_ROOT="admin6@email.emailr"
|
||||
# Address of the Monitoring server in Munin's configuration format
|
||||
export IPV4_MASTER_MUNIN='^111\\\.111\\\.111\\\.111\$'
|
||||
export IPV6_MASTER_MUNIN='^111:111:111::1\$'
|
||||
|
||||
# root/operator aliases for mailing
|
||||
export MAIL_ALIAS_ROOT="adminsys@grifon.fr"
|
||||
|
||||
# General informations
|
||||
export DC="The DC of City"
|
||||
export DC_for_function_check_value_in_conf_file=$(echo -e ${DC} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | sed -e 's/[[:space:]]/[[:space:]]*/g')
|
||||
export ENTITY="Entity"
|
||||
export ENTITY_for_function_check_value_in_conf_file=$(echo -e ${ENTITY} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | sed -e 's/[[:space:]]/[[:space:]]*/g')
|
||||
|
||||
|
||||
# User and password to request a token on phpIPAM API
|
||||
export USER_IPAM='user'
|
||||
export PASSWORD_IPAM='password'
|
||||
|
||||
# URL of the API
|
||||
export URL="https://ipam.example/api/${USER_IPAM}"
|
||||
|
Loading…
Reference in new issue