标签:文件存在与否;os
#!/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本文出自 “Zcy.gy” 博客,请务必保留此出处http://1064187464.blog.51cto.com/9108437/1834860
标签:文件存在与否;os
原文地址:http://1064187464.blog.51cto.com/9108437/1834860