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

check_php-fpm-status

Blame
  • about 3.05 KiB
    #!/bin/bash
    # ======================================================================
    #
    # Icinga/ Nagios Check
    # ABOUT
    #
    # ----------------------------------------------------------------------
    # 2023-10-23  v1.0  <axel.hahn@unibe.ch>  initial version
    # 2023-10-25  v1.1  <axel.hahn@unibe.ch>  show disks, show installed versions (WIP)
    # 2023-12-22  v1.2  <axel.hahn@unibe.ch>  show help
    # ======================================================================
    
    . $(dirname $0)/inc_pluginfunctions
    
    export self_APPVERSION=1.2
    
    . /etc/icingaclient/client.cfg 2>/dev/null
    
    # show versions of these tools. 
    # number 2 or 3 stands for position of version in the output 
    # tools2="curl restic php python"
    # tools3="rsync"
    
    # ----------------------------------------------------------------------
    # FUNCTIONS
    # ----------------------------------------------------------------------
    
    # show help text
    function showHelp(){
        local _self; _self=$(basename $0)
    cat <<EOF
    $( ph.showImlHelpHeader )
    
    About ... shows a short summary for the system:
    
      * operating system
      * cpu
      * ram
      * diskspace
      * checked services
    
    SYNTAX:
    
      $_self [-h]
    
    OPTIONS:
    
      -h, --help 
          this help
    
    EOF
    }
    
    function _section(){
        echo ">>>>>>>>>> $*"
    }
    
    # ----------------------------------------------------------------------
    # MAIN
    # ----------------------------------------------------------------------
    
    # --- check param -h
    
    while [[ "$#" -gt 0 ]]; do case $1 in
        -h|--help)      showHelp; exit 0;;
        *) echo "ERROR: Unknown parameter: $1"; showHelp; exit 1;
    esac; done
    
    _iCpu=$( grep -c "processor" /proc/cpuinfo )
    _sCpuModel=$(grep "model name" /proc/cpuinfo | sort -u )
    _iMem=$( grep "MemTotal:"   /proc/meminfo | awk '{ print $2 }' )
    _sMem=$( grep "MemTotal:"   /proc/meminfo | awk '{ print $2 " " $3}' )
    _sSwap=$( grep "SwapTotal:" /proc/meminfo | awk '{ print $2 " " $3}' )
    
    # ----- status line
    echo -n $( ph.getOS; ph.getOSMajor )
    echo -n " / ${_iCpu} cpu"
    echo -n " / $(ph.toUnit "${_iMem}K" "G" 3) GB ram"
    echo
    echo
    
    # ----- body text
    
    _section "CPU: $_iCpu"
    echo "${_sCpuModel}"
    echo
    
    _section "Memory"
    echo "RAM total    ${_sMem}"
    echo "Swap         ${_sSwap}"
    echo
    
    _section "Disks"
    out=$(df -h )
    echo "$out" | head -1
    for mydev in $( echo "$out" | grep "^/" | cut -f 1 -d " " | sort -u )
    do
        echo "$out" | grep "^$mydev" | head -1
    done
    echo
    
    if [ -d "${dir_checks}" ]; then
        _section "Services"
        cd "${dir_checks}"
        ls -1 Service-* | cut -f 2- -d "-"
        cd - >/dev/null 2>&1
        echo
    fi
    
    # hmmmm - too complicated...
    # _section "Tools"
    # (
    #     for mytool in $tools2
    #     do
    #         (
    #         $mytool --version 2>/dev/null \
    #             || $mytool version 2>/dev/null
    #         ) | head -1 | awk '{ print $1 " " $2 }'
    #     done
    #     for mytool in $tools3
    #     do
    #         (
    #         $mytool --version 2>/dev/null \
    #             || $mytool version 2>/dev/null
    #         ) | head -1 | awk '{ print $1 " " $3 }'
    #     done
    # ) | sort 
    # echo
    
    # _section "network"
    # ip -o a
    # echo
    # cat /etc/resolv.conf | grep "^[a-z0-9]"
    
    # ----------------------------------------------------------------------