#!/bin/bash

inStr=$1
retUsage='0'

if [ "$#" -eq  "0" ]; then
     echo -e "\nPlease call '$0 <CPU, RAM or DISK>' to run this command!"
     echo "ex: $0 CPU"
     exit 1
fi

case $inStr in
        "CPU")
        # CPU Usage: in percent %
                retUsage=$(top -bn1 | awk '/Cpu/ { print $2}')
                echo "$retUsage%"
                ;;
        "RAM")
        # Memory Usage: in MB
                retUsage=$(free -m | awk '/Mem/{print $3}')
                echo "$retUsage MB"
                ;;
        "DISK")
        # Disk Usage: in percent %
                retUsage=$(df -kh . | tail -n1 | awk '{print $5}')
                echo "$retUsage"
                ;;
       "CPUTEMP")
        # CPU Temp: in celcius °
                TEMP_FILE=/sys/class/thermal/thermal_zone*/temp
		ORIGINAL_TEMP=$(cat $TEMP_FILE)
		retUsage=$((ORIGINAL_TEMP/1000))
                echo "$retUsage"
                ;;
esac

exit 0

