From 5a5915e5ded5264dfc78bfb4dca4e329be722f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B3mas=20Edwardsson?= Date: Thu, 4 Mar 2010 11:36:20 +0000 Subject: [PATCH] Added crit2warn Nagios plugin wrapper to change critical return codes of plugins to warning. --- crit2warn.sh/trunk/crit2warn.sh | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 crit2warn.sh/trunk/crit2warn.sh diff --git a/crit2warn.sh/trunk/crit2warn.sh b/crit2warn.sh/trunk/crit2warn.sh new file mode 100644 index 0000000..8e00e28 --- /dev/null +++ b/crit2warn.sh/trunk/crit2warn.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright 2010, Tomas Edwardsson +# +# crit2warn.sh is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# crit2warn.sh is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# crit2warn.sh is a wrapper for Nagios checks that changes the return +# code for checks from CRITICAL to WARNING + +CMD="" + +# Quote arguments +for (( i = 1; i < $# ; i++ )); do + eval ARG=\$$i + CMD="$CMD $(echo "$ARG" | awk '{gsub(".", "\\\\&");print}')" +done + +# Run command +eval "echo $CMD >> /tmp/cmd" +eval "$CMD" +ret=$? + + +# Change return CRITICAL to WARNING +if [ $ret == 2 ]; then + ret=1 +fi + +exit $ret +