0
TSD_HOST=localhost
TSD_PORT=4242
COLLECTION_INTERVAL=60

nc -z $TSD_HOST $TSD_PORT >/dev/null || exit 13

while :; do
  echo stats || exit
    sleep $COLLECTION_INTERVAL
done | nc $TSD_HOST $TSD_PORT

输出:

tsd.hbase.rpcs 1389058717 2037068142 type=put host=x
tsd.hbase.rpcs 1389058717 0 type=rowLock host=x
tsd.hbase.rpcs 1389058717 17 type=openScanner host=x
tsd.hbase.rpcs 1389058717 29 type=scan host=x
tsd.hbase.rpcs.batched 1389058717 5258656 host=x

以上是自带的默认tcollector脚本opentsdb。我想为每个打印出来的元素添加一个额外的标签;前任:

tsd.hbase.rpcs 1389058717 2037068142 type=put host=x  cluster=y

我想附加cluster=y到统计数据的每个元素。但我找不到一个好的捷径来做到这一点。

4

1 回答 1

1

将“”附加| awk '{print $0 " cluster=y"}'到“”行的末尾done | nc $TSD_HOST $TSD_PORT(或者,如果您不想修改脚本,只需执行tcollector | awk '{print $0 " cluster=y"})。

于 2014-01-07T01:51:34.290 回答