五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
都昌县| 开阳县| 库伦旗| 浦城县| 连云港市| 遵化市| 巴里| 龙州县| 天峻县| 曲靖市| 莱州市| 北宁市| 二连浩特市| 屏东市| 德江县| 巢湖市| 三江| 资兴市| 松江区| 静宁县| 涟源市| 穆棱市| 金华市| 营口市| 乐昌市| 逊克县| 垫江县| 闸北区| 张掖市| 新民市| 鄂温| 阳东县| 长治县| 保定市| 白山市| 惠安县| 台东县| 仁怀市| 靖远县| 汉川市| 华亭县|