Develope/Programming

[Telegraf] Exec plugin test

고로이 2018. 6. 12. 17:43
반응형
1 test 파일 작성 ( cpu, memory )


#!/bin/sh
USED1=`free | grep ^Mem | awk '{print $4}'`
CPU=`mpstat | tail -1 | awk '{print 100-$11}'`
echo jmx-app1 mem=$USED1,cpu=$CPU
echo jmx-app2 mem=$USED1,cpu=$CPU




jmx-app1,mem=23497164,cpu=0.58 i=42i,j=43i,k=44i
jmx-app2,mem=23497164,cpu=0.58 i=42i,j=43i,k=44i

<Name>,Tag1=<val>,Tag2=<val> <field1>=<val>,<field1>=<val>,<field1>=<val>



2. Telegraf 등록
[[inputs.exec]]
  commands = ["sh /tmp/test.sh"]
  timeout = "5s"
  data_format = "influx"


3 확인


{
  "fields": {
    "i": 42,
    "j": 43,
    "k": 44
  },
  "name": "jmx-app1",
  "tags": {
    "cpu": "0.58",
    "host": "tcore-ic-test",
    "mem": "23382016"
  },
  "timestamp": 1528789390
}
{
  "fields": {
    "i": 42,
    "j": 43,
    "k": 44
  },
  "name": "jmx-app2",
  "tags": {
    "cpu": "0.58",
    "host": "tcore-ic-test",
    "mem": "23382016"
  },
  "timestamp": 1528789390


반응형