source: trunk/server/fedora/config/etc/nagios/check_kern_taint @ 1849

Last change on this file since 1849 was 1849, checked in by adehnert, 13 years ago
Add check for kernel taints This should allow nagios to alert on things like OOPSes and BUGS. See -i nagios.shining-armor.LOAD.d today for some of the background. Code initially by geofft and slightly updated by me.
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/bin/sh
2. /usr/lib64/nagios/plugins/utils.sh
3
4taintval=$(cat /proc/sys/kernel/tainted)
5
6if [ "$taintval" = 0 ]; then
7    $ECHO "Not tainted"
8    exit $STATE_OK
9fi
10
11# This is a bash reimplementation of kernel/panic.c:print_tainted
12# Letters are as follows:
13# 181 *      print_tainted - return a string to represent the kernel taint state.
14# 182 *
15# 183 *  'P' - Proprietary module has been loaded.
16# 184 *  'F' - Module has been forcibly loaded.
17# 185 *  'S' - SMP with CPUs not designed for SMP.
18# 186 *  'R' - User forced a module unload.
19# 187 *  'M' - System experienced a machine check exception.
20# 188 *  'B' - System has hit bad_page.
21# 189 *  'U' - Userspace-defined naughtiness.
22# 190 *  'D' - Kernel has oopsed before
23# 191 *  'A' - ACPI table overridden.
24# 192 *  'W' - Taint on warning.
25# 193 *  'C' - modules from drivers/staging are loaded.
26# 194 *  'I' - Working around severe firmware bug.
27# 195 *
28
29flag=1
30taints=""
31for i in P F S R M B U D A W C I; do
32    if [ $(($taintval & $flag)) -ne 0 ]; then
33        taints="$taints$i"
34    else
35        taints="$taints "
36    fi
37    flag=$(($flag * 2))
38done
39
40echo "Tainted: $taints"
41
42case "$taints" in
43    *M*|*B*|*D*) exit $STATE_CRITICAL;;
44    *U*|*W*) exit $STATE_WARNING;;
45    *) exit $STATE_OK;;
46esac
47
Note: See TracBrowser for help on using the repository browser.