Skip to content
Snippets Groups Projects
Select Git revision
  • 111518dde5d1544b3d103d7f11000b28f78aaa09
  • master default
  • jas-ci-test
  • wip-slh-dsa-sha2-128s
  • master-updates
  • release-3.10-fixes
  • getopt-prototype
  • fix-bcrypt-warning
  • refactor-hmac
  • wip-use-alignas
  • trim-sha3-context
  • fix-gitlab-ci
  • check-fat-emulate
  • delete-digest_func-size
  • slh-dsa-shake-128f-nettle
  • slh-dsa-shake-128s-nettle
  • slh-dsa-shake-128s
  • delete-openpgp
  • ppc64-sha512
  • delete-md5-compat
  • cleanup-hmac-tests
  • nettle_3.10.2_release_20250626
  • nettle_3.10.1_release_20241230
  • nettle_3.10_release_20240616
  • nettle_3.10rc2
  • nettle_3.10rc1
  • nettle_3.9.1_release_20230601
  • nettle_3.9_release_20230514
  • nettle_3.8.1_release_20220727
  • nettle_3.8_release_20220602
  • nettle_3.7.3_release_20210606
  • nettle_3.7.2_release_20210321
  • nettle_3.7.1_release_20210217
  • nettle_3.7_release_20210104
  • nettle_3.7rc1
  • nettle_3.6_release_20200429
  • nettle_3.6rc3
  • nettle_3.6rc2
  • nettle_3.6rc1
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
41 results

sha1-compress.c

Blame
  • check_lysrdiff 2.91 KiB
    #!/bin/sh
    #
    # This check script is maintained in a Subversion repository at
    # http://lsvn.lysator.liu.se/svnroot/nagios-plugins.  Contact
    # <ceder@lysator.liu.se> for commit access.
    
    activity=26
    stale=40
    
    usage () {
      echo $0: usage: $0 '[ opt ] partno' >&2
      echo options: >&2
      echo '  --activty N  Warn if no backup completed in the last N hours.' >&2
      echo '  --stale N    Critical if oldest backup is more than N hours old.' >&2
      exit 3
    }
    
    while [ $# -gt 1 ]
    do
      case "x$1" in
        x--activity)
          activity=$2
          shift	
          shift;;
        x--stale)
          stale=$2
          shift
          shift;;
        x--*)
          usage
          exit 1;;
        x*) break;;
      esac
    done  
    
    if [ $# != 1 ]
    then
      usage
    fi
    
    partno=$1
    BASE=/lysrdiff/$partno/perm
    
    if [ ! -f $BASE/lysrdiff.id ]
    then
        echo CRITICAL - $BASE: no such file
        exit 2
    fi
    
    if [ "`cat $BASE/lysrdiff.id`" != "$partno perm" ]
    then
        echo CRITICAL - found `cat $BASE/lysrdiff.id` instead of $lysrdiff >&2
        exit 2
    fi
    
    acttime=`date '+%Y-%m-%d %H:%M:%S' -d "$activity hours ago"`
    staletime=`date '+%Y-%m-%d %H:%M:%S' -d "$stale hours ago"`
    
    statecache=/tmp/lysrdiff-nagios-state
    state=$statecache-$partno
    
    find $BASE/lysrdiff/state -type f \
    	-printf "%TY-%Tm-%Td %TH:%TM:%TS %P\n" \
          | sort > $statecache.$partno.$$
    mv -f $statecache.$partno.$$ $state || {
      echo UNKNOWN - mv failed
      rm $statecache.$partno.$$
      exit 3
    }
    rm -f $state-stale $state-active || {
      echo UNKNOWN - rm failed
      rm $state
      exit 3
    }
    
    echo $staletime MARKER \
    | sort $state - \
    | grep -- '-start$\|MARKER' \
    | sed -e '/MARKER$/,$d' \
    > $state-stale
    
    echo $acttime MARKER \
    | sort $state - \
    | grep -- '-end$\|MARKER' \
    | sed -e '0,/MARKER$/d' \
    > $state-active
    
    FAILED=`grep -c -- '-fail$' $state`
    STALE=`wc -l < $state-stale`
    ACTIVITY=`wc -l < $state-active`
    
    if [ $FAILED -gt 0 ]
    then
      echo -n "CRITICAL - $FAILED failed backups"
      if [ $STALE -gt 0 ]
      then
          echo -n " (also $STALE stale)"
      fi
      echo -n ": "
      sed -n 's/-fail$//p' $state \
        |awk 'BEGIN { sz = 0 }
    	  NR > 1 && sz < 198 { printf ", "; sz += 2 }
    	  sz < 200 { printf "%s", $3; sz += length($3) }
    	  END { if (sz >= 200) printf ", others" } ' \
        |sed s'/, \([^,]*\)$/ and \1/'
      echo '. | activity='$ACTIVITY stale=$STALE failed=$FAILED
      rm $state $state-stale $state-active
    
      exit 2
    fi
    
    if [ $STALE -gt 0 ]
    then
      echo -n "CRITICAL - $STALE stale backups: "
      sed 's/-start$//' $state-stale \
        |awk 'BEGIN { sz = 0 }
    	  NR > 1 && sz < 198 { printf ", "; sz += 2 }
    	  sz < 200 { printf "%s", $3; sz += length($3) }
    	  END { if (sz >= 200) printf ", others" } ' \
        |sed s'/, \([^,]*\)$/ and \1/'
      echo '. | activity='$ACTIVITY stale=$STALE failed=0
      rm $state $state-stale $state-active
      exit 2
    fi
    
    if [ $ACTIVITY = 0 ]
    then
      echo 'WARNING - No activity. | activity='0 stale=$STALE failed=0
      rm $state $state-stale $state-active
      exit 1
    fi
    
    echo 'OK - all ok. | activity='$ACTIVITY stale=0 failed=0
    rm $state $state-stale $state-active
    exit 0