Use "command -v" instead of "which"

see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html#tag_20_22_18
Add "monitor" for ceph osd.
This commit is contained in:
Jeremy Gardais 2015-08-29 10:01:47 +02:00
parent fede5d8b50
commit f7337fd9d8
2 changed files with 33 additions and 29 deletions

View File

@ -36,7 +36,7 @@ for PART in /boot /home /opt /tmp /usr /var /var/lib/vz; do
done done
### IF ZFS ### IF ZFS
if [ $(which zpool) ]; then if [ $(command -v zpool) ]; then
printf '%b' "\n${MAGENTA}+++++++++++++++++++ ${WHITEB}ZFS${RESET} ${WHITE}Partitions${RESET} ${MAGENTA}:++++++++++++++++++${RESET}" printf '%b' "\n${MAGENTA}+++++++++++++++++++ ${WHITEB}ZFS${RESET} ${WHITE}Partitions${RESET} ${MAGENTA}:++++++++++++++++++${RESET}"
NUMBER_PART=$(df -T | grep zfs | wc -l) NUMBER_PART=$(df -T | grep zfs | wc -l)
LINE=1 LINE=1

View File

@ -62,7 +62,7 @@ service_info() {
printf '%b' "${MAGENTA}+++++++++++++++++++: ${WHITE}Service Info${MAGENTA} :++++++++++++++++++++${RESET}" printf '%b' "${MAGENTA}+++++++++++++++++++: ${WHITE}Service Info${MAGENTA} :++++++++++++++++++++${RESET}"
## IF POSTFIX ## IF POSTFIX
if [ $(which postfix) ]; then if [ $(command -v postfix) ]; then
MSG=$(process_info "postfix" '') MSG=$(process_info "postfix" '')
MSG=$(service_info "25" "${MSG}") MSG=$(service_info "25" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -70,7 +70,7 @@ fi
## FI POSTFIX ## FI POSTFIX
### IF APACHE2 ### IF APACHE2
if [ $(which apache2) ]; then if [ $(command -v apache2) ]; then
MSG=$(process_info "apache2" '') MSG=$(process_info "apache2" '')
MSG=$(service_info "80 443" "${MSG}") MSG=$(service_info "80 443" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -78,7 +78,7 @@ fi
### FI APACHE2 ### FI APACHE2
### IF NGINX ### IF NGINX
if [ $(which nginx) ]; then if [ $(command -v nginx) ]; then
MSG=$(process_info "nginx" '') MSG=$(process_info "nginx" '')
MSG=$(service_info "80 443" "${MSG}") MSG=$(service_info "80 443" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -86,7 +86,7 @@ fi
### FI NGINX ### FI NGINX
### IF MYSQLD ### IF MYSQLD
if [ $(which mysqld) ]; then if [ $(command -v mysqld) ]; then
MSG=$(process_info "mysqld" '') MSG=$(process_info "mysqld" '')
MSG=$(service_info "3306" "${MSG}") MSG=$(service_info "3306" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -94,7 +94,7 @@ fi
### FI MYSQLD ### FI MYSQLD
### IF SLAPD ### IF SLAPD
if [ $(which slapd) ]; then if [ $(command -v slapd) ]; then
MSG=$(process_info "slapd" '') MSG=$(process_info "slapd" '')
MSG=$(service_info "389 636" "${MSG}") MSG=$(service_info "389 636" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -102,33 +102,37 @@ fi
### FI SLAPD ### FI SLAPD
### IF ZFS ### IF ZFS
if [ $(which zfs) ]; then if [ $(command -v zfs) ]; then
MSG=$(process_info "zfs" '') MSG=$(process_info "zfs" '')
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
fi fi
### FI ZFS ### FI ZFS
### IF Ceph Monitor ### IF Ceph Monitor
#if [ $(which ceph-mon) ]; then #if [ $(command -v ceph-mon) ]; then
#ceph-mon is installed with the 'ceph' package #ceph-mon is installed with the 'ceph' package
#so we can't just check if `ceph-mon` is available on a system #so we can't just check if `ceph-mon` is available on a system
if [ $(command -v ceph) ]; then
if (grep "mon_initial_members.*$(hostname)" /etc/ceph/*.conf > /dev/null); then if (grep "mon_initial_members.*$(hostname)" /etc/ceph/*.conf > /dev/null); then
MSG=$(process_info "ceph-mon" '') MSG=$(process_info "ceph-mon" '')
MSG=$(service_info "6789" "${MSG}") MSG=$(service_info "6789" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
fi fi
fi
### FI Ceph Monitor ### FI Ceph Monitor
### IF Ceph OSD ### IF Ceph OSD
if [ $(command -v ceph) ]; then
if (ceph osd tree | grep "host $(hostname)" > /dev/null 2> /dev/null); then if (ceph osd tree | grep "host $(hostname)" > /dev/null 2> /dev/null); then
MSG=$(process_info "ceph-osd" '') MSG=$(process_info "ceph-osd" '')
MSG=$(service_info "6800 6801 6802" "${MSG}") MSG=$(service_info "6800 6801 6802" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
fi fi
fi
### FI Ceph OSD ### FI Ceph OSD
### IF PUPPETMASTER ### IF PUPPETMASTER
if [ $(which puppetmaster) ]; then if [ $(command -v puppetmaster) ]; then
MSG=$(process_info "puppetmaster" '') MSG=$(process_info "puppetmaster" '')
MSG=$(service_info "8140" "${MSG}") MSG=$(service_info "8140" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -136,7 +140,7 @@ fi
### IF PUPPETMASTER ### IF PUPPETMASTER
### IF NFS Server ### IF NFS Server
if [ $(which nfsd) ]; then if [ $(command -v nfsd) ]; then
MSG=$(process_info "nfsd" '') MSG=$(process_info "nfsd" '')
MSG=$(service_info "111 2049" "${MSG}") MSG=$(service_info "111 2049" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -144,7 +148,7 @@ fi
### FI NFS Server ### FI NFS Server
### IF TFTPD ### IF TFTPD
if [ $(which in.tftpd) ]; then if [ $(command -v in.tftpd) ]; then
MSG=$(process_info "in.tftpd" '') MSG=$(process_info "in.tftpd" '')
#MSG=$(service_info "69" "${MSG}") #MSG=$(service_info "69" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -152,7 +156,7 @@ fi
### FI TFTPD ### FI TFTPD
### IF SQUID3 ### IF SQUID3
if [ $(which squid3) ]; then if [ $(command -v squid3) ]; then
MSG=$(process_info "squid3" '') MSG=$(process_info "squid3" '')
MSG=$(service_info "3128" "${MSG}") MSG=$(service_info "3128" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -160,7 +164,7 @@ fi
### FI SQUID3 ### FI SQUID3
### IF APT-CACHER-NG ### IF APT-CACHER-NG
if [ $(which apt-cacher-ng) ]; then if [ $(command -v apt-cacher-ng) ]; then
MSG=$(process_info "apt-cacher-ng" '') MSG=$(process_info "apt-cacher-ng" '')
MSG=$(service_info "3142" "${MSG}") MSG=$(service_info "3142" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -168,7 +172,7 @@ fi
### FI APT-CACHER-NG ### FI APT-CACHER-NG
### IF SSHD ### IF SSHD
if [ $(which sshd) ]; then if [ $(command -v sshd) ]; then
MSG=$(process_info "sshd" '') MSG=$(process_info "sshd" '')
MSG=$(service_info "22" "${MSG}") MSG=$(service_info "22" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -176,21 +180,21 @@ fi
### FI SSHD ### FI SSHD
### IF DHCPD ### IF DHCPD
if [ $(which dhcpd) ]; then if [ $(command -v dhcpd) ]; then
MSG=$(process_info "dhcpd" '') MSG=$(process_info "dhcpd" '')
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
fi fi
### FI DHCPD ### FI DHCPD
### IF FAIL2BAN ### IF FAIL2BAN
if [ $(which fail2ban-server) ]; then if [ $(command -v fail2ban-server) ]; then
MSG=$(process_info "fail2ban" '') MSG=$(process_info "fail2ban" '')
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
fi fi
### FI FAIL2BAN ### FI FAIL2BAN
### IF ETHERPAD ### IF ETHERPAD
if [ $(which etherpad) ]; then if [ $(command -v etherpad) ]; then
MSG=$(process_info "etherpad" '') MSG=$(process_info "etherpad" '')
MSG=$(service_info "9001" "${MSG}") MSG=$(service_info "9001" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -198,7 +202,7 @@ fi
### FI ETHERPAD ### FI ETHERPAD
### IF ETHERCALC ### IF ETHERCALC
if [ $(which ethercalc) ]; then if [ $(command -v ethercalc) ]; then
MSG=$(process_info "ethercalc" '') MSG=$(process_info "ethercalc" '')
MSG=$(service_info "8000" "${MSG}") MSG=$(service_info "8000" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -206,7 +210,7 @@ fi
### FI ETHERCALC ### FI ETHERCALC
### IF GITLAB ### IF GITLAB
if [ $(which gitlab-ctl) ]; then if [ $(command -v gitlab-ctl) ]; then
MSG=$(process_info "nginx" '') MSG=$(process_info "nginx" '')
MSG=$(service_info "80 443" "${MSG}") MSG=$(service_info "80 443" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -216,7 +220,7 @@ fi
### FI GITLAB ### FI GITLAB
### IF XYMONSERVER ### IF XYMONSERVER
if [ $(which xymond) ]; then if [ $(command -v xymond) ]; then
MSG=$(process_info "xymond" '') MSG=$(process_info "xymond" '')
MSG=$(service_info "1984" "${MSG}") MSG=$(service_info "1984" "${MSG}")
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
@ -224,7 +228,7 @@ fi
### FI XYMONSERVER ### FI XYMONSERVER
### IF XYMONCLIENT ### IF XYMONCLIENT
if [ $(which xymon) ]; then if [ $(command -v xymon) ]; then
MSG=$(process_info "xymonlaunch" '') MSG=$(process_info "xymonlaunch" '')
printf '%b' "\n${MSG}" printf '%b' "\n${MSG}"
fi fi