Nagios-Plugin to check the current version of clamd


I wrote a small plugin for nagios to check the current clamav-version.

Setup nagios:

define command{
command_name check_clamdv
command_line $USER1$/check_clamdv $ARG1$
}

define service{
use local-service
host_name obelix.schaal-24.de
service_description CLAMD Version
check_command check_clamdv
# if clamd is not located in /usr/local/sbin/clamd, use
#check_command check_clamdv!/path/to/your/clamd
check_interval 15
}

check_clamd Download

#!/bin/bash
CLAMD=/usr/local/sbin/clamd
if [[ -n "$1" ]]; then CLAMD=$1; fi
if [ ! -f $CLAMD ]; then echo "$1 not found"; exit 3; fi
LOCALVERSION=`$CLAMD -V | awk '{print $2}' | cut -d \/ -f1`
CURRENTVERSION=`host -t txt current.cvd.clamav.net|cut -d \" -f 2|cut -d \: -f 1`

if [ $LOCALVERSION != $CURRENTVERSION ]; then
echo "CLAMD ($LOCALVERSION) outdated - $CURRENTVERSION available"
exit 2
else
echo "CLAMD ($LOCALVERSION) is up to date"
exit 0
fi

Leave a comment

Your email address will not be published. Required fields are marked *