#!/bin/bash
CACHEFILE=/tmp/check_mk-opensuse_zypper.cache
if [ -f /usr/lib/nagios/plugins/check_zypper ]; then
  echo "<<<opensuse_zypper>>>"
  # use prime number for cache lifetime
  if test `find $CACHEFILE -type f -mmin -59`; then
    OUTPUT=$(cat $CACHEFILE)
  else
    OUTPUT=$(/usr/lib/nagios/plugins/check_zypper -s | cut -f2 -d\| | tr -d " " | tr -s \; | sed -e 's/; *$//')
    if [ ${OUTPUT:0:4} = secu ]; then
      echo $OUTPUT > $CACHEFILE
    fi
  fi
  if [ ${OUTPUT:0:4} = secu ]; then
    echo $OUTPUT | tr "\;=" "\n "
  fi
fi
