shell - RabbitMQ持久化信息获取

2022-12-20
#!/bin/bash
fields="name vhost durable"
types="queues exchanges"
declare -A dict
ips="192.168.13.136 192.168.10.132"
dict=([192.168.13.136]="passwd1" [192.168.10.132]="passwd2")
temp_path="/tmp/mq"
rm -rf ${temp_path}
mkdir -p ${temp_path}

for ip in ${ips}
do
    for type in ${types}
    do
        old_files=""
        for field in ${fields}
        do
            password=${dict[${ip}]}
            curl -s -u admin:${password} http://${ip}:15672/api/${type} | jq . > ${temp_path}/${ip}-${type}
            key_file=${temp_path}/${ip}-${type}-${field}
            cat ${temp_path}/${ip}-${type} | jq -r ".[]|.${field}" > ${key_file}
            old_files="${old_files} ${key_file}"
        done
        echo $old_files
        paste ${old_files} > ${temp_path}/${ip}-${type}
        rm ${old_files}
    done
done

标题:shell - RabbitMQ持久化信息获取
地址:https://blog.njqhome.com:8443/articles/2022/12/20/1671516176535.html