UNPKG

499 Bapplication/x-shView Raw
1#!/usr/bin/env bash
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#
8host="${STATSD_HOST:-127.0.0.1}"
9port="${STATSD_PORT:-8125}"
10
11if [ $# -ne 1 ]
12then
13 echo "Syntax: $0 '<gauge_data_for_statsd>'"
14 exit 1
15fi
16
17# Setup UDP socket with statsd server
18exec 3<> /dev/udp/$host/$port
19
20# Send data
21printf "$1" >&3
22
23# Close UDP socket
24exec 3<&-
25exec 3>&-