diff --git a/diag.sh b/diag.sh
index d954411..81ad81d 100644
--- a/diag.sh
+++ b/diag.sh
@@ -12,7 +12,6 @@ ADMIN_USER="Administrator"
SERVER_NAME=$(hostname)
NTP_SERVER="pool.ntp.org"
-
# Ports requis pour Samba AD
REQUIRED_PORTS=(
53 # DNS
@@ -243,40 +242,35 @@ check_time_sync() {
# Vérifier si ntpd ou chronyd est installé
if ! command -v ntpstat &> /dev/null && ! command -v chronyc &> /dev/null; then
time_checks+=("
| Service NTP | Non installé |
")
+ echo "${time_checks[@]}"
return
fi
# Vérifier la synchronisation avec chronyd
if command -v chronyc &> /dev/null; then
if chronyc tracking | grep -q "^Leap status.*Normal"; then
- local offset=$(chronyc tracking | grep "Last offset" | awk '{print $4}')
- if [ "$(echo "$offset < 1.0" | bc -l)" -eq 1 ]; then
- time_checks+=("| Synchronisation NTP (chronyd) | Synchronisé (offset: ${offset}s) |
")
+ # Extraire l'offset et supprimer le signe "+"
+ local offset=$(chronyc tracking | awk '/Last offset/ {print $4}' | sed 's/^+//')
+
+ # Vérifier si l'offset est bien un nombre avant d'utiliser bc
+ if [[ "$offset" =~ ^-?[0-9]+(\.[0-9]+)?$ ]]; then
+ if (( $(echo "$offset < 1.0" | bc -l) )); then
+ time_checks+=("| Synchronisation NTP (chronyd) | Synchronisé (offset: ${offset}s) |
")
+ else
+ time_checks+=("| Synchronisation NTP (chronyd) | Offset important: ${offset}s |
")
+ fi
else
- time_checks+=("| Synchronisation NTP (chronyd) | Offset important: ${offset}s |
")
+ time_checks+=("| Synchronisation NTP (chronyd) | Erreur: Offset invalide (${offset}) |
")
fi
else
time_checks+=("| Synchronisation NTP (chronyd) | Non synchronisé |
")
fi
fi
- # Vérifier la synchronisation avec ntpd
- if command -v ntpq &> /dev/null; then
- if ntpq -p &> /dev/null; then
- local offset=$(ntpq -c rv | grep offset | cut -d= -f2)
- if [ "$(echo "$offset < 1.0" | bc -l)" -eq 1 ]; then
- time_checks+=("| Synchronisation NTP (ntpd) | Synchronisé (offset: ${offset}ms) |
")
- else
- time_checks+=("| Synchronisation NTP (ntpd) | Offset important: ${offset}ms |
")
- fi
- else
- time_checks+=("| Synchronisation NTP (ntpd) | Non synchronisé |
")
- fi
- fi
-
echo "${time_checks[@]}"
}
+
# Vérification des ports UFW
check_ufw_ports() {
local ufw_checks=()