Home Directory Plugins Backup and Recovery Others check_backup (for any backup system)

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_backup (for any backup system)

Rating
0 votes
Favoured:
0
Current Version
1.0
Last Release Date
2015-03-22
Compatible With
  • Nagios 4.x
License
BSD
Hits
15195
Files:
FileDescription
check_backupcheck_backup
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!
The check_backup plugin is designed to provide a generic way to check the status of backup processes by reading the contents of a file your scripts will leave either locally to the Nagios server, or on a remotely accessible host through ssh.

The file it checks is in the format [timestamp] [exitcode] on one line. [timestamp] is seconds since the epoch of backup completion, [exitcode] is 0 for success. All of this is documented in the script, which with the exception of ssh support has no dependencies other than bash.

I use this to monitor the status of my rsync backups - the script will exit with OK, WARNING, or CRITICAL status based on the backup's recorded exicode, or after the time frames supplied by the user.

It's very easy to use and setup. Just read the comments at the top of the script and you'll be up in no time.

Hoping you find this useful,

-John
From the script:

check_backup v1.0

Nagios plugin by John E.P. Hynes, HyTronix [03/22/2015] john@hytronix.com

Arguments can be in any order: d[days] h[hours] m[minutes] s[seconds] x[multiplier] f[filename] u[ssh user/host] and i[path to ssh key].

All except filename are optional. (Well, except that time defaulting to "0" will always fail...) and if you specify u[ssh user/host], you must also specify i[path to ssh key].

Example: ./check_backup h3 m45 x2 f/tmp/timefile

u[ssh user/host], if provided, means to retrieve the contents of [filename] from a remote host via ssh. It must be in the search path.

This string should contain user@host, so the complete declaration would be:

ujohn@mybox (for user "john" at host "mybox")

i[path to ssh key] tells ssh to log in using the ssh key provided. It would also allow you to just use a local key
for which there was no local user. Make the remote user privilege-less for security. (So long as they can read [filename]...)

I suppose ssh agent setup would work too; if you know about this you don't need me to tell you how to do it.

ssh example:

./check_backup h3 m45 x2 f/tmp/timefile ujohn@mybox i~/.ssh/id_rsa

Returns (from above example):

OK if timestamp in /tmp/timefile is no older
than 3 hours and 45 minutes ago, and the exit code in /tmp/timefile is 0. WARNING if time exceeded, CRITICAL if exceeded by multiplier - in this case, CRITICAL at 7 hours 30 minutes overdue.

Always CRITICAL if exit code is not 0.

If x[multiplier] is omitted, goes right to CRITICAL on time exceeded.

Your backup scripts must produce this file. As implied, it's format
is:

------8<------ CUT
[timestamp] [exit code]
------8<------ CUT

[timestamp] is seconds since the epoch,
[exit code] is the backup process exit code (make this 0 if successful).

For example, your script could, when complete, do a:

echo -n `date +%s | tr -d 'n'> /tmp/test`;
echo -n " " >> /tmp/test; echo "0" >> /tmp/test

...or somesuch. I'm sure you get the idea.

Other than supporting getting timefile data via ssh, this script has
no dependencies other than bash itself.

Questions, comments, and suggestions appreciated.