码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-06-22 12:49:31      阅读:368      评论:0      收藏:0      [点我收藏+]

标签:

1. linux客户端部署agent
2. 编写脚本,比如:

#!/usr/bin/env python
#!-*- coding:utf8 -*-

import requests
import time
import json
import random
import os


while True:
    time.sleep(20)
    payload_list = []
    ts = int(time.time())
    print ts
    endpoint = os.popen(echo $HOSTNAME).read().strip()
    value = random.randint(1,100)
    temp_dict = {
        "endpoint": endpoint,
        "metric": "feng-count",
        "timestamp": ts,
        "step": 60,
        "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 字典中的格式书写。

3.查看agent值是否传输到query中
cd /data/query/script/
./query "endpoint" "counter(就是metric)"

 

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

标签:

原文地址:http://www.cnblogs.com/fengjian2016/p/5606610.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!