From 7e89a0d6dcb36e99f106c526e7ebef230ac6b2ec Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 5 Nov 2014 14:59:02 +0100 Subject: [PATCH] dsa-check-running-kernel: in cat_vmlinux(), only consider the first 5 hits for the magic start sequence --- .../checks/dsa-check-running-kernel | 22 +++++-------------- dsa-nagios-checks/debian/changelog | 5 ++++- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/dsa-nagios-checks/checks/dsa-check-running-kernel b/dsa-nagios-checks/checks/dsa-check-running-kernel index ae5f8ec..6a6994b 100755 --- a/dsa-nagios-checks/checks/dsa-check-running-kernel +++ b/dsa-nagios-checks/checks/dsa-check-running-kernel @@ -37,15 +37,13 @@ get_offset() { file="$1" needle="$2" - pos="$3" perl -e ' undef $/; - $i = index(<>, "'"$needle"'", '"$pos"'); - if ($i < 0) { - exit 1; - }; - print $i,"\n"' < "$file" + $i = 0; $k=<>; + while (($i = index($k, "'"$needle"'", $i)) >= 0) { + print $i++,"\n"; + }; ' < "$file" } get_avail() { @@ -130,23 +128,13 @@ cat_vmlinux() { header="$2" filter="$3" hdroff="$4" - nextoff=0 - - while : ; do - off=`get_offset "$image" $header $nextoff` - local ret="$?" - if [ "$ret" != 0 ]; then - # not found, exit - return 1 - fi + get_offset "$image" $header | head -n 5 | while read off; do (if [ "$off" != 0 ]; then dd ibs="$((off+hdroff))" skip=1 count=0 fi && dd bs=512k) < "$image" 2>/dev/null | $filter 2>/dev/null - nextoff=$((off + 1)) done - return 0 } get_image_linux() { diff --git a/dsa-nagios-checks/debian/changelog b/dsa-nagios-checks/debian/changelog index a673c8c..79c3ba3 100644 --- a/dsa-nagios-checks/debian/changelog +++ b/dsa-nagios-checks/debian/changelog @@ -8,12 +8,15 @@ dsa-nagios-checks (101) UNRELEASED; urgency=low * dsa-check-hpasm: Support supplying a list of things for which failures are ignored. * dsa-check-soas: do some queries without RD set. + * dsa-check-running-kernel: in cat_vmlinux(), only consider the first 5 hits + for the magic start sequence. This makes running times bearable on our + new octeons. [ Hendrik Köhler ] * Extend dsa-check-entropy output so Icinga2 can process performance data (e.g. used by Graphite). - -- Peter Palfrader Sat, 11 Oct 2014 09:43:01 +0200 + -- Peter Palfrader Wed, 05 Nov 2014 14:57:51 +0100 dsa-nagios-checks (100) unstable; urgency=low -- 2.20.1