Untitled

 avatar
unknown
plain_text
24 days ago
478 B
4
Indexable
#!/bin/bash

# Utilisateur à surveiller
USER="root"

# Utilisation de ss pour afficher les connexions et filtrer par utilisateur
CONN_COUNT=$(ss -tulnp | grep $USER | wc -l)

# Vérifier le nombre de connexions
if [ "$CONN_COUNT" -gt 1 ]; then
  echo "CRITICAL - $USER has $CONN_COUNT connections"
  exit 2
elif [ "$CONN_COUNT" -gt 0 ]; then
  echo "WARNING - $USER has $CONN_COUNT connections"
  exit 1
else
  echo "OK - No connections for $USER"
  exit 0
fi
Editor is loading...
Leave a Comment