Created
October 9, 2018 13:00
-
-
Save vroman/b085c5e0d9a18ea5074d4e7bf8f7e953 to your computer and use it in GitHub Desktop.
Send running jail stats to carbon database
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 carbon database. It may be consumed then by tools | |
# like graphite or grafana. | |
# | |
# 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 | |
# | |
# Modify carbon_host, carbon_port and prefix variables | |
# to suit your needs. By default the metric has the | |
# format: hostname.jail.<jail name>.<metric name> | |
# | |
# Author(s): Víctor Román Archidona <vroman@loadfront.com> | |
carbon_host="127.0.0.1" | |
carbon_port="2003" | |
hostname=`hostname | tr '.' '_'` | |
prefix="$hostname.jail" | |
date=`date +%s` | |
jails=`jls -d -h name | tail -n +2` | |
for jail in $jails; do | |
for item in `rctl -u jail:$jail`; do | |
echo $prefix.$jail.$item $date | tr '=' ' ' | nc -N $carbon_host $carbon_port | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment