First a created a bash script that return 0 – error, 1 – OK, 2 – Old Kernel is running.
The script is called /usr/local/bin/last-kernel-check.sh
#!/bin/bash
name="`uname -a | cut -d ' ' -f3`"
new="0"
for files in `ls /boot/config* | xargs -n 1 basename | cut -d '-' -f2-`
do
if [ "$files" == "$name" ]; then
new="1"
else
new="2"
fi
done
echo $new
In file /etc/zabbix/zabbix_agentd.conf I added:
UserParameter=custom.checkkernel,/usr/local/bin/last-kernel-check.sh
In Zabbix a added one Item and two triggers.
The Item is checking the custom command custom.checkkernel added above to the zabbix-agentd.conf
One of the two trigger is used to check if the return value is 0 – Error and the other trigger is used for check if 2 – Old kernel is running.
Here you can download a export-file for Zabbix Linux Template. ChechKernel_Linux_templates_export
Leave a Reply