openfalcon客户端自定义push 传输到transfer

时间:2021-02-01 04:24:20
. linux客户端部署agent
. 编写脚本,比如: #!/usr/bin/env python
#!-*- coding:utf8 -*- import requests
import time
import json
import random
import os while True:
time.sleep()
payload_list = []
ts = int(time.time())
print ts
endpoint = os.popen('echo $HOSTNAME').read().strip()
value = random.randint(,)
temp_dict = {
"endpoint": endpoint,
"metric": "feng-count",
"timestamp": ts,
"step": ,
"value":value ,
"counterType": "GAUGE",
"tags": "idc_test",
}
payload_list.append(temp_dict)
requests.post("http://127.0.0.1:1988/v1/push", data=json.dumps(payload_list)) 注释:
必须按照 temp_dict 字典中的格式书写。 .查看agent值是否传输到query中
cd /data/query/script/
./query "endpoint" "counter(就是metric)"