国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

[示例]使用python編寫prometheus_export

2020-02-24 16:09 作者:究極完美豆芽  | 我要投稿

環(huán)境:

python3.7

import subprocess
import prometheus_client
import time

request_count = prometheus_client.Counter('request_count', "啟動后到現(xiàn)在收集了幾數(shù)據(jù)")

job_count = prometheus_client.Gauge("job_count", "統(tǒng)計數(shù)量", ["user_name"])


# 執(zhí)行命令
def popen(cmd):
? ?try:
? ? ? ?result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?encoding="utf-8", shell=True, )
? ? ? ?return result.stdout
? ?except Exception as e:
? ? ? ?print(e)
? ? ? ?# 返回-1時為出錯
? ? ? ?return -1


def process_request(sleepTime):
? ?request_count.inc() ?# 數(shù)值+1
? ?job_count.labels(user_name="root").set(11)
? ?job_count.labels(user_name="testuser").set(22)
? ?time.sleep(sleepTime) ?# 睡眠


if __name__ == '__main__':
? ?prometheus_client.start_http_server(8080)
? ?print("啟動完成")
? ?while True:
? ? ? ?process_request(2) ?# 兩秒一次收集一次數(shù)據(jù)


[示例]使用python編寫prometheus_export的評論 (共 條)

分享到微博請遵守國家法律
田东县| 祁东县| 永城市| 瓦房店市| 南江县| 蓬安县| 黔江区| 光山县| 定结县| 临江市| 客服| 盈江县| 重庆市| 垫江县| 广饶县| 昭觉县| 山东省| 河间市| 易门县| 如东县| 湟中县| 太湖县| 临夏市| 方城县| 南宫市| 永胜县| 武夷山市| 昭苏县| 五莲县| 巩留县| 沂南县| 裕民县| 西安市| 新昌县| 潮安县| 花莲县| 普兰店市| 祁阳县| 临沧市| 石家庄市| 海阳市|