Skip to content

Commit

Permalink
Merge pull request statsd#109 from shaftoe/master
Browse files Browse the repository at this point in the history
Add a basic CLI bash client to example directory
  • Loading branch information
mrtazz committed Jun 26, 2012
2 parents 97888e6 + d00be7a commit 42ff275
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Here's a bunch of example code contributed by the communinty for interfacing wit
python_example.py - Python
ruby_example.rb - Ruby
statsd.erl - Erlang
statsd-client.sh - Bash

Third Party StatsD Libraries
============================
Expand Down
25 changes: 25 additions & 0 deletions examples/statsd-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
#
# Very simple bash client to send metrics to a statsd server
# Example with gauge: ./statsd-client.sh 'my_metric:100|g'
#
# Alexander Fortin <[email protected]>
#
STATSD="statsd-ip-address"
PORT="8125"

if [ $# -ne 1 ]
then
echo "Syntax: $0 '<gauge_data_for_statsd>'"
exit 1
fi

# Setup UDP socket with statsd server
exec 3<> /dev/udp/${STATSD}/${PORT}

# Send data
echo "$1" >&3

# Close UDP socket
exec 3<&-
exec 3>&-

0 comments on commit 42ff275

Please sign in to comment.