diff --git a/board/raspberrypi/motioneye-modules/boardctl.py b/board/raspberrypi/motioneye-modules/boardctl.py index d4bd1d3f25..a3ff722525 100644 --- a/board/raspberrypi/motioneye-modules/boardctl.py +++ b/board/raspberrypi/motioneye-modules/boardctl.py @@ -24,6 +24,29 @@ import streameyectl CONFIG_TXT = '/boot/config.txt' +MONITOR = '/data/etc/monitor_1' + +MONITOR_SCRIPT = '''#!/bin/bash + +net_tmp=/tmp/netspeed.tmp +temp=$(($(cat /sys/devices/virtual/thermal/thermal_zone0/temp) / 1000)) +load=$(cat /proc/loadavg | cut -d ' ' -f 2) +recv=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 3 | tail +3 | awk '{s+=$1} END {print s}') +send=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 11 | tail +3 | awk '{s+=$1} END {print s}') +total=$(($recv + $send)) + +if [ -e $net_tmp ]; then + prev_total=$(cat $net_tmp) + speed=$(($total - $prev_total)) +else + speed=0 +fi + +echo $total > $net_tmp +speed=$(($speed / 1024)) + +echo -n "$temp°|$load|${speed}kB/s" +''' OVERCLOCK = { 700: '700|250|400|0', @@ -169,6 +192,30 @@ def _set_board_settings(s): f.write(line) +def _get_sys_mon(): + return os.access(MONITOR, os.X_OK) + + +def _set_sys_mon(sys_mon): + if sys_mon: + if os.access(MONITOR, os.X_OK): + pass + + else: + if os.path.exists(MONITOR): + os.system('chmod +x %s' % MONITOR) + + else: + with open(MONITOR, 'w') as f: + f.write(MONITOR_SCRIPT) + + os.system('chmod +x %s' % MONITOR) + + else: + if os.access(MONITOR, os.X_OK): + os.system('chmod -x %s' % MONITOR) + + @additional_config def boardSeparator(): return { @@ -231,3 +278,17 @@ def overclock(): 'get_set_dict': True } + +@additional_config +def sysMon(): + return { + 'label': 'Enable System Monitoring', + 'description': 'when this is enabled, system monitoring info will be overlaid on top of the first camera frame', + 'type': 'bool', + 'section': 'expertSettings', + 'advanced': True, + 'reboot': False, + 'get': _get_sys_mon, + 'set': _set_sys_mon + } + diff --git a/board/raspberrypi2/motioneye-modules/boardctl.py b/board/raspberrypi2/motioneye-modules/boardctl.py index 94fb2ce749..2cf8235438 100644 --- a/board/raspberrypi2/motioneye-modules/boardctl.py +++ b/board/raspberrypi2/motioneye-modules/boardctl.py @@ -24,6 +24,29 @@ import streameyectl CONFIG_TXT = '/boot/config.txt' +MONITOR = '/data/etc/monitor_1' + +MONITOR_SCRIPT = '''#!/bin/bash + +net_tmp=/tmp/netspeed.tmp +temp=$(($(cat /sys/devices/virtual/thermal/thermal_zone0/temp) / 1000)) +load=$(cat /proc/loadavg | cut -d ' ' -f 2) +recv=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 3 | tail +3 | awk '{s+=$1} END {print s}') +send=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 11 | tail +3 | awk '{s+=$1} END {print s}') +total=$(($recv + $send)) + +if [ -e $net_tmp ]; then + prev_total=$(cat $net_tmp) + speed=$(($total - $prev_total)) +else + speed=0 +fi + +echo $total > $net_tmp +speed=$(($speed / 1024)) + +echo -n "$temp°|$load|${speed}kB/s" +''' OVERCLOCK = { 700: '700|250|400|0', @@ -164,6 +187,30 @@ def _set_board_settings(s): f.write(line) +def _get_sys_mon(): + return os.access(MONITOR, os.X_OK) + + +def _set_sys_mon(sys_mon): + if sys_mon: + if os.access(MONITOR, os.X_OK): + pass + + else: + if os.path.exists(MONITOR): + os.system('chmod +x %s' % MONITOR) + + else: + with open(MONITOR, 'w') as f: + f.write(MONITOR_SCRIPT) + + os.system('chmod +x %s' % MONITOR) + + else: + if os.access(MONITOR, os.X_OK): + os.system('chmod -x %s' % MONITOR) + + @additional_config def boardSeparator(): return { @@ -227,3 +274,17 @@ def overclock(): 'get_set_dict': True } + +@additional_config +def sysMon(): + return { + 'label': 'Enable System Monitoring', + 'description': 'when this is enabled, system monitoring info will be overlaid on top of the first camera frame', + 'type': 'bool', + 'section': 'expertSettings', + 'advanced': True, + 'reboot': False, + 'get': _get_sys_mon, + 'set': _set_sys_mon + } + diff --git a/board/raspberrypi3/motioneye-modules/boardctl.py b/board/raspberrypi3/motioneye-modules/boardctl.py index d2cccf450f..c314ae47f1 100644 --- a/board/raspberrypi3/motioneye-modules/boardctl.py +++ b/board/raspberrypi3/motioneye-modules/boardctl.py @@ -24,6 +24,29 @@ import streameyectl CONFIG_TXT = '/boot/config.txt' +MONITOR = '/data/etc/monitor_1' + +MONITOR_SCRIPT = '''#!/bin/bash + +net_tmp=/tmp/netspeed.tmp +temp=$(($(cat /sys/devices/virtual/thermal/thermal_zone0/temp) / 1000)) +load=$(cat /proc/loadavg | cut -d ' ' -f 2) +recv=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 3 | tail +3 | awk '{s+=$1} END {print s}') +send=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 11 | tail +3 | awk '{s+=$1} END {print s}') +total=$(($recv + $send)) + +if [ -e $net_tmp ]; then + prev_total=$(cat $net_tmp) + speed=$(($total - $prev_total)) +else + speed=0 +fi + +echo $total > $net_tmp +speed=$(($speed / 1024)) + +echo -n "$temp°|$load|${speed}kB/s" +''' OVERCLOCK = { 700: '700|250|400|0', @@ -167,6 +190,30 @@ def _set_board_settings(s): f.write(line) +def _get_sys_mon(): + return os.access(MONITOR, os.X_OK) + + +def _set_sys_mon(sys_mon): + if sys_mon: + if os.access(MONITOR, os.X_OK): + pass + + else: + if os.path.exists(MONITOR): + os.system('chmod +x %s' % MONITOR) + + else: + with open(MONITOR, 'w') as f: + f.write(MONITOR_SCRIPT) + + os.system('chmod +x %s' % MONITOR) + + else: + if os.access(MONITOR, os.X_OK): + os.system('chmod -x %s' % MONITOR) + + @additional_config def boardSeparator(): return { @@ -230,3 +277,17 @@ def cameraLed(): # 'get_set_dict': True # } + +@additional_config +def sysMon(): + return { + 'label': 'Enable System Monitoring', + 'description': 'when this is enabled, system monitoring info will be overlaid on top of the first camera frame', + 'type': 'bool', + 'section': 'expertSettings', + 'advanced': True, + 'reboot': False, + 'get': _get_sys_mon, + 'set': _set_sys_mon + } + diff --git a/package/motioneye/motioneye.mk b/package/motioneye/motioneye.mk index 6cf3a33e93..64cd7f3fd9 100644 --- a/package/motioneye/motioneye.mk +++ b/package/motioneye/motioneye.mk @@ -4,7 +4,7 @@ # ############################################################# -MOTIONEYE_VERSION = 2890653304c1e5dedd2d1c4b64cb92903d0a7fbc +MOTIONEYE_VERSION = f262d5d49e167aedb4a8354d484d70a821c7baa5 MOTIONEYE_SITE = $(call github,ccrisan,motioneye,$(MOTIONEYE_VERSION)) MOTIONEYE_SOURCE = $(MOTIONEYE_VERSION).tar.gz MOTIONEYE_LICENSE = GPLv3 diff --git a/package/motioneye/watchctl.py b/package/motioneye/watchctl.py index 85ec2da671..e7952dc096 100644 --- a/package/motioneye/watchctl.py +++ b/package/motioneye/watchctl.py @@ -172,15 +172,6 @@ def watchLinkTimeout(): } -@additional_config -def watchLinkSeparator(): - return { - 'type': 'separator', - 'section': 'expertSettings', - 'advanced': True - } - - @additional_config def watchConnect(): return {