Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 26 lines (21 sloc) 0.466 kb
5095868 @shaftoe Add CLI bash client example
shaftoe authored
1 #!/bin/bash
2 #
d00be7a @shaftoe Remove gauge reference
shaftoe authored
3 # Very simple bash client to send metrics to a statsd server
4 # Example with gauge: ./statsd-client.sh 'my_metric:100|g'
5095868 @shaftoe Add CLI bash client example
shaftoe authored
5 #
6 # Alexander Fortin <alexander.fortin@gmail.com>
7 #
b99c0d5 @Dieterbe allow overriding statsd host and port
Dieterbe authored
8 host="${STATSD_HOST:-127.0.0.1}"
9 port="${STATSD_PORT:-8125}"
5095868 @shaftoe Add CLI bash client example
shaftoe authored
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
b99c0d5 @Dieterbe allow overriding statsd host and port
Dieterbe authored
18 exec 3<> /dev/udp/$host/$port
5095868 @shaftoe Add CLI bash client example
shaftoe authored
19
20 # Send data
92eff4d @mrtazz use printf in shell example client
mrtazz authored
21 printf "$1" >&3
5095868 @shaftoe Add CLI bash client example
shaftoe authored
22
23 # Close UDP socket
24 exec 3<&-
25 exec 3>&-
Something went wrong with that request. Please try again.