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

Last change on this file since 1852 was 1852, checked in by adehnert, 13 years ago
Add link that the letter info came from
  • Property svn:executable set to *
File size: 1.3 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# 181 *      print_tainted - return a string to represent the kernel taint state.
15# 182 *
16# 183 *  'P' - Proprietary module has been loaded.
17# 184 *  'F' - Module has been forcibly loaded.
18# 185 *  'S' - SMP with CPUs not designed for SMP.
19# 186 *  'R' - User forced a module unload.
20# 187 *  'M' - System experienced a machine check exception.
21# 188 *  'B' - System has hit bad_page.
22# 189 *  'U' - Userspace-defined naughtiness.
23# 190 *  'D' - Kernel has oopsed before
24# 191 *  'A' - ACPI table overridden.
25# 192 *  'W' - Taint on warning.
26# 193 *  'C' - modules from drivers/staging are loaded.
27# 194 *  'I' - Working around severe firmware bug.
28# 195 *
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.