-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcitrusleaf_graphite.sh
executable file
·49 lines (43 loc) · 1.31 KB
/
citrusleaf_graphite.sh
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
#######
# this script runs through clinfo and grabs all the values for citrusleaf, then parses them out to graphite every 10 seconds.
# it only sends numeric values.
#
# to run this script :
# nohup sh citrusleaf_graphite.sh &
#
#######
NAMESPACE="<NAMESPACE>"
HOSTNAME=`echo $HOSTNAME | cut -d. -f1`
DATE=`date +%s`
NETCAT=`which nc`
CL_SERVER="127.0.0.1"
CL_PORT="3000"
GRAPHITE_SERVER="<GRAPHITE SERVER ADDRESS>"
GRAPHITE_PORT="2003"
NUMBER="0"
#### this is to check whether or not netcat is installed ####
if [[ -z ${NETCAT} ]]; then
printf "\nnc not found.\n"
exit 1
fi
#### you should not have to change anything below this line ####
while (true)
do
DATE=`date +%s`
NUMBER="0"
for I in $(clinfo -h ${CL_SERVER} -p ${CL_PORT} -v ${NAMESPACE} | grep type | cut -d" " -f4 | tr ";" "\n")
do
# NUMBER=`expr ${NUMBER} + 2`
NAME=`echo ${I} | cut -d"=" -f1`
VALUE=`echo ${I} | cut -d"=" -f2 | cut -d";" -f1`
VALUE_CHK=${VALUE//[^0-9]/}
if [[ ${VALUE} == ${VALUE_CHK} ]]; then
# echo ${NUMBER} ${I}
# echo "value to nc:"
# echo ${HOSTNAME}.${NAME} ${VALUE} ${DATE}
echo "${HOSTNAME}.${NAME} ${VALUE} ${DATE}" | nc ${GRAPHITE_SERVER} ${GRAPHITE_PORT}
fi
done
sleep 10
done