Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grep -E -> grep -P #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ptrap
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ elif [ ! -f /var/log/messages ]; then
fi

PROTOCOLS_TO_MONITOR="${MONITOR_TCP:+tcp} ${MONITOR_UDP:+udp}"
OUTPUT_INTERFACE="$($PRG_IP route get 10.10.41.71 | head -n1 | grep -o -E "dev \w*\s" | cut -d' ' -f2)"
OUTPUT_INTERFACE="$($PRG_IP route get 10.10.41.71 | head -n1 | grep -o -P "dev \w*\s" | cut -d' ' -f2)"
log "Program parameters:"
log "- Ip to monitor: $IP_TO_MONITOR"
log "- Port to monitor: ${PORT_TO_MONITOR:-any}"
Expand Down Expand Up @@ -203,8 +203,8 @@ teardown_lock_directory () {
monitor_syslog() {
log "Starting syslog monitoring..."
tail -f -s "$TAIL_INTERVAL_S" /var/log/messages | grep --line-buffered "$IPTABLES_IDENTIFIER" | while read LINE; do
PROTOCOL=$(echo "$LINE" | grep -o -E "PROTO=\w*" | cut -d= -f2) || PROTOCOL=""
SOURCE_PORT=$(echo "$LINE" | grep -o -E "SPT=[0-9]+" | cut -d= -f2) || SOURCE_PORT=""
PROTOCOL=$(echo "$LINE" | grep -o -P "PROTO=\w*" | cut -d= -f2) || PROTOCOL=""
SOURCE_PORT=$(echo "$LINE" | grep -o -P "SPT=[0-9]+" | cut -d= -f2) || SOURCE_PORT=""
MATCHING_PID=$($PRG_LSOF -i ${PROTOCOL}:${SOURCE_PORT} | tail -n1 | awk '{print $2}') || MATCHING_PID=""
if [ -z "$MATCHING_PID" ]; then
log "ERROR: request detected, but lsof did not list any process. Read the program help for tips on how to avoid this." force >&2
Expand Down