What's new

Beta Script to monitor temperatures on RT-AC68U

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

haridsv

Occasional Visitor
Radios on my first router stopped working within hours of setting it up and I suspected it due to high temperature (CPU was at 96°C). When I got a replacement, I didn't want to take a chance so had it always running with a fan. I recently upgraded to RT-AC86U and converted the old router to an AiMesh node. It is now positioned at a location where the fan noise would be really bothersome, so I wanted to see if fan is really needed, so I disconnected it and observed it for a while. The temperatures were hovering at around 80°C/61°C/67°C for CPU, 2.4 and 5Ghz chips respectively. I could not say for sure if these are safe enough by googling, so I decided to create a little script to monitor and take some corrective action. I am sharing the script here to get some feedback. The script checks for all 3 temperatures and sends an email alert and it also takes an action if it is one of the radios. It basically turns off the corresponding radio and adds a cron entry to get it turned back on at the turn of the hour. E.g., I got my first alert a few minutes ago
Temperature too hot, CPU: 81/82 2.4Ghz wifi: 62/62 5Ghz wifi: 68/67
Router RT-AC68U
9:08 PM (48 minutes ago)
to me

Turning off 5Ghz radio for up to an hour
---
Your friendly router RT-AC68U.
When I checked the temperatures after about 50min, 2.4Ghz dropped from 62 to 56 and CPU dropped from 80 to 76. The 5Ghz radio was still off, so I waited for it get turned back on to check the temperature and it too dropped from 68 to 61. The script is working, but the max temperatures need some tweaking. Also, I noticed that when the 5Ghz radio was turned back on, it caused some disruption. The node went offline momentarily and my Mac laptop that is connected to this SSID lost connection, so I had to manually select the network again (for some reason my Mac doesn't automatically reconnect, even to my 2.4Ghz SSID which should be available).

Here is the script:
Code:
#!/bin/sh

# Based on: https://www.snbforums.com/threads/email-notification-when-switching-to-secondary-wan.39724/post-331321

MAX_TEMP_CPU=82
MAX_TEMP_24=62
MAX_TEMP_5=67

function radio_off() {
  local iface=$1
  wl -i $iface radio off
  local cronId=TurnOn-$iface
  cru a $cronId "0 * * * * wl -i $iface radio on; cru d $cronId"
}

# Email settings (mail envelope) #
FROM_ADDRESS="you@gmail.com"
TO_NAME="Your Name"
TO_ADDRESS="you@gmail.com"

# Email credentials #
USERNAME="you@gmail.com"
PASSWORD="gmail-password"

# Server settings #
SMTP="smtp.gmail.com"
PORT="587"

# FROM Name in email
FROM_NAME="Router $(nvram get productid)"

### Do not change below ###

# set environment PATH to system binaries
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH

wifi24_status=$(wl -i eth1 radio)
wifi5_status=$(wl -i eth2 radio)

cpu_temp=$(cat /proc/dmu/temperature | sed 's/[^0-9]//g')
wifi24_temp=$([ $wifi24_status = 0x0000 ] && wl -i eth1 phy_tempsense | sed 's/ .*//' || echo 0)
wifi5_temp=$([ $wifi5_status = 0x0000 ] && wl -i eth2 phy_tempsense | sed 's/ .*//' || echo 0)
if [ $cpu_temp -gt $MAX_TEMP_CPU -o $wifi24_temp -gt $MAX_TEMP_24 -o $wifi5_temp -gt $MAX_TEMP_5 ]; then
  msg="Temperature too hot, CPU: $cpu_temp/$MAX_TEMP_CPU 2.4Ghz wifi: $wifi24_temp/$MAX_TEMP_24 5Ghz wifi: $wifi5_temp/$MAX_TEMP_5"

  # notify Syslog of the event
  logger $msg

  # assemble the message
  echo "From: \"$FROM_NAME\" <$FROM_ADDRESS>" > /tmp/mail.txt
  echo "To: \"$TO_NAME\" <$TO_ADDRESS>" >> /tmp/mail.txt
  echo "Subject: $msg" >> /tmp/mail.txt
  echo "Date: $(date -R)" >> /tmp/mail.txt
  echo "" >> /tmp/mail.txt
  if [ $wifi24_temp -gt $MAX_TEMP_24 ]; then
    radio_off eth1
    echo "Turning off 2.4Ghz radio for up to an hour" >> /tmp/mail.txt
  fi
  if [ $wifi5_temp -gt $MAX_TEMP_5 ]; then
    radio_off eth2
    echo "Turning off 5Ghz radio for up to an hour" >> /tmp/mail.txt
  fi
  echo "--- " >> /tmp/mail.txt
  echo "Your friendly router $(nvram get productid)." >> /tmp/mail.txt

  # send with curl
  curl --url smtp://$SMTP:$PORT \
   --mail-from "$FROM_ADDRESS" --mail-rcpt "$TO_ADDRESS" \
   --upload-file /tmp/mail.txt \
   --ssl-reqd \
   --user "$USERNAME:$PASSWORD" --insecure

  # remove temp file
  rm /tmp/mail.txt
fi
I would appreciate any comments or suggestions for improving it further. Also, would appreciate inputs on what the max temperatures can safely be.
 
There are already numerous discussions/comparisons of router temperatures in these forums (which I can't be bothered to search for). But my RT-AC68U has been running for years at about 88/52/54 without any additional cooling. Expect higher CPU temperatures if you're putting load on the CPU (e.g. VPN, media server, etc.)
 
Yes, I have come across a few threads and some of them suggested that even 100°C is safe for the CPU, but I couldn't make any conclusions on safe temperatures for the wifi radios. E.g., comparing against yours, I see that the wifi radios are at 52/54 but I have never seen mine run that cool, except with active cooling.
 

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top