From 4a56eb18976700f6fc460a1b910544421a484cf2 Mon Sep 17 00:00:00 2001 From: Sven Hartge Date: Fri, 20 Apr 2012 15:19:22 +0200 Subject: [PATCH] arp: use only awk to process ARP cache Simplify the processing of the output of arp -an to use only awk. Reduces the needed subprocesses in the pipe. --- plugins/arp/arp | 3 +-- plugins/arp/arp_ | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/arp/arp b/plugins/arp/arp index a6657551..8addffa3 100755 --- a/plugins/arp/arp +++ b/plugins/arp/arp @@ -38,6 +38,5 @@ if [ "$1" = "config" ]; then exit 0 fi -echo -n "entries.value " -arp -an | grep -v "incomplete" | awk '{ print $4; }' | sort -u | wc -l +arp -an | awk 'BEGIN { regex="";} { if (!match($4,regex)) { a[$4] }} END{for(i in a){n++};print "entries.value " n}' diff --git a/plugins/arp/arp_ b/plugins/arp/arp_ index 24667f02..adbd86c3 100755 --- a/plugins/arp/arp_ +++ b/plugins/arp/arp_ @@ -51,6 +51,5 @@ if [ "$1" = "config" ]; then exit 0 fi -echo -n "entries.value " -arp -an -i $INTERFACE | grep -v "incomplete" | awk '{ print $4; }' | sort -u | wc -l +arp -an -i $INTERFACE | awk 'BEGIN { regex="";} { if (!match($4,regex)) { a[$4] }} END{for(i in a){n++};print "entries.value " n}'