forked from statsd/statsd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request statsd#109 from shaftoe/master
Add a basic CLI bash client to example directory
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>&- |