1 |
|
2 | #
|
3 | # Very simple bash client to send metrics to a statsd server
|
4 | # Example with gauge: ./statsd-client.sh 'my_metric:100|g'
|
5 | #
|
6 | # Alexander Fortin <alexander.fortin@gmail.com>
|
7 | #
|
8 | host="${STATSD_HOST:-127.0.0.1}"
|
9 | port="${STATSD_PORT:-8125}"
|
10 |
|
11 | if [ $# -ne 1 ]
|
12 | then
|
13 | echo "Syntax: $0 '<gauge_data_for_statsd>'"
|
14 | exit 1
|
15 | fi
|
16 |
|
17 | # Setup UDP socket with statsd server
|
18 | exec 3<> /dev/udp/$host/$port
|
19 |
|
20 | # Send data
|
21 | printf "$1" >&3
|
22 |
|
23 | # Close UDP socket
|
24 | exec 3<&-
|
25 | exec 3>&-
|