#!/bin/sh : << =cut =head1 NAME debsecan - Plugin to monitor the number of CVE vulnerabilities present on a Debian system (using debsecan). Might work on other distib, who knows... =head1 CONFIGURATION [debsecan] env.suite jessie env.fixed_warn 1 env.fixed_critical 1000 env.remote_warn 1 env.remote_critical 10 =head1 AUTHORS * Nicolas BOUTHORS http://nbi.fr/, Inspiration of the moment 10/10/2007 * Olivier Mehani , 2016 =head1 LICENSE Public Domain =head1 MAGIC MARKERS %# family=auto %# capabilities=autoconf =cut # Auto enable if we have debsecan only if [ "$1" = "autoconf" ] ; then if [ -x /usr/bin/debsecan ]; then echo yes else echo 'no (/usr/bin/debsecan not found)' fi exit 0 fi # Fail if we don't have debsecan if [ ! -x /usr/bin/debsecan ]; then echo 'error: /usr/bin/debsecan not found' >&2 exit 1 fi # Determine suite from filename... SUITE=$(echo "$0" | sed 's/.*_//') if [ "${SUITE}" = "${0}" ]; then # ...or fall back onto configuration in environment SUITE=${suite:-sid} fi FIXEDWARN=${fixed_warning:-1} FIXEDCRIT=${fixed_critical:-1000} REMOTEWARN=${remote_warning:-1} REMOTECRIT=${remote_critical:-10} if [ "$1" = "config" ] ; then cat < /dev/null) REMOTE=$(echo "$ALL" | grep 'remotely') NONREMOTE=$(echo "$ALL" | grep -v 'remotely') HIGH=$(echo "${NONREMOTE}" | grep 'high urgency') MEDIUM=$(echo "${NONREMOTE}" | grep 'medium urgency') LOW=$(echo "${NONREMOTE}" | grep 'low urgency') OTHER=$(echo "${NONREMOTE}" | grep -v 'urgency') FIXED=$(echo "${ALL}" | grep '(fixed') remote_count=$(echo "${REMOTE}" | wc -l) high_count=$(echo "${HIGH}" | wc -l) medium_count=$(echo "${MEDIUM}" | wc -l) low_count=$(echo "${LOW}" | wc -l) other_count=$(echo "${OTHER}" | wc -l) fixed_count=$(echo "${FIXED}" | wc -l) CVECOUNTRE="s/^ *\([0-9]\+\) \+\([^ ]\+\)/\2 (\1)/" # shellcheck disable=SC2005 disable=SC2046 # The nested $(echo ...)s are needed to yet the newlines cat <