Compare commits

...

2 Commits

Author SHA1 Message Date
c0ad1c5d16 Merge branch 'check-log-ulog' into 'master'
check_log - Prise en compte logs ulogd

See merge request zorval/scripts/check-nrpe!1
2021-04-24 08:16:00 +00:00
85e8cd4eed check_log - Prise en compte logs ulogd 2021-04-24 08:16:00 +00:00
2 changed files with 28 additions and 17 deletions

View File

@ -21,7 +21,6 @@ command[check_load] = /usr/local/bin/check_load
command[check_memory] = /usr/local/bin/check_memory command[check_memory] = /usr/local/bin/check_memory
command[check_systemd] = /usr/local/bin/check_systemd command[check_systemd] = /usr/local/bin/check_systemd
command[check_service] = /usr/local/bin/check_service command[check_service] = /usr/local/bin/check_service
command[check_log] = /usr/local/bin/check_log
command[check_chrony] = /usr/local/bin/check_chrony command[check_chrony] = /usr/local/bin/check_chrony
# with sudo # with sudo
@ -30,3 +29,4 @@ command[check_reboot] = sudo /usr/sbin/needrestart -p -k
command[check_restart] = sudo /usr/sbin/needrestart -p -l command[check_restart] = sudo /usr/sbin/needrestart -p -l
command[check_git] = sudo /usr/local/sbin/check_git command[check_git] = sudo /usr/local/sbin/check_git
command[check_conf] = sudo /usr/local/sbin/check_conf command[check_conf] = sudo /usr/local/sbin/check_conf
command[check_log] = sudo /usr/local/sbin/check_log

View File

@ -47,8 +47,12 @@ if [ "$PRINT_MODE" = true ]; then
fi fi
fi fi
# Répertoire des logs # Répertoire des logs perso
REP_LOG="/var/log/check_log" REP_LOG="/var/log/check_log"
# Répertoire ulogd
REP_ULOGD="/var/log/ulog"
# Fichier iptables ou nftables # Fichier iptables ou nftables
[ -f '/var/log/iptables.log' ] && FIC_TABLES_LOG='/var/log/iptables.log' [ -f '/var/log/iptables.log' ] && FIC_TABLES_LOG='/var/log/iptables.log'
[ -f '/var/log/nftables.log' ] && FIC_TABLES_LOG='/var/log/nftables.log' [ -f '/var/log/nftables.log' ] && FIC_TABLES_LOG='/var/log/nftables.log'
@ -61,7 +65,7 @@ LOG_ERR="ERROR"
################################################################################ ################################################################################
# Si le répertoire n'existe pas, on met un petit WARNING # Si le répertoire des logs perso n'existe pas, on met un petit WARNING
if [ ! -d "$REP_LOG" ] ; then if [ ! -d "$REP_LOG" ] ; then
echo "[WARNING] Le répertoire $REP_LOG n'existe pas" echo "[WARNING] Le répertoire $REP_LOG n'existe pas"
exit 1 # Sortie en Warning exit 1 # Sortie en Warning
@ -69,10 +73,13 @@ fi
################################################################################ ################################################################################
# Cherche tous les fichiers .log présents dans le répertoire # Fonction permettant de trouver les .log non vides d'un répertoire
LISTE_LOG=$(find $REP_LOG ! -empty -type f -name '*.log') function find_log() {
FIND_DIR=$1
# Cherche tous les fichiers .log présents dans le répertoire
LISTE_LOG=$(find $FIND_DIR ! -empty -type f -name '*.log')
if [ "$LISTE_LOG" ] ; then if [ "$LISTE_LOG" ] ; then
# Pour chaque fichier présent # Pour chaque fichier présent
for LOG in $LISTE_LOG ; do for LOG in $LISTE_LOG ; do
$DEBUG && echo -e "DEBUG\t\t\tERROR\t$LOG" $DEBUG && echo -e "DEBUG\t\t\tERROR\t$LOG"
@ -81,9 +88,13 @@ if [ "$LISTE_LOG" ] ; then
# Et on dit qu'on a au moins une erreur # Et on dit qu'on a au moins une erreur
ERROR=true ERROR=true
done done
else else
$DEBUG && echo -e "DEBUG\t\t\t$LISTE_LOG est vide\t" $DEBUG && echo -e "DEBUG\t\t\t$LISTE_LOG est vide\t"
fi fi
}
find_log $REP_LOG
find_log $REP_ULOGD
################################################################################ ################################################################################