Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_duplicati_job
1.0
2021-07-17
- Nagios 4.x
Other
3862
File | Description |
---|---|
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 |
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!
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********
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********
Reviews (0)
Be the first to review this listing!