Wrapper script to report Amanda backup status to Logstash/Kibana

From MyWiki

Jump to: navigation, search

Below is the script that engages amdump for given configuration and then sends report in JSON format to Redis which is part of our Logstash.

#
# Wrapper script to run dump and pump report out to Logstash/Kibana
#
# Pre-requisites: mlogger, RELP configuration in rsyslog
#

PATH=/usr/sbin:/usr/bin:/bin
LOG_PRG_NAME=amanda_report

if [ $# -lt 1 ]
then
	echo "Usage: `basename $0` <backup_configuration_name>"
	exit -1
fi

# Perform the backup
amdump $1 

# send out JSON formatted report to Logstash
amreport --format=json, $1 | sed -e 's/^$/ /g' | tr -d '\n' | mlogger -t ${LOG_PRG_NAME}

When you create cron job for backing up, use the script (example below)

# Data Integration backups
0 20 * * *      /etc/amanda/amdump_and_report.sh prod-di-1week-vtape-RAIT
Personal tools