Skip to content
Snippets Groups Projects
Commit 0cfbe0bd authored by Andreas Olsson's avatar Andreas Olsson
Browse files

Adding Munin plugin.

parent 115a0d14
Branches
Tags
No related merge requests found
Copyright (c) 2009, 2010, 2011 Andreas Olsson Copyright (c) 2009-2012 Andreas Olsson
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
......
...@@ -10,3 +10,9 @@ Nagios plugin which works by reading a text file containing a Unix ...@@ -10,3 +10,9 @@ Nagios plugin which works by reading a text file containing a Unix
timestamp of the most recent tarsnap backup. See the top comment in timestamp of the most recent tarsnap backup. See the top comment in
check_tarsnap for an example on how your tarsnap backup script can check_tarsnap for an example on how your tarsnap backup script can
generate such a file. generate such a file.
* tarsnap_usage
This Munin plugin keeps track on how much data a machine has backed up
on tarsnap. This is done by reading the current amount of data from a
text file, preferably updated by the tarsnap backup script. See the
plugin documentation for details.
#!/bin/sh
# -*- sh -*-
: << '=cut'
=head1 NAME
tarsnap_usage - Plugin to measure amount of tarsnap stored data
=head1 CONFIGURATION
By default the amount of data will be read from the file
/var/lib/tarsnap/status/data. Another file can be specified by setting
the variable datafile.
[tarsnap_usage]
env.datafile /path/to/datafile
=head2 DATA FILE
The plugin expects the data file to contain a numeric value, and
nothing more, representing the number of bytes stored. One way to have
that file generated is by running something like the following at the
end of your tarsnap backup script.
data=$(tarsnap --print-stats | sed -nre "s/^\s+\(unique data\)\s+[0-9]+\s+([0-9]+)$/\1/p")
[ -n "$data ] && echo "$data" > /var/lib/tarsnap/status/data
=head1 AUTHOR
Andreas Olsson <andreas@arrakis.se>
=head1 LICENSE
MIT License
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ -z "$datafile" ]; then
datafile="/var/lib/tarsnap/status/data"
fi
amount=$(cat "$datafile" 2> /dev/null)
is_numeric () {
echo "$amount" | grep -Eq "^[0-9]+$" && return 0 || return 1
}
if [ "$1" = "autoconf" ]; then
is_numeric && echo yes || echo no
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Tarsnap usage'
echo 'graph_vlabel byte stored'
echo 'data.label total usage'
echo 'graph_args --base 1000 -l 0'
echo 'graph_category disk'
echo 'graph_info Total amount of unique data backed up by tarsnap. That is, after deduplication and compression.'
exit 0
fi
if ! is_numeric; then
echo "Failed to read expected data from ${datafile}"
exit 1
fi
echo "data.value ${amount}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment