| 
                Last change
                  on this file since 2709 was
                  1853,
                  checked in by adehnert, 15 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 |  | 
|---|
| 4 | taintval=$(cat /proc/sys/kernel/tainted) | 
|---|
| 5 |  | 
|---|
| 6 | if [ "$taintval" = 0 ]; then | 
|---|
| 7 |     $ECHO "Not tainted" | 
|---|
| 8 |     exit $STATE_OK | 
|---|
| 9 | fi | 
|---|
| 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 |  | 
|---|
| 30 | flag=1 | 
|---|
| 31 | taints="" | 
|---|
| 32 | for 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)) | 
|---|
| 39 | done | 
|---|
| 40 |  | 
|---|
| 41 | $ECHO "Tainted: $taints" | 
|---|
| 42 |  | 
|---|
| 43 | case "$taints" in | 
|---|
| 44 |     *M*|*B*|*D*) exit $STATE_CRITICAL;; | 
|---|
| 45 |     *U*|*W*) exit $STATE_WARNING;; | 
|---|
| 46 |     *) exit $STATE_OK;; | 
|---|
| 47 | esac | 
|---|
| 48 |  | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.