From 067257f04a1ace1308e07dbfb9d0fb0a80634f25 Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Mon, 11 Jul 2011 14:59:17 +0200 Subject: [PATCH] check_zypper.sh: Initial commit --- check_zypper.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 check_zypper.sh diff --git a/check_zypper.sh b/check_zypper.sh new file mode 100755 index 0000000..d467d79 --- /dev/null +++ b/check_zypper.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +############################################################################# +# (c) 2011 Sven Velt /dev/null 2>&1 + +zypper_out=$(sudo LANG=C /usr/bin/zypper -q pchk) +if ( echo "${zypper_out}" | grep -q "needed" ) ; then + output=$(echo ${zypper_out} | cut -d "." -f 7) + patches=$(echo ${output} | cut -d " " -f1) + if [ ${patches} -gt 0 ] ; then + secpatches=$(echo ${output} | cut -d "(" -f2|cut -d " " -f1) + if [ -n "${secpatches}" ]; then + if [ ${secpatches} -gt 0 ] ; then + echo "Zypper CRITICAL - ${patches}" + exit 2 + fi + echo "Zypper WARNING - ${output}" + exit 1 + fi + fi +fi + +echo "Zypper OK - No updates available" +exit 0