Просмотр исходного кода

check_ossec.sh: add option to exclude multiple services

Jon Schipp 12 лет назад
Родитель
Сommit
9c216e2d0e
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      check_ossec.sh

+ 3 - 3
check_ossec.sh

@@ -46,7 +46,7 @@ This script should be run on the OSSEC server.
         -c <int>        Critical threshold for number of inactive agents
         -l              List all agents
         -s <service>    Check status of OSSEC server processes. Use ``-s all'' to check all.
-                        To exclude a service e.g execd pass as argument i.e. ``-s execd''
+			To exclude a service(s) e.g pass as comma separated argument i.e. ``-s "execd,maild''
         -w              Warning threshold for number of inactive agents
 
 Usage: $0 -a "server1,server2,station3"
@@ -100,7 +100,7 @@ do
              ;;
          s)
              SERVER_CHECK=1
-             EXCLUDE="$OPTARG"
+	     EXCLUDE=$(echo $OPTARG | sed 's/,/|/g')
              ;;
          v)
              CHECK_THRESHOLD=1
@@ -122,7 +122,7 @@ fi
 
 if [ $SERVER_CHECK -eq 1 ]; then
 
-        $OSSEC_CONTROL status | grep -v $EXCLUDE | grep "not running"
+        $OSSEC_CONTROL status | grep -v -E "$EXCLUDE" | grep "not running"
 
         if [ $? -eq 0 ]; then
                 echo "An OSSEC service is not running!"