summaryrefslogtreecommitdiffstats
path: root/extras/munin
diff options
context:
space:
mode:
Diffstat (limited to 'extras/munin')
-rw-r--r--extras/munin/filebin_stats25
1 files changed, 25 insertions, 0 deletions
diff --git a/extras/munin/filebin_stats b/extras/munin/filebin_stats
new file mode 100644
index 000000000..4396c3503
--- /dev/null
+++ b/extras/munin/filebin_stats
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# Put something along those lines into your munin-node config
+#
+# [filebin_stats]
+# env.mysqlopts --defaults-file=/var/lib/munin/.my.cnf
+# env.database filebin
+
+case $1 in
+ config)
+ cat <<'EOM'
+graph_title FileBin
+graph_args --base 1024 --logarithmic --units=si
+graph_vlabel Space
+used.label Storage used
+dedup.label Storage saved by deduplication
+EOM
+ exit 0;;
+esac
+
+echo -n "used.value "
+mysql $mysqlopts -sr $database <<<"select coalesce(sum(filesize), 0) as 'Used storage' from file_storage;" || echo "a"
+
+echo -n "dedup.value "
+mysql $mysqlopts -sr $database <<<"select coalesce(sum((c - 1) * sub.filesize), 0) 'Space saved by deduplication' from (select fs.id, filesize, count(*) c from files join file_storage fs on fs.id = files.file_storage_id group by fs.id having c > 1 order by c) sub;" || echo "a"