探测文件存在与否push状态至falcon
#!/usr/bin/python27#-*- coding:utf8 -*-
import requests
import time
import json
import os,os.path
eaglecachelog="PATH/TO/SOME_FILE"
ts = int(time.time())
if os.path.isfile(eaglecachelog):
state = 1
else:
state = 0
print state
cache = [
{
"endpoint":"HOSTNAME",
"metric":"eaglecache",
"timestamp":ts,
"step":300,
"value":state,
"counterType": "GAUGE",
"tags": "eaglecache=agent",
}
]
s = requests.post("http://127.0.0.1:1988/v1/push", data=json.dumps(cache))
print s.text
页:
[1]