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

Last change on this file was 1853, checked in by adehnert, 13 years ago
Remove line numbers
  • 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# (As quoted from http://lxr.linux.no/#linux+v2.6.38/kernel/panic.c#L181)
14# *      print_tainted - return a string to represent the kernel taint state.
15# *
16# *  'P' - Proprietary module has been loaded.
17# *  'F' - Module has been forcibly loaded.
18# *  'S' - SMP with CPUs not designed for SMP.
19# *  'R' - User forced a module unload.
20# *  'M' - System experienced a machine check exception.
21# *  'B' - System has hit bad_page.
22# *  'U' - Userspace-defined naughtiness.
23# *  'D' - Kernel has oopsed before
24# *  'A' - ACPI table overridden.
25# *  'W' - Taint on warning.
26# *  'C' - modules from drivers/staging are loaded.
27# *  'I' - Working around severe firmware bug.
28# *
29
30flag=1
31taints=""
32for i in P F S R M B U D A W C I; do
33    if [ $(($taintval & $flag)) -ne 0 ]; then
34        taints="$taints$i"
35    else
36        taints="$taints "
37    fi
38    flag=$(($flag * 2))
39done
40
41$ECHO "Tainted: $taints"
42
43case "$taints" in
44    *M*|*B*|*D*) exit $STATE_CRITICAL;;
45    *U*|*W*) exit $STATE_WARNING;;
46    *) exit $STATE_OK;;
47esac
48
Note: See TracBrowser for help on using the repository browser.