From 736a22dfef42c610f4b101e681bf4b49275e9b5c Mon Sep 17 00:00:00 2001 From: Gardouille Date: Tue, 1 Sep 2015 11:44:03 +0200 Subject: [PATCH] Ceph-mon process monitor: ensure to run the ceph cmd even if a specific user must be use. --- dynmotd_scripts/06service | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/dynmotd_scripts/06service b/dynmotd_scripts/06service index 7a141ce..41d50c6 100755 --- a/dynmotd_scripts/06service +++ b/dynmotd_scripts/06service @@ -109,10 +109,8 @@ fi ### FI ZFS ### IF Ceph Monitor -#if [ $(command -v ceph-mon) ]; then -#ceph-mon is installed with the 'ceph' package -#so we can't just check if `ceph-mon` is available on a system if [ $(command -v ceph) ]; then + # Ensure the host is define as a initial monitor if (grep "mon_initial_members.*$(hostname)" /etc/ceph/*.conf > /dev/null); then MSG=$(process_info "ceph-mon" '') MSG=$(service_info "6789" "${MSG}") @@ -123,10 +121,27 @@ fi ### IF Ceph OSD if [ $(command -v ceph) ]; then - if (ceph osd tree | grep "host $(hostname)" > /dev/null 2> /dev/null); then - MSG=$(process_info "ceph-osd" '') - MSG=$(service_info "6800 6801 6802" "${MSG}") - printf '%b' "\n${MSG}" + # If there is a specific user + if [ -f /etc/ceph/*.keyring ]; then + for keyring in "$(find /etc/ceph -type f -name *.keyring)"; do + CEPH_USERNAME=$(grep client ${keyring} | sed 's/^\[client.\(.*\)\]/\1/') + CEPH_OSD_OK=$(ceph osd tree --id ${CEPH_USERNAME} | grep -i -- "host $(hostname)" 2> /dev/null) + if [ "${CEPH_OSD_OK}" ]; then + MSG="${MAGENTA}+++ ${WHITEB}BEGIN - ${keyring}${MAGENTA} +++${RESET}\n" + MSG=$(process_info "ceph-osd" "${MSG}") + MSG=$(service_info "6800 6801 6802" "${MSG}") + MSG="${MSG}\n${MAGENTA}+++ ${WHITEB}END - ${keyring}${MAGENTA} +++${RESET}" + printf '%b' "\n${MSG}" + fi + done + # Use default Ceph user + else + CEPH_OSD_OK=$(ceph osd tree | grep -i -- "host $(hostname)" 2> /dev/null) + if [ ${CEPH_OSD_OK} ]; then + MSG=$(process_info "ceph-osd" '') + MSG=$(service_info "6800 6801 6802" "${MSG}") + printf '%b' "\n${MSG}" + fi fi fi ### FI Ceph OSD