From de7d6a27b92627ab255cfac54182248da2bbe6ce Mon Sep 17 00:00:00 2001 From: Warren Guy Date: Wed, 22 Jan 2014 14:17:26 +0000 Subject: [PATCH] Add 'tarsnap' plugin. Monitors the amount of data stored by the local machine on the tarsnap.com service. --- plugins/tarsnap/README.md | 46 +++++++++++++++++++++++++++ plugins/tarsnap/tarsnap | 67 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 plugins/tarsnap/README.md create mode 100755 plugins/tarsnap/tarsnap diff --git a/plugins/tarsnap/README.md b/plugins/tarsnap/README.md new file mode 100644 index 00000000..b66af942 --- /dev/null +++ b/plugins/tarsnap/README.md @@ -0,0 +1,46 @@ +Munin plugin for Tarsnap +======================== + +https://github.com/warrenguy/munin-tarsnap + +This plugin creates two graphs: + +* *tarsnap_total* - summarising the total amount of data the local tarsnap +instance has stored on the service (total and compressed). +* *tarsnap_unique* - summarising the total amount of unique (deduplicated) +data the local tarsnap instance has stored on the service (total and +compressed). The compressed value here is the actual amount of data stored +on the tarnap servers and what tarsnap uses for billing. + +Usage +----- + +Add the following to your backup script (after tarsnap has run), or to a +cron job: + + /usr/local/bin/tarsnap --print-stats > /path/to/tarsnap-stats.txt + +N.B.: ensure `/path/to/munin-stats.txt` is readable by munin-node. + +Configuration +------------- + +Define the path to the stats file created above in your munin-node +configuration: + + [tarsnap] + env.STATSFILE /path/to/tarsnap-stats.txt + +The default value is `/var/lib/munin/tarsnap-stats.txt`. + +Author +------ + +Warren Guy + +https://warrenguy.me + +Copyright +--------- + +Copyright (C) 2014 Warren Guy diff --git a/plugins/tarsnap/tarsnap b/plugins/tarsnap/tarsnap new file mode 100755 index 00000000..44e0e677 --- /dev/null +++ b/plugins/tarsnap/tarsnap @@ -0,0 +1,67 @@ +#!/bin/sh +# +# Munin plugin for Tarsnap +# +# https://github.com/warrenguy/munin-tarsnap +# +# USAGE: +# +# Add the following to your backup script (after tarsnap has run), or to a +# cron job: +# +# /usr/local/bin/tarsnap --print-stats > /path/to/tarsnap-stats.txt +# +# N.B.: ensure /path/to/munin-stats.txt is readable by munin-node. The +# default path this script tries is /var/lib/munin/tarsnap-stats.txt +# +# CONFIGURATION: +# +# [tarsnap] +# env.STATSFILE /path/to/tarsnap-stats.txt +# +# AUTHOR: +# +# Warren Guy +# https://warrenguy.me +# +# COPYRIGHT: +# +# Copyright (C) 2014 Warren Guy +# + +STATSFILE=${STATSFILE=/var/lib/munin/tarsnap-stats.txt} + +case $1 in + config) + cat <<'EOM' +multigraph tarsnap_total +graph_title Tarsnap total data +graph_vlabel bytes +graph_category tarsnap +total_size.label Total size +total_compressed.label Total size (compressed) + +multigraph tarsnap_unique +graph_title Tarsnap unique data +graph_vlabel bytes +graph_category tarsnap +unique_size.label Unique data +unique_compressed.label Unique data (compressed) +EOM + exit 0;; +esac + +NUMBERS=`cat $STATSFILE | sed -e 's/[a-zA-Z\(\)]//g' -e 's/\ /\n/g' |grep -v ^$` +LINE=0 +for NUMBER in $NUMBERS; do + LINE=`expr $LINE + 1` + case "$LINE" in + 1) TOTALSIZE=$NUMBER ;; + 2) TOTALCOMP=$NUMBER ;; + 3) UNIQUESIZE=$NUMBER ;; + 4) UNIQUECOMP=$NUMBER ;; + esac +done + +printf "multigraph tarsnap_total\ntotal_size.value %s\ntotal_compressed.value %s\n\n" $TOTALSIZE $TOTALCOMP +printf "multigraph tarsnap_unique\nunique_size.value %s\nunique_compressed.value %s\n" $UNIQUESIZE $UNIQUECOMP