Untitled
unknown
plain_text
18 days ago
620 B
5
Indexable
#!/bin/bash # Utilisateur à surveiller USER="root" # Compter le nombre de connexions SSH actives pour l'utilisateur root CONN_COUNT=$(ps -ef | grep 'sshd: root@' | grep -v grep | wc -l) # Vérifier si la connexion SSH en cours de l'utilisateur exécutant le script doit être exclue if [[ "$USER" == "$(whoami)" && "$CONN_COUNT" -gt 0 ]]; then CONN_COUNT=$((CONN_COUNT - 1)) fi # Vérifier le nombre de connexions et alerter if [ "$CONN_COUNT" -gt 1 ]; then echo "CRITICAL - $USER has $CONN_COUNT SSH connections" exit 2 else echo "OK - $USER has $CONN_COUNT SSH connections" exit 0 fi
Editor is loading...
Leave a Comment