[checkmk-commits] Check_MK Git: check_mk: OpenBSD Agent: Handle bug in OpenBSD ksh, better NIC support allowing more than 15interfaces. Thanks to Dave Josephsen <dave at ...>

git version control git at mathias-kettner.de
Fri Nov 2 12:28:20 CET 2012


Module: check_mk
Branch: master
Commit: df265bfb188626f92f3e12f1350c32dc72f4a981
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=df265bfb188626f92f3e12f1350c32dc72f4a981

Author: Florian Heigl <fh at mathias-kettner.de>
Date:   Fri Nov  2 12:25:25 2012 +0100

OpenBSD Agent: Handle bug in OpenBSD ksh, better NIC support allowing more than 15interfaces. Thanks to Dave Josephsen <dave at ...>

---

 agents/check_mk_agent.openbsd |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/agents/check_mk_agent.openbsd b/agents/check_mk_agent.openbsd
index c230ed6..fd6b0b9 100644
--- a/agents/check_mk_agent.openbsd
+++ b/agents/check_mk_agent.openbsd
@@ -86,12 +86,16 @@ echo '<<<netctr>>>'
 # BO= Bytes out
 # PO= Packets out
 # CO= Colls
+# NI= number of interfaces
 
 Z1=1
 Z2=p
+NI=$(netstat -in | grep 'Link' | wc -l)
+[ "${NI}" -ge 1 ] || NI=15
+
 
 date +%s
-while [ $Z1 -lt 15 ]
+while [ $Z1 -lt $NI ]
   do
   BI=$( netstat -inb | egrep -v Name | grep Link | awk '{print $1" "$5}' | sed -ne $Z1$Z2 )
   PI=$( netstat -in | egrep -v Name | grep Link | awk '{print $5}' | sed -ne $Z1$Z2 )
@@ -102,7 +106,7 @@ while [ $Z1 -lt 15 ]
   EO=$( netstat -in | egrep -v Name | grep Link | awk '{print $8}' | sed -ne $Z1$Z2 )
   CO=$( netstat -in | egrep -v Name | grep Link | awk '{print $9}' | sed -ne $Z1$Z2 )
   FF2="0 0"
-    if [ "$PI" -gt "0" ]
+    if [ "$(echo ${PI} | cut -c 1-3)" -gt 0 ]
       then
 	echo $BI $PI $EI $FF1 $BO $PO $EO $FF2 $CO $FF2
     fi



More information about the checkmk-commits mailing list