{"id":144,"date":"2025-10-21T07:58:10","date_gmt":"2025-10-20T23:58:10","guid":{"rendered":"https:\/\/www.sretalk.com\/?p=144"},"modified":"2025-12-17T10:20:33","modified_gmt":"2025-12-17T02:20:33","slug":"rabbitmq-%e5%b7%a1%e6%a3%80%e8%84%9a%e6%9c%ac%ef%bc%88%e7%a4%ba%e4%be%8b%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.sretalk.com\/?p=144","title":{"rendered":"RabbitMQ \u5de1\u68c0\u811a\u672c\uff08\u793a\u4f8b\uff09"},"content":{"rendered":"\n<pre class=\"wp-block-code language=shell\"><code>#!\/bin\/bash\n# ============================================\n# RabbitMQ HTTP API \u5de1\u68c0\u811a\u672c (curl)\n# Version: 2.0\n# ============================================\n\n# ---------- \u57fa\u672c\u914d\u7f6e ----------\nRMQ_HOST=\"127.0.0.1\"\nRMQ_PORT=\"15672\"\nRMQ_USER=\"guest\"\nRMQ_PASS=\"guest\"\nPROTO=\"http\"\n\nAPI_BASE=\"${PROTO}:\/\/${RMQ_HOST}:${RMQ_PORT}\/api\"\n\nOUT=\"\/tmp\/rabbitmq_http_inspect_$(hostname)_$(date +%F_%H%M).txt\"\n\nCURL=\"curl -s -u ${RMQ_USER}:${RMQ_PASS}\"\n\n# ---------- Header ----------\n{\necho \"===================================\"\necho \" RabbitMQ \u96c6\u7fa4\u5de1\u68c0\u62a5\u544a (HTTP API)\"\necho \"\u751f\u6210\u65f6\u95f4: $(date)\"\necho \"\u4e3b\u673a\u540d: $(hostname)\"\necho \"API \u5730\u5740: ${API_BASE}\"\necho \"===================================\"\n} | tee \"$OUT\"\n\n# ---------- \u5de5\u5177\u51fd\u6570 ----------\nsection () {\n  echo -e \"\\n&#91;$1] $2\" | tee -a \"$OUT\"\n}\n\nsub () {\n  echo -e \"\\n---- $1 ----\" | tee -a \"$OUT\"\n}\n\n# ---------- 1. \u6982\u89c8 ----------\nsection 1 \"\u96c6\u7fa4\u603b\u4f53\u6982\u89c8\"\n$CURL \"${API_BASE}\/overview\" | tee -a \"$OUT\"\n\n# ---------- 2. \u96c6\u7fa4\u4e0e\u8282\u70b9 ----------\nsection 2 \"\u96c6\u7fa4\u4e0e\u8282\u70b9\u72b6\u6001\"\n\nsub \"\u8282\u70b9\u5217\u8868\"\n$CURL \"${API_BASE}\/nodes\" | tee -a \"$OUT\"\n\nsub \"\u96c6\u7fa4\u540d\u79f0\"\n$CURL \"${API_BASE}\/cluster-name\" | tee -a \"$OUT\"\n\n# ---------- 3. \u961f\u5217\u4e0e\u6d88\u606f ----------\nsection 3 \"\u961f\u5217\u4e0e\u6d88\u606f\u72b6\u6001\"\n\nsub \"\u6240\u6709\u961f\u5217\"\n$CURL \"${API_BASE}\/queues\" | tee -a \"$OUT\"\n\nsub \"\u6b7b\u4fe1\u961f\u5217 (DLX\/DLQ)\"\n$CURL \"${API_BASE}\/queues\" \\\n  | grep -Ei \"dead|dlx|dlq\" | tee -a \"$OUT\"\n\n# ---------- 4. \u4ea4\u6362\u673a ----------\nsection 4 \"\u4ea4\u6362\u673a\u4fe1\u606f\"\n\n$CURL \"${API_BASE}\/exchanges\" | tee -a \"$OUT\"\n\n# ---------- 5. \u8fde\u63a5\u4e0e\u901a\u9053 ----------\nsection 5 \"\u8fde\u63a5\u4e0e\u901a\u9053\u72b6\u6001\"\n\nsub \"Connections\"\n$CURL \"${API_BASE}\/connections\" | tee -a \"$OUT\"\n\nsub \"Channels\"\n$CURL \"${API_BASE}\/channels\" | tee -a \"$OUT\"\n\n# ---------- 6. \u7ed1\u5b9a\u5173\u7cfb ----------\nsection 6 \"Bindings (Exchange \u2194 Queue)\"\n\n$CURL \"${API_BASE}\/bindings\" | tee -a \"$OUT\"\n\n# ---------- 7. \u865a\u62df\u4e3b\u673a ----------\nsection 7 \"Vhosts\"\n\n$CURL \"${API_BASE}\/vhosts\" | tee -a \"$OUT\"\n\n# ---------- 8. \u7528\u6237\u4e0e\u6743\u9650 ----------\nsection 8 \"\u7528\u6237\u4e0e\u6743\u9650\"\n\nsub \"Users\"\n$CURL \"${API_BASE}\/users\" | tee -a \"$OUT\"\n\nsub \"Permissions\"\n$CURL \"${API_BASE}\/permissions\" | tee -a \"$OUT\"\n\n# ---------- 9. \u7b56\u7565 ----------\nsection 9 \"Policies\"\n\n$CURL \"${API_BASE}\/policies\" | tee -a \"$OUT\"\n\n# ---------- 10. \u5065\u5eb7\u68c0\u67e5 ----------\nsection 10 \"\u5065\u5eb7\u68c0\u67e5\"\n\nsub \"Aliveness Test (\/)\"\n$CURL -X GET \"${API_BASE}\/aliveness-test\/%2F\" | tee -a \"$OUT\"\n\n# ---------- Footer ----------\n{\necho -e \"\\n===================================\"\necho \" \u5de1\u68c0\u5b8c\u6210\uff0c\u62a5\u544a\u6587\u4ef6\u8def\u5f84: $OUT\"\necho \"===================================\"\n} | tee -a \"$OUT\"\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-144","post","type-post","status-publish","format-standard","hentry","category-rabbitmq"],"_links":{"self":[{"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/posts\/144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=144"}],"version-history":[{"count":4,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/posts\/144\/revisions"}],"predecessor-version":[{"id":170,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=\/wp\/v2\/posts\/144\/revisions\/170"}],"wp:attachment":[{"href":"https:\/\/www.sretalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sretalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}