| 1 | #!/bin/bash |
| 2 | source /usr/share/ceph-tools/_ct-common |
| 3 | |
| 4 | help_msg () { |
| 5 | printf """ |
| 6 | usage: $0 [-h] KEY |
| 7 | |
| 8 | Description |
| 9 | -h, --help show this help message and exit |
| 10 | -g, --get get the configuration |
| 11 | -s, --set set the configuration |
| 12 | KEY config key to show |
| 13 | [VALUE] value for the key (optionnal) |
| 14 | |
| 15 | Example |
| 16 | $0 -g osd_recovery_sleep |
| 17 | $0 -s osd_recovery_sleep 0.1 |
| 18 | """ |
| 19 | } |
| 20 | |
| 21 | get_config() { |
| 22 | osd_list=$(ceph osd df -f json | jq '.nodes[]["id"]' |sort -n -u) |
| 23 | search=$'\'.[]|select(.name|test(\"'${1}$'\")).value\'' |
| 24 | for id in ${osd_list} |
| 25 | do |
| 26 | echo -n "osd.${id} : " |
| 27 | eval "ceph config show osd.${id} -f json | jq -e ${search}|| echo -n -e '\r'" |
| 28 | done |
| 29 | } |
| 30 | set_config(){ |
| 31 | ceph tell "osd.*" injectargs "--${1}=${2}" |
| 32 | } |
| 33 | |
| 34 | ct_help_min $# 1 |
| 35 | |
| 36 | while [ $# -gt 0 ] ; do |
| 37 | arg="$1" |
| 38 | case $arg in |
| 39 | -h|--help) |
| 40 | help_msg |
| 41 | ct_on_exit 0 |
| 42 | ;; |
| 43 | -g|--get) |
| 44 | key="^${2}$"$ |
| 45 | get_config $key |
| 46 | ct_on_exit 0 |
| 47 | ;; |
| 48 | -s|--set) |
| 49 | key="${2}" |
| 50 | value=$3 |
| 51 | set_config $key $value |
| 52 | ct_on_exit 0 |
| 53 | ;; |
| 54 | esac |
| 55 | done |
| 56 | |
| 57 | ct_on_exit 0 |