How to configure kdump Linux Script ?


This script checks your crash dump configuration for  Linux server especially Redhat 5-6 . You can  configure  parameter  for your server. Just edit  “for loop”  to change  kernel parameter then you ‘ll be able  to check your  linux  crash dump  configuration.

 

#!/bin/ksh
# Title : kdump_Control.sh
# Author : Abdurrahim YILDIRIM
# Version : 0.1
# bash_version : Tested on GNU bash, version 4.1.2(1)-release
if cat /etc/redhat-release |awk ‘{print $7}’|cut -d ‘.’ -f 1,1 |grep -q “5” >/dev/null 2>&1
then
if service kdump status|grep -qw “operational” >/dev/null 2>&1
then
COUNT_NOTFOUND=0
for i in $(echo “kernel.sysrq=1
kernel.panic=10
kernel.panic_on_oops=1
kernel.panic_on_unrecovered_nmi=1
kernel.unknown_nmi_panic=1”)
do
temp_value=echo $i|cut -d ‘=’ -f 2,2|awk ‘{print $1}’
temp_deg=echo $i|cut -d ‘=’ -f 1,1|awk ‘{print $1}’
if sysctl $temp_deg|cut -d ‘=’ -f 2,2 |grep -qv $temp_value > /dev/null 2>&1
then
COUNT_NOTFOUND=$(( $COUNT_NOTFOUND + 1 ))
DUMPSTATUS_VER=echo $DUMPSTATUS_VER $temp_deg=$temp_value
fi
done
if [[ $COUNT_NOTFOUND = “0” ]]
then
if dmidecode -t system|grep -wq VMware >/dev/null 2>&1
then
if cat /boot/grub/grub.conf |grep -q crashkernel >/dev/null 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q ext3 >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q path >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q core_collector >/dev/nul 2>&1
then
DUMPSTATUS=echo “DUMPOK”
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “core_collector”
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “path”
fi
fi
if cat /etc/kdump.conf|grep -v ‘#’|grep -q net >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q core_collector >/dev/nul 2>&1
then
DUMPSTATUS=echo “DUMPOK”
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “core_collector”
fi
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “crashkernel”
fi
else
if cat /boot/grub/grub.conf |grep -q nmi_watchdog >/dev/null 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q ext3 >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q path >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q core_collector >/dev/nul 2>&1
then
DUMPSTATUS=echo “DUMPOK”
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “core_collector”
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “path”
fi
fi
if cat /etc/kdump.conf|grep -v ‘#’|grep -q net >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q core_collector >/dev/nul 2>&1
then
DUMPSTATUS=echo “DUMPOK”
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “core_collector”
fi
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “nmi_watchdog”
fi
fi
else
DUMPSTATUS=echo “DUMPNOK”
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “ServiceNotRunning”
fi
fi
if cat /etc/redhat-release |awk ‘{print $7}’|cut -d ‘.’ -f 1,1 |grep -q “6” >/dev/null 2>&1
then
if service kdump status|grep -qw “operational” >/dev/null 2>&1
then
COUNT_NOTFOUND=0
for i in $(echo “kernel.panic_on_oops=1
kernel.unknown_nmi_panic=1
kernel.panic=10
kernel.panic_on_unrecovered_nmi=1
kernel.panic_on_io_nmi=1”)
do
temp_value=echo $i|cut -d ‘=’ -f 2,2|awk ‘{print $1}’
temp_deg=echo $i|cut -d ‘=’ -f 1,1|awk ‘{print $1}’
if sysctl $temp_deg|cut -d ‘=’ -f 2,2 |grep -qv $temp_value > /dev/null 2>&1
then
COUNT_NOTFOUND=$(( $COUNT_NOTFOUND + 1 ))
DUMPSTATUS_VER=echo $DUMPSTATUS_VER $temp_deg=$temp_value
fi
done
if [[ $COUNT_NOTFOUND = “0” ]]
then
if dmidecode -t system|grep -wq VMware >/dev/null 2>&1
then
if cat /boot/grub/grub.conf |grep -q crashkernel >/dev/null 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q ext3 >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q path >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q core_collector >/dev/nul 2>&1
then
DUMPSTATUS=echo “DUMPOK”
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “core_collector”
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “path”
fi
fi
if cat /etc/kdump.conf|grep -v ‘#’|grep -q net >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q core_collector >/dev/nul 2>&1
then
DUMPSTATUS=echo “DUMPOK”
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “core_collector”
fi
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “crashkernel”
fi
else
if cat /boot/grub/grub.conf |grep -q nmi_watchdog >/dev/null 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q ext3 >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q path >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q core_collector >/dev/nul 2>&1
then
DUMPSTATUS=echo “DUMPOK”
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “core_collector”
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “path”
fi
fi
if cat /etc/kdump.conf|grep -v ‘#’|grep -q net >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q core_collector >/dev/nul 2>&1
then
DUMPSTATUS=echo “DUMPOK”
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “core_collector”
fi
fi
if cat /etc/kdump.conf|grep -v ‘#’|grep -q path >/dev/nul 2>&1
then
if cat /etc/kdump.conf|grep -v ‘#’|grep -q core_collector >/dev/nul 2>&1
then
DUMPSTATUS=echo “DUMPOK”
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “core_collector”
fi
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “nmi_watchdog”
fi
fi
else
DUMPSTATUS=echo “DUMPNOK”
fi
else
DUMPSTATUS=echo “DUMPNOK”
DUMPSTATUS_VER=echo “ServiceNotRunning”
fi
fi
echo “”
echo “`hostname` | $DUMPSTATUS | $DUMPSTATUS_VER”

 

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

200 Total Posts
Follow Me

0 Comments

Leave a Reply