What's new

Feature request: Last Restart time

AppleBag

Regular Contributor
Would it be possible to add a small text label somewhere on the main page (the first one shown when logging in) that displays the last time the router was restarted/rebooted? Maybe even just as an icon next to the green ones at the top right, and when the cursor hovers over it, the alt text displays the timestamp.

I have my router set to reboot on a certain schedule, but often-times just based on network behavior, it seems as if it didn't do a reboot when it was supposed to. Having a label displaying this information would be very helpful in diagnosing issues for me.

Thanks!
 

RMerlin

Asuswrt-Merlin dev
Would it be possible to add a small text label somewhere on the main page (the first one shown when logging in) that displays the last time the router was restarted/rebooted? Maybe even just as an icon next to the green ones at the top right, and when the cursor hovers over it, the alt text displays the timestamp.

I have my router set to reboot on a certain schedule, but often-times just based on network behavior, it seems as if it didn't do a reboot when it was supposed to. Having a label displaying this information would be very helpful in diagnosing issues for me.

Thanks!
There is an uptime counter on the Sysinfo page, as well as the System Log page.
 

eibgrad

Senior Member
Here's perhaps an even better idea; send yourself an email every time the router is rebooted.

First, make sure JFFS custom scripts is enabled under Administration->System. Then after configuring sendmail in the script w/ the correct settings for your email provider (server, port, user, password), open an ssh session to the router and paste the script into the window. This will create an init-start script in /jffs/scripts which will get called whenever the router is rebooted.

Code:
mkdir -p /jffs/scripts

cat << "EOF" > /jffs/scripts/init-start
#!/bin/sh
set -x # comment/uncomment to disable/enable debug mode
(
send_email() {
    local server='xxxxxxxx'
    local port='xxxxxxxx'
    local user='xxxxxxxx'
    local password='xxxxxxxx'
    local from="$user"
    local to="$user"
    local subject="$1"
    local body="$2"

    echo -e "Subject:$subject\n$body\n" | \
        sendmail -S"$server:$port" -au"$user" -ap"$password" -f"$from" "$to"
}

# wait for *reliable* internet connection
while ! ping -qc1 -w3 8.8.8.8 > /dev/null 2>&1; do sleep 10; done; sleep 10

# try up to three (3) times to send email
for i in 1 2 3; do
    send_email "$(nvram get lan_hostname)->$(basename $0)" \
        "$(nvram get lan_hostname) rebooted @ $(date)" && exit
    sleep 60
done
) 2>&1 | logger -t $(basename $0)[$$] &
EOF

chmod +x /jffs/scripts/init-start
Now it's possible to filter those emails, trigger an alarm, etc. I suppose you could even modify it to send a text message.

Note, I purposely wrote the output of the script to the syslog so you can more easily debug it. You can grep for the output w/ the following command in an ssh session.

Code:
cat /tmp/syslog.log | grep init-start
Once you know it's working, you can comment out the debug line.

P.S. This is also a good way to know if your router is spontaneously rebooting for some reason, unbeknownst to you!
 
Last edited:

Latest threads

Sign Up For SNBForums Daily Digest

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