五月天青色头像情侣网名,国产亚洲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的評論 (共 條)

分享到微博請遵守國家法律
拜城县| 隆德县| 西藏| 临沂市| 宝坻区| 营山县| 靖西县| 文化| 安西县| 泽普县| 巴塘县| 蒙阴县| 湖州市| 龙里县| 鹰潭市| 孟津县| 竹溪县| 海门市| 靖江市| 南靖县| 荣成市| 高平市| 广安市| 睢宁县| 陆川县| 长武县| 双鸭山市| 晋江市| 大丰市| 石楼县| 博野县| 长岭县| 章丘市| 辉南县| 忻城县| 闻喜县| 吕梁市| 贺兰县| 黔西县| 南涧| 凤庆县|