Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_duplicati_job

Rating
0 votes
Favoured:
0
Current Version
1.0
Last Release Date
2021-07-17
Compatible With
  • Nagios 4.x
Owner
License
Other
Hits
3862
Files:
FileDescription
check_duplicati_job/usr/local/nagios/libexec/check_duplicati_job
check_duplicati_job.cfg/usr/local/nagios/etc/commands/check_duplicati_job.cfg
save-job-result.sh/root/.config/Duplicati/save-job-result.sh
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
check_duplicati_job
I’ve made a small set of scripts to allow for an easy monitoring integration with Nagios Core.

You’ll need to place the following files into your nagios installation to set it up. I’ve tested this on Debian 10 (buster). Your Duplicati backup job needs to call the bash script by specifiying the advanced option “–run-script-after=/root/.config/Duplicati/save-job-result.sh” in order to save the job result to a status file. The status file will be read by the nagios plugin to determine the sensor status.
I’ve made a small set of scripts to allow for an easy monitoring integration with Nagios Core.

You’ll need to place the following files into your nagios installation to set it up. I’ve tested this on Debian 10 (buster). Your Duplicati backup job needs to call the bash script by specifiying the advanced option “–run-script-after=/root/.config/Duplicati/save-job-result.sh” in order to save the job result to a status file. The status file will be read by the nagios plugin to determine the sensor status.

chmod +x /usr/local/nagios/libexec/check_duplicati_job
******* START ********
#!/bin/sh
#
# Command line.
## sh /usr/local/nagios/libexec/check_duplicati_job my-test-backup-job; echo $?
#
EXIT_OK=0
EXIT_WARNING=1
EXIT_CRITICAL=2
#
if [ -z "${1}" ]; then
echo "WARNING: Duplicati job parameter #1 missing."
exit ${EXIT_WARNING}
fi
DUPLICATI_JOB_NAME="${1}"
DUPLICATI_JOB_RESULT_FULLFN="/root/.config/Duplicati/jobs/${DUPLICATI_JOB_NAME}.result"
#
if [ ! -f "${DUPLICATI_JOB_RESULT_FULLFN}" ]; then
echo "WARNING: Job "${DUPLICATI_JOB_NAME}" was never executed."
exit ${EXIT_WARNING}
fi
#
if ( ! grep -q "Success" "${DUPLICATI_JOB_RESULT_FULLFN}" ); then
echo "CRITICAL: Job "${DUPLICATI_JOB_NAME}" $(cat "${DUPLICATI_JOB_RESULT_FULLFN}" 2>/dev/null)"
exit ${EXIT_CRITICAL}
fi
#
echo "OK: Job "${DUPLICATI_JOB_NAME}" $(cat "${DUPLICATI_JOB_RESULT_FULLFN}" 2>/dev/null)"
exit ${EXIT_OK}
******* END********

/usr/local/nagios/etc/commands/check_duplicati_job.cfg
******* START ********
define command{
command_name check_duplicati_job
command_line $USER1$/check_duplicati_job $ARG1$
}
******* END********


/usr/local/nagios/etc/servers/my-duplicati-server.cfg
******* START ********
define host {

use linux-server
host_name my-duplicati-server
alias my-duplicati-server
address [SERVER_IP_ADDRESS]
check_period 24x7
contact_groups admins
max_check_attempts 5
}

define service {
use local-service
host_name my-duplicati-server
service_description duplicati-job-1
check_command check_duplicati_job!duplicati-job-1
}
******* END********

The job status saver:
chmod +x /root/.config/Duplicati/save-job-result.sh
******* START ********
#!/bin/bash
#
# Store job result to file for nagios monitoring.
SCRIPT_PATH="$(dirname "$(realpath "${0}")")"
mkdir -p "${SCRIPT_PATH}/jobs/"
echo "${DUPLICATI__PARSED_RESULT} ${DUPLICATI__EVENTNAME} ${DUPLICATI__OPERATIONNAME}" > "${SCRIPT_PATH}/jobs/${DUPLICATI__backup_name}.result"
exit 0
******* END********