Permalink
Browse files

Merge pull request #109 from shaftoe/master

Add a basic CLI bash client to example directory
  • Loading branch information...
2 parents 97888e6 + d00be7a commit 42ff27525e2efc9f8cf42de1ebec90ba45e3b8b1 @mrtazz mrtazz committed Jun 26, 2012
Showing with 26 additions and 0 deletions.
  1. +1 −0 examples/README.md
  2. +25 −0 examples/statsd-client.sh
View
@@ -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
============================
View
@@ -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 <alexander.fortin@gmail.com>
+#
+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.