freebsd-ports/Tools/portbuild/scripts/client-metrics
Kris Kennaway 9ed197c29c Script run from cron on the package clients to report metrics to ganglia.
Currently we collect:

* The current and maximum number of vnodes in use

* The number of packages built over the past hour
2008-07-26 15:09:00 +00:00

35 lines
970 B
Bash
Executable file

#!/bin/sh
# Collect metrics for ganglia:
# - current vnodes
# - max vnodes
# - number of packages built in the past hour
pb=/var/portbuild
arch=$(uname -m)
me=$(hostname)
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
gmetric --name="maxvnodes" --value=`sysctl -n kern.maxvnodes` --tmax=120 --dmax=0 --type=uint32 --units="# vnodes"
gmetric --name="vnodes" --value=`sysctl -n vfs.numvnodes` --tmax=120 --dmax=0 --type=uint32 --units="# vnodes"
if [ -f ${pb}/${arch}/portbuild.conf -a -f ${pb}/${arch}/portbuild.${me} ]; then
. ${pb}/${arch}/portbuild.conf
. ${pb}/${arch}/portbuild.${me}
else
exit 1
fi
if [ ! -d ${scratchdir}/stamp ]; then
exit 1
fi
cd ${scratchdir}/stamp || exit 1
new=$(find . -mmin -60 | wc -l)
new=$((${new} + 0))
find . \! -mmin -60 -delete
gmetric --name="packages" --value="${new}" --tmax=120 --dmax=0 --type=int16 --units="Packages/hour" --conf="/usr/local/etc/gmond.conf"