Skip to content

Instantly share code, notes, and snippets.

@DaffyDuke
Created March 4, 2017 17:04
Show Gist options
  • Save DaffyDuke/324a75d80d08a0c3f12763df40c625e1 to your computer and use it in GitHub Desktop.
Save DaffyDuke/324a75d80d08a0c3f12763df40c625e1 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment