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

check_onevm.md

Blame
  • check_reboot_required 1.49 KiB
    #!/bin/bash
    # ======================================================================
    #
    # NAGIOS CLIENT CHECK :: is a restart required?
    #
    # ----------------------------------------------------------------------
    # works for sure on
    # - centos7
    # - debian6,7
    # - ubuntu10,12
    # ----------------------------------------------------------------------
    # 2016-08-12  added ouput of packages
    # 2020-03-05  v1.2  <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
    # ======================================================================
    
    
    . `dirname $0`/inc_pluginfunctions
    distro=`ph.getOS`
    
    # ----------------------------------------------------------------------
    case $distro in
    
      "centos")
        currentkernel=`uname -r`
        out=`rpm -q --last kernel | head -1 | fgrep $currentkernel`
        if [ -z "$out" ]; then
          ph.setStatus "warning"
          ph.status "[$distro] need to reboot for kernel `rpm -q --last kernel | head -1` (current: $currentkernel)"
        else
          ph.status "[$distro] no reboot required (kernel is up to date: $currentkernel)"
        fi
        ;;
    
      "debian"|"ubuntu")
      
        if [ ! -f /var/run/reboot-required ]; then
            ph.status "[$distro] no reboot required"
        else
            ph.setStatus "warning"
            ph.status "[$distro] `cat /var/run/reboot-required` by `tr '\n' ',' </var/run/reboot-required.pkgs`"
        fi
        ;;
    
      *)
        ph.abort "UNKNOWN: distro [$distro] was detected but is not supported (yet)."
        ;; 
    esac
    
    ph.exit
    
    # ----------------------------------------------------------------------