× NETGEAR will be terminating ReadyCLOUD service by July 1st, 2023. For more details click here.
Orbi WiFi 7 RBE973
Reply

Addon Dev. Question - Action on Pressing Power Button?

heckz
Aspirant

Addon Dev. Question - Action on Pressing Power Button?

Hi. In response to a request for an addon that does more with the NV+ front panel LCD display I have started work on an add-on. So far I have created a shell script that produces various outputs to the LCD, which works fine when run manually (or via cron) from a SSH session with the NAS. I have been reading the addon SDK guide and want to know how I can change the behaviour of "user presses blue power button" with an addon...?

Otherwise I will just have to make an addon that periodically displays sys info e.g. every 30 minutes.. Which is less useful.

For info, here are some sample ""screenshots"" that the script does with the LCD. Any feature ideas are welcomed but please have an idea of how it could be implemented!

RAM:787MB/1002MB
Swap:0MB/1023MB

Load:0.06/0.08
Processes:75

hostname.domain
Up:102d/Users:1

Rcvd:2014MB
Sent:2212MB

IPv4:10.75.86.12
MTU:1500
Message 1 of 8
soremaniac
Aspirant

Re: Addon Dev. Question - Action on Pressing Power Button?

coool....when will the AddOn be finish :?

Regards Mike
Message 2 of 8
Skywalker
NETGEAR Expert

Re: Addon Dev. Question - Action on Pressing Power Button?

You could consider patching /etc/hotplug/powersave.agent 🙂
Message 3 of 8
soremaniac
Aspirant

Re: Addon Dev. Question - Action on Pressing Power Button?

is the AddOn Online jet?
Message 4 of 8
heckz
Aspirant

Re: Addon Dev. Question - Action on Pressing Power Button?

Nah I never got around to it. But I did write this script, if you want to use it and put it in a cron or whatever... No warantee provided. YMMV.

#!/bin/bash
#
# System Info Script for ReadyNAS NV+ 16x2 LCD display.
# Cycles a selection of system information over LCD.
# 0.2a by rxbyte@gmail.com

# ---- Global Variables ----
# No need to alter unless debugging on non-ReadyNAS platform
ROTATION_DELAY=10
NET_INT=eth0
HDD_DEV=/dev/hdc1
RAID_DEV=/dev/c/c
# LCD Flags
LCD_SHOW_MEM=1
LCD_SHOW_CPU=1
LCD_SHOW_SYS=1
LCD_SHOW_NET=1
LCD_SHOW_IP=1
LCD_SHOW_TIME=1
LCD_SHOW_HDD=1

# ---- LCD Management Functions ----
# Change state of LCD backlight
function set_backlight
{
if [ $1 = 0 ]; then
echo 0 > /proc/sys/dev/lcd/backlight
else
echo 1 > /proc/sys/dev/lcd/backlight
fi
}
# Write string to LCD device
function print_lcd
{
if [ $1 = 0 ]; then
echo 2 > /proc/sys/dev/lcd/cmd
else
echo 192 > /proc/sys/dev/lcd/cmd
fi
printf "%-16.16s" $2 > /dev/lcd
}
function reset_lcd
{
set_backlight 0
print_lcd 0 ""
print_lcd 1 ""
}
# ---- Statistics Generation Functions ----
# Each function below produces a string of information for display on one line of the LCD.
# Generate memory usage info
function get_meminfo
{
local s=""
sMemUsed=$(free -m | awk 'NR == 2 {print $3;}')
sMemTotal=$(free -m | awk 'NR == 2 {print $2;}')
s="RAM:"$sMemUsed"MB/"$sMemTotal"MB"
echo $s
}
# Generate swap usage info
function get_swapinfo
{
local s=""
sSwapUsed=$(free -m | awk 'NR == 4 {print $3;}')
sSwapTotal=$(free -m | awk 'NR == 4 {print $2;}')
s="Swap:"$sSwapUsed"MB/"$sSwapTotal"MB"
echo $s
}
# Generate system availability info
function get_uptimeinfo
{
local s=""
sUp=$(cat /proc/uptime | awk '{print $1;}' | cut -f1 -d.)
let "sUp /= 3600"
# sUnit=$(uptime | awk '{print $4;}' | cut -b1)
sUsers=$(uptime | awk '{print $4;}')
s="Up:"$sUp"h/Users:"$sUsers
echo $s
}
# Generate domain name info
function get_hostnameinfo
{
local s=""
sHostname=$(hostname -f)
s=$sHostname
echo $s
}
# Generate CPU load average info
function get_loadinfo
{
local s=""
sOneLoad=$(uptime | awk '{print $8;}' | cut -d, -f1)
sFifteenLoad=$(uptime | awk '{print $10;}' | cut -d, -f1)
s="Load:"$sOneLoad"/"$sFifteenLoad
echo $s
}
# Generate CPU processes info
function get_procinfo
{
local s=""
sProcs=$(ps ax | wc -l | awk '{print $1}')
s="Processes:"$sProcs
echo $s
}
# Generate network interface received data info
function get_ethrxinfo
{
local s=""
sRX=$(ifconfig $NET_INT | grep "RX bytes:" | awk '{print $2}' | cut -b7-64)
let "sRX /= 1048576"
s="Rcvd:"$sRX"MB"
echo $s
}
# Generate network interface sent data info
function get_ethtxinfo
{
local s=""
sTX=$(ifconfig $NET_INT | grep "RX bytes:" | awk '{print $6}' | cut -b7-64)
let "sTX /= 1048576"
s="Sent:"$sTX"MB"
echo $s
}
# Generate network interface IP address info
function get_ipinfo
{
local s=""
sIPV4=$(ifconfig $NET_INT | awk 'NR == 2 {print $2;}' | cut -b6-20)
s="IP:"$sIPV4
echo $s
}
# Generate network interface MTU info
function get_mtuinfo
{
local s=""
sMTU=$(ifconfig -s $NET_INT | awk 'NR == 2 {print $2}')
s="MTU:"$sMTU
echo $s
}
# Generate system date info
function get_dateinfo
{
local s=""
sDate=$(date +%a-%d/%m/%Y)
s=$sDate
echo $s
}
# Generate system time info
function get_timeinfo
{
local s=""
sTime=$(date +%H:%M)
s=$sTime
echo $s
}
# Generate free disc info for system partition
function get_syshdinfo
{
local s=""
sUsedSys=$(df -h $HDD_DEV | awk 'NR == 2 {print $3}')
sTotalSys=$(df -h $HDD_DEV | awk 'NR == 2 {print $2}')
s="Sys:"$sUsedSys"/"$sTotalSys
echo $s
}
# Generate free disc info for raid array partition
function get_raidhdinfo
{
local s=""
sUsedRaid=$(df -h $RAID_DEV | awk 'NR == 2 {print $3}')
sTotalRaid=$(df -h $RAID_DEV | awk 'NR == 2 {print $2}')
s="RAID:"$sUsedRaid"/"$sTotalRaid
echo $s
}

# ---- Main Function ----
# Display a series of statistics on the LCD
reset_lcd
set_backlight 1

# Display Memory Information
if [ $LCD_SHOW_MEM = 1 ]; then
print_lcd 0 `get_meminfo`
print_lcd 1 `get_swapinfo`
sleep $ROTATION_DELAY
fi

# Display Disk Space Information
if [ $LCD_SHOW_HDD = 1 ]; then
print_lcd 0 `get_syshdinfo`
print_lcd 1 `get_raidhdinfo`
sleep $ROTATION_DELAY
fi

# Display CPU Information
if [ $LCD_SHOW_CPU = 1 ]; then
print_lcd 0 `get_procinfo`
print_lcd 1 `get_loadinfo`
sleep $ROTATION_DELAY
fi

# Display System Information
if [ $LCD_SHOW_SYS = 1 ]; then
print_lcd 0 `get_hostnameinfo`
print_lcd 1 `get_uptimeinfo`
sleep $ROTATION_DELAY
fi

# Display Network Transport Information
if [ $LCD_SHOW_NET = 1 ]; then
print_lcd 0 `get_ethtxinfo`
print_lcd 1 `get_ethrxinfo`
sleep $ROTATION_DELAY
fi

# Display Network IP Information
if [ $LCD_SHOW_IP = 1 ]; then
print_lcd 0 `get_ipinfo`
print_lcd 1 `get_mtuinfo`
sleep $ROTATION_DELAY
fi

# Display Date and Time Information
if [ $LCD_SHOW_TIME = 1 ]; then
print_lcd 0 `get_dateinfo`
print_lcd 1 `get_timeinfo`
sleep $ROTATION_DELAY
fi

reset_lcd
exit 0
Message 5 of 8
goudkamp
Aspirant

Re: Addon Dev. Question - Action on Pressing Power Button?

This is great, thank you! Will use this with SABnzbd and such 🙂
Message 6 of 8
moegrease
Aspirant

Re: Addon Dev. Question - Action on Pressing Power Button?

i know this is a old thread but do you guys have this already compiled (.bin) and if so i was wondering if it could be sent my way please and thank you 😄
Message 7 of 8
viperhansa
Virtuoso

Re: Addon Dev. Question - Action on Pressing Power Button?

Old thread warning again... 🙂

But has there been any progress on this? Like a addon?
Message 8 of 8
Top Contributors
Discussion stats
  • 7 replies
  • 3729 views
  • 0 kudos
  • 6 in conversation
Announcements