1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-24 18:07:20 +00:00
Munin-Contrib/plugins/ceph/ceph_capacity
Tim Connors 5b1300aebf Cater for newer OS dependencies - python and ceph updates
system default python is now usually python3 - better make our code
compliant with it

`ceph` CLI itself has some slightly different usage and outputs

jq used instead of cut in a few places, because was easier to work out
what the original commands were intending to grab, now that those
outputs have moved location.  Yes, jq is a new dependency for some of
the plugins, but it was already implicitly depended upon in ceph_osd
plugin
2023-10-16 22:55:52 +11:00

64 lines
1.5 KiB
Bash
Executable file

#!/bin/sh
: << =cut
=head1 NAME
ceph_capacity - Shows ceph total storage capacity, used raw space and used data space
=head1 CONFIGURATION
[ceph_capacity]
env.warning_level Used raw space percentage above warning alert should be issued
env.critical_level Used raw space percentage above critical alert should be issued
=head1 AUTHOR
Mate Gabri <mate@gabri.hu>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
WARNING_LEVEL=${warning_level:-"80"}
CRITICAL_LEVEL=${critical_level:-"90"}
CEPH_STATUS=$(ceph -s --format=json)
if [ "$1" = "config" ]; then
echo 'graph_title CEPH capacity'
echo 'graph_category fs'
echo 'graph_vlabel GB'
echo 'graph_info CEPH cluster capacity'
echo 'graph_args --base 1000 -l 0'
CAPACITY=$(echo "$CEPH_STATUS" | jq '.pgmap.bytes_total')
WARNING=$(echo "scale=2;$CAPACITY * ($WARNING_LEVEL/100)" | bc -l | cut -d '.' -f 1)
CRITICAL=$(echo "scale=2;$CAPACITY * ($CRITICAL_LEVEL/100)" | bc -l | cut -d '.' -f 1)
echo "capacity.label Capacity"
echo "used.label Raw used"
echo "used.draw AREA"
echo "used.warning $WARNING"
echo "used.critical $CRITICAL"
echo "data.label Data"
echo "data.draw AREA"
exit 0
fi
echo "capacity.value $(echo "$CEPH_STATUS" | jq '.pgmap.bytes_total')"
echo "used.value $(echo "$CEPH_STATUS" | jq '.pgmap.bytes_used')"
echo "data.value $(echo "$CEPH_STATUS" | jq '.pgmap.data_bytes')" # no idea of the intention of this metric; could be bytes_avail