Last active
September 2, 2021 15:47
-
-
Save vroman/5f7eba2b668b160a6bbdcdd53406e306 to your computer and use it in GitHub Desktop.
send_jail_stats_prometheus.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This scripts injects running jails from a FreeBSD host | |
# into Prometheus monitoring pushgateway. | |
# | |
# A common way to use this is set-up a crontab entry. | |
# | |
# kernel requeriments: | |
# options RACCT | |
# options RCTL | |
# | |
# /boot/loader.conf.local requeriments: | |
# kern.racct.enable=1 | |
# | |
# Sample usage via cron: | |
# | |
# * * * * * root /usr/local/sbin/send_jail_stats_prometheus.sh | /usr/local/bin/curl --connect-timeout 5 --max-time 15 --data-binary @- http://IP.PROMETHEUS:9091/metrics/job/pushgateway/instance/IP.LOCAL.SERVER >/dev/null 2>&1 | |
# | |
# Author(s): Victor Roman Archidona <vroman@loadfront.com> | |
jails=`jls -d -h name | tail -n +2` | |
for jail in $jails; do | |
for item in `rctl -u jail:$jail`; do | |
itemname=`echo $item | cut -d= -f1` | |
itemvalue=`echo $item | cut -d= -f2` | |
echo freebsd_jail_resource{jail=\"$jail\",name=\"$itemname\"} $itemvalue | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment