-
Notifications
You must be signed in to change notification settings - Fork 23
/
check_dmesg.sh
executable file
·42 lines (38 loc) · 1.02 KB
/
check_dmesg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
#
# Check dmesg output for common errors
#
# Usage: check_dmesg.sh
# -h, --help Display this screen
#
# (c) 2014, Benjamin Dos Santos <benjamin.dossantos@gmail.com>
# https://github.com/bdossantos/nagios-plugins
#
while [[ -n "$1" ]]; do
case $1 in
--help | -h)
sed -n '2,7p' "$0" | tr -d '#'
exit 3
;;
*)
echo "Unknown argument: $1"
exec "$0" --help
exit 3
;;
esac
shift
done
output=$(dmesg -T -l warn,err,crit,alert,emerg 2>/dev/null || dmesg || exit 3)
if [[ ! -z "$output" ]]; then
filtered_output=$({
echo "$output" | egrep -o -i \
'Hardware Error|I/O error|hard resetting link|DRDY ERR|critical medium error|Out of memory|Killed process|temperature above threshold|Possible SYN flooding|segfault|MEMORY ERROR|dropping packet'
})
if [[ ! -z "$filtered_output" ]]; then
echo 'WARNING - The dmesg output contain error(s) :'
echo "$filtered_output"
exit 1
fi
fi
echo "OK - The dmesg command output doesn't seem contain error."
exit 0