Skip to content

Instantly share code, notes, and snippets.

@maethor
Last active January 7, 2018 23:18
Show Gist options
  • Select an option

  • Save maethor/7008980 to your computer and use it in GitHub Desktop.

Select an option

Save maethor/7008980 to your computer and use it in GitHub Desktop.

Revisions

  1. maethor revised this gist Oct 16, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions check_kernel.sh
    Original file line number Diff line number Diff line change
    @@ -21,9 +21,9 @@ STATE_CRITICAL=2
    STATE_UNKNOWN=3

    currentkernel=$(uname -r)
    lastestkernel=$(ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | head -n1)
    latestkernel=$(ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | head -n1)

    if [ $lastestkernel = $currentkernel ] ; then
    if [ $latestkernel = $currentkernel ] ; then
    echo "OK - Running kernel: $currentkernel;"
    exit $STATE_OK
    else
  2. maethor created this gist Oct 16, 2013.
    37 changes: 37 additions & 0 deletions check_kernel.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    #!/bin/sh

    #
    # Guillaume Subiron, Sysnove, 2013
    #
    # Description :
    #
    # This plugin checks if we're running the newest installed kernel.
    # Works on Debian.
    #
    # Copyright 2013 Guillaume Subiron <[email protected]>
    # This work is free. You can redistribute it and/or modify it under the
    # terms of the Do What The Fuck You Want To Public License, Version 2,
    # as published by Sam Hocevar. See the http://www.wtfpl.net/ file for more details.
    #

    # Nagios return codes
    STATE_OK=0
    STATE_WARNING=1
    STATE_CRITICAL=2
    STATE_UNKNOWN=3

    currentkernel=$(uname -r)
    lastestkernel=$(ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | head -n1)

    if [ $lastestkernel = $currentkernel ] ; then
    echo "OK - Running kernel: $currentkernel;"
    exit $STATE_OK
    else
    if [ "$1" = "--warn-only" ] ; then
    echo "KERNEL WARNING - Running kernel: $currentkernel but newer kernel available: $latestkernel."
    exit $STATE_WARNING
    else
    echo "KERNEL CRITICAL - Running kernel: $currentkernel but newer kernel available: $latestkernel."
    exit $STATE_CRITICAL
    fi
    fi