DaffyDuke
3/4/2017 - 5:04 PM

Nagios Plugin for dmesg Monitoring

Nagios Plugin for dmesg Monitoring

#!/bin/bash
# Source : http://lzone.de/blog/Nagios%20Plugin%20for%20dmesg%20Monitoring
SEVERITIES="err,alert,emerg,crit"
WHITELIST="microcode: |\
Firmware Bug|\
i8042: No controller|\
Odd, counter constraints enabled but no core perfctrs detected|\
Failed to access perfctr msr|\
echo 0 > /proc/sys"

# Check for critical dmesg lines from this day
date=$(date "+%a %b %e")
output=$(dmesg -T -l "$SEVERITIES" | egrep -v "$WHITELIST" | grep "$date" | tail -5)

if [ "$output" == "" ]; then
echo "All is fine."
exit 0
fi

echo "$output" | xargs
exit 1