Skip to content

Instantly share code, notes, and snippets.

@libcrack
Created May 12, 2024 14:25
Show Gist options
  • Save libcrack/91470a86827272d09cfe7d279f9259c5 to your computer and use it in GitHub Desktop.
Save libcrack/91470a86827272d09cfe7d279f9259c5 to your computer and use it in GitHub Desktop.
Script to read CPU temperature in FreeBSD/pfSense boxes
#!/bin/sh
# devnull@libcrack.so
# Mon Sep 9 21:30:51 CEST 2019
#
# Title : cputemp
# Description: Prints the average CPU core temperature
# Author : linuxitux
# Date : 12-01-2016
# Usage : ./cputemp
# Notes : kldload coretemp
TEMP=0
CPUS=0
for T in $(sysctl -a | grep temperature | cut -d':' -f2 | tr -d " " | tr -d C | tr -d .)
do
TEMP=$((TEMP + T))
CPUS=$((CPUS + 1))
done
TEMP=$((TEMP / CPUS / 10))
if [ "${1}X" != "X" ]; then
echo "CPUs: ${CPUS}"
echo "Temp: ${TEMP} C"
else
echo "${TEMP}"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment