#!/bin/bash
#####################
#
# Author: Gerrit Lazer
# Version: 0.1
#
# This check tells you if the physical/core CPU is within the warning or crit temperature
#
#####################

SENSORS="/usr/bin/sensors"

# Is sensors available? If not stop
if [[ ! -x $SENSORS ]]; then
        echo "sensors not available"
        exit 1
fi

# Check if a physical/core CPU within the critical
if [[ $( $SENSORS | egrep '(Physical|Core)' | awk -F'[\+\.]' '$2>=$6 { print "1";}' | wc -l ) > 0 ]]; then
        $SENSORS | grep Physical
        exit 2
fi

if [[ $( $SENSORS | egrep '(Physical|Core)' | awk -F'[\+\.]' '$2>=$4 { print "1";}' | wc -l ) > 0 ]]; then
        $SENSORS | grep Physical
        exit 1
else
        echo "No hotness"
        exit 0
fi

