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

check_netstat

Blame
  • check_uptime 1.56 KiB
    #!/bin/bash
    # ======================================================================
    #
    # NAGIOS CLIENT CHECK :: show uptime and if automatic update is ON
    #
    # REQUIREMENTS
    # - client uses a cronjob with cronwrapper (it creates parsable logs)
    #
    # It returns
    # - OK in all cases
    #
    # ----------------------------------------------------------------------
    #
    # ah=axel.hahn@iml.unibe.ch
    # ds=daniel.schueler@iml.unibe.ch
    #
    # 2018-12-17  v1.0  ah,ds
    # 2020-03-05  v1.1  <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
    # 2020-03-10  v1.2  <axel.hahn@iml.unibe.ch> add performance data
    # 2020-07-02  v1.3  <axel.hahn@iml.unibe.ch> use sec for performance data
    # 2022-10-21  v1.3  <axel.hahn@unibe.ch>     remove grep: warning: stray \ before white space
    # ======================================================================
    
    
    . `dirname $0`/inc_pluginfunctions
    cronfile=/etc/cron.d/system-updater
    
    # ----------------------------------------------------------------------
    # MAIN
    # ----------------------------------------------------------------------
    
    iSecUp=`cat /proc/uptime | awk '{print $1}'`
    echo "Uptime: `uptime | awk '{ print $3 " days " $5 " h"}' | tr -d ","` ... $iSecUp sec"
    
    # --- status of auto update (IML specific)
    ls ${cronfile} >/dev/null 2>&1
    if [ $? -eq 0 ]; then
      echo Autoupdate ON
      grep -- " -r" ${cronfile} >/dev/null 2>&1 
      if [ $? -eq 0 ]; then
        echo Autoreboot ON
      else
        echo Autoreboot OFF
      fi
    else
      echo Autoupdate OFF
    fi
    
    # --- add performance data
    ph.perfadd uptime $iSecUp
    
    ph.exit
    
    # ----------------------------------------------------------------------