diff --git a/check_clamav-daemon.sh b/check_clamav-daemon.sh new file mode 100755 index 0000000..17c6f9c --- /dev/null +++ b/check_clamav-daemon.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + + +tmp_err_msg=$(mktemp) + +# - Is this a systemd system? +# - +if [[ "X`which systemd`" = "X" ]]; then + systemd_exists=false +else + systemd_exists=true +fi + + +## - restart clamv-daemon if process is not present +## - +if ! ps -ef | grep -v grep | grep /usr/sbin/clamd > /dev/null ; then + echo "clamd is down, so i try to start it.." + if $systemd_exists ; then + systemctl stop clamav-daemon > /dev/null 2> $tmp_err_msg + if [[ "$?" -ne 0 ]] ; then + cat $tmp_err_msg + fi + sleep 2 + systemctl start clamav-daemon > /dev/null 2> $tmp_err_msg + if [[ "$?" -ne 0 ]] ; then + cat $tmp_err_msg + fi + else + /etc/init.d/clamav-daemon stop > /dev/null 2> $tmp_err_msg + if [[ "$?" -ne 0 ]] ; then + cat $tmp_err_msg + fi + sleep 2 + /etc/init.d/clamav-daemon start > /dev/null 2> $tmp_err_msg + if [[ "$?" -ne 0 ]] ; then + cat $tmp_err_msg + fi + fi +#else +# echo "clamd is up. noting to do" +fi + +## - restart clamv-freshclam if prozess is not present +## - +if ! ps -ef | grep -v grep | grep /usr/bin/freshclam > /dev/null ; then + echo "freshclam is down, so i try to start it.." + if $systemd_exists ; then + systemctl stop clamav-freshclam > /dev/null 2> $tmp_err_msg + if [[ "$?" -ne 0 ]] ; then + cat $tmp_err_msg + fi + sleep 2 + systemctl start clamav-freshclam > /dev/null 2> $tmp_err_msg + if [[ "$?" -ne 0 ]] ; then + cat $tmp_err_msg + fi + else + /etc/init.d/clamav-freshclam stop > /dev/null 2> $tmp_err_msg + if [[ "$?" -ne 0 ]] ; then + cat $tmp_err_msg + fi + sleep 2 + /etc/init.d/clamav-freshclam start > /dev/null 2> $tmp_err_msg + if [[ "$?" -ne 0 ]] ; then + cat $tmp_err_msg + fi + fi +#else +# echo "freshclam is up. noting to do" +fi + +rm $tmp_err_msg +exit 0 diff --git a/check_webservice_load.conf.sample b/conf/check_webservice_load.conf.sample similarity index 100% rename from check_webservice_load.conf.sample rename to conf/check_webservice_load.conf.sample