Skip to content
Snippets Groups Projects
Select Git revision
  • 3e550af3ef43a144c310c8d21c9f4988e2e88849
  • master default protected
  • simple-task/7248-eol-check-add-node-22
  • 6877_check_iml_deployment
4 results

check_requirements.md

Blame
  • check_ceph_status 1.35 KiB
    #!/bin/bash
    # ======================================================================
    #
    # Icinga/ Nagios Check
    # CEPH STATUS / HEALTH
    #
    # ----------------------------------------------------------------------
    #
    # REQUIREMENTS:
    #   - ceph
    #
    # SYNTAX:
    #   - check_ceph_status
    #     No parameter required
    #
    # ----------------------------------------------------------------------
    # 2020-03-04  v1.0  <axel.hahn@iml.unibe.ch>
    # 2020-03-05  v1.1  <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
    # ======================================================================
    
    . `dirname $0`/inc_pluginfunctions
    
    tmpfile=/tmp/ceph_status_output_$$
    
    # ----------------------------------------------------------------------
    # MAIN
    # ----------------------------------------------------------------------
    sudo /bin/ceph health > $tmpfile 2>&1
    grep "HEALTH_" $tmpfile >/dev/null
    if [ $? -ne 0 ]; then
    	rm -f $tmpfile
    	ph.abort "UNKNOWN: ceph is not available or no sudo permissions to execute ceph commands."
    fi
    
    grep "HEALTH_OK" $tmpfile >/dev/null
    if [ $? -eq 0 ]; then
    	ph.setStatus "ok"
    else
    
    	grep "HEALTH_WARN" $tmpfile >/dev/null
    	if [ $? -eq 0 ]; then
    		ph.setStatus "warning"
    	else
    		ph.setStatus "critical"
    	fi
    fi
    
    ph.status "Ceph status is `cat $tmpfile`"
    echo
    sudo /bin/ceph status
    
    rm -f $tmpfile
    ph.exit
    
    # ----------------------------------------------------------------------