#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import json
import os
zbx_srv = '192.168.xx.xx'
hostname = 'Rabbitmq-server'
url = 'http://192.168.xx.xx:15672/api/queues'
r = requests.get(url, auth=("UserName", "password"), timeout=5)
parsed = json.loads(r.content)
for i in parsed:
k = i.get('name') #队列名
v = i.get('messages') #待处理队列数
c = i.get('consumers') #消费者数
m = i.get('memory') ##队列消耗内存
print k, v, c, m
值抓出来后就可以用 zabbix_sender 命令推送到zabbix server了
网友评论