Parcourir la source

nagios/netstat: corr. bug

Charly il y a 6 ans
Parent
commit
6dc448c6b3
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      nagios/check_netstat_connectioncount.sh

+ 6 - 1
nagios/check_netstat_connectioncount.sh

@@ -65,6 +65,11 @@ check_range_syntax() {
 for i in netstat ss; do
 	if which "$i" >/dev/null 2>&1 ; then
 		COMMAND_SYS="$i"
+		if [ "$COMMAND_SYS" = "ss" ]; then
+			OUTPUT_COLUMN=5
+		else
+			OUTPUT_COLUMN=4
+		fi
 		break
 	fi
 done
@@ -143,7 +148,7 @@ while getopts hw:c:p: f; do
 				*)
 					PORT_NUMBER=$( printf "%d" "$OPTARG" )
 					LABEL="port$PORT_NUMBER"
-					CPT="$( $COMMAND_SYS -tauen | sed 's/[[:space:]]\+/\t/g' | cut -f 4 | ( grep -c ":$PORT_NUMBER$" || true ) )"
+					CPT="$( $COMMAND_SYS -taun | sed 's/[[:space:]]\+/\t/g' | cut -f "$OUTPUT_COLUMN" | ( grep -c ":$PORT_NUMBER$" || true ) )"
 					;;
 			esac