aboutsummaryrefslogtreecommitdiff
path: root/Tools/portbuild/scripts/client-metrics
blob: 34867a312e497185dcf4e8096c9f5f66522f20f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/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"