[RabbitMQ #3] RabbitMQ Server API 이용 Connection List 확인 하기

2022. 5. 24. 11:26 Spring Cloud/RabbitMQ

RabbitMQ Server API 이용, 연결된 Connection List 확인 하기

 

import requests

session = requests.Session()
session.auth = ("admin", "admin")
json_data = session.get("http://192.168.0.40:15672/api/connections").json()


for data in json_data:
    print(data["name"])
$ python main.py 
192.168.0.210:56129 -> 192.168.48.3:5672

 

수신된 JSON 데이터 원문

- RabbitMQ Server에 연결된 Connection은 1개이며, 

   {
      "auth_mechanism":"PLAIN",
      "channel_max":2047,
      "channels":1,
      "client_properties":{
         "capabilities":{
            "authentication_failure_close":true,
            "basic.nack":true,
            "connection.blocked":true,
            "consumer_cancel_notify":true,
            "publisher_confirms":true
         },
         "information":"See http://pika.rtfd.org",
         "platform":"Python 3.8.8",
         "product":"Pika Python Client Library",
         "version":"1.2.0"
      },
      "connected_at":1644819996067,
      "frame_max":131072,
      "garbage_collection":{
         "fullsweep_after":65535,
         "max_heap_size":0,
         "min_bin_vheap_size":46422,
         "min_heap_size":233,
         "minor_gcs":488
      },
      "host":"192.168.48.3",
      "name":"192.168.0.210:56129 -> 192.168.48.3:5672",
      "node":"rabbit@99061aa29786",
      "peer_cert_issuer":"None",
      "peer_cert_subject":"None",
      "peer_cert_validity":"None",
      "peer_host":"192.168.0.210",
      "peer_port":56129,
      "port":5672,
      "protocol":"AMQP 0-9-1",
      "recv_cnt":119,
      "recv_oct":1347,
      "recv_oct_details":{
         "rate":0.0
      },
      "reductions":627255,
      "reductions_details":{
         "rate":177.6
      },
      "send_cnt":123,
      "send_oct":2514,
      "send_oct_details":{
         "rate":0.0
      },
      "send_pend":0,
      "ssl":false,
      "ssl_cipher":"None",
      "ssl_hash":"None",
      "ssl_key_exchange":"None",
      "ssl_protocol":"None",
      "state":"running",
      "timeout":60,
      "type":"network",
      "user":"admin",
      "user_who_performed_action":"admin",
      "vhost":"/"
   }
]

 

Trouble Shooting

GET http://192.168.0.3:15672/api/connections 수행 후, 아래와 같은 응답을 받은 경우, User Tags에 administrator를 등록하면 API를 사용 할 수 있다.

 

{'error': 'not_authorised', 'reason': 'Not management user'}

 

 



출처: https://kaizen8501.tistory.com/196?category=958645 [Life4IoT]