#!/bin/bash

# Variable contains the states we want to use to filter the dmesg output
states_dmesg="alert,emerg,err,crit";

#Exceptions dmesg
exception_dmesg="$1";

# Variable gets the actual Date, in a for dmesg matching format
date_today_dmesg=$(date "+%a %b %e");

# Variable gets a filtered Output of dmesg
output_dmesg=$(dmesg -T -l "$states_dmesg" | grep -Ev "$exception_dmesg" | grep "$date_today_dmesg" | tail -20)

# If the variable output_dmesg is not empty, the script ends with an output of the variable contents and a warning status. 
if [[ "$output_dmesg" != "" ]]; then
	echo "$output_dmesg"
	exit 1
fi


echo "Kein kritisches Problem"
exit 0

