Here is a small script for this.
#!/bin/bash
# This file will load at every start (add to /etc/rc.local)
# Will verify if the kernel is different with the older started kernel and send a mail to you.
# in /boot/grub/grub.conf you need to put panic=5
# Checking whether Root Runs the Application
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root !" 1>&2
exit 1
fi
MAIL='YOURMEMAIL-HERE' // edit this line
RUNKERNEL=`uname -a |awk '{print $3}'`
FILEKERNEL='/etc/krnversion'
# If Kernel Version File does not exist, create it from the current running kernel
if [ ! -f $FILEKERNEL ]; then
echo $RUNKERNEL > $FILEKERNEL
else
GETFILEKERNEL=`cat $FILEKERNEL`
# if the file exists, compare the running kernel with the one on file and if they differ, update the kernel record file with the current kernel & notify the administration
if [ "$RUNKERNEL" != "$GETFILEKERNEL" ]; then
echo $RUNKERNEL > $FILEKERNEL
echo "!!! Warning !!!
Difference found in Kernel Versions between the Running Kernel Version and the Kernel Version File !
This probably happened because of a Kernel Upgrade or the loading of an Older Kernel to compensate for a newer Kernel panic.
Please check the versions below, make a determination and act accordingly:
Running Kernel Version is $RUNKERNEL while the Kernel Version on File is $GETFILEKERNEL
* However, the Kernel Version File was updated to match the Running Kernel Version *
#" > ~anquietas/Desktop/KERNEL_SCRIPT_LOG
| mail -s "Kernel Versios Difference Detected !" MAIL
fi
fi