#!/bin/sh

#Hostname
echo -n $HOSTNAME >/tmp/$HOSTNAME.stat

# Load
echo -n " Load: ">>/tmp/$HOSTNAME.stat
uptime |awk '
/^/ { printf "%f", $8 }
' >>/tmp/$HOSTNAME.stat

#CPU Temperature
echo -n " CPU Temp: " >> /tmp/$HOSTNAME.stat
cat /proc/acpi/thermal_zone/THRM/temperature | awk '
/^/{
	cpuhi=60
	cpumd=50
	cpulo=40
	ct=$2
	if(ct > cpuhi) printf "\x01B[0;31m"
	else if (ct > cpumd) printf "\x01B[0;33m"
	else if (ct > cpulo) printf "\x01B[0;32m"
	else printf "\x01B[0;34m"
	printf "%d C",ct
	printf "\x01B[0m"
}' >> /tmp/$HOSTNAME.stat

#GPU Temperature
echo -n " GPU Temp: ">>/tmp/$HOSTNAME.stat
~/bin/nvidia-smi -a -q |awk '
/Temperature/ {
	gpuhi=80
	gpumd=65
	gpulo=45
	gt=$3
	if(gt > gpuhi) printf "\x01B[0;31m"
	else if (gt > gpumd) printf "\x01B[0;33m"
	else if (gt > gpulo) printf "\x01B[0;32m"
	else printf "\x01B[0;34m"
	printf "%d C", $3 
	printf "\x01B[0m \n"
}
/^/ { next }
' >>/tmp/$HOSTNAME.stat
cat /tmp/$HOSTNAME.stat
rm -f /tmp/$HOSTNAME.stat
