海运的博客

贝尔光猫G-140W-UG优化CPU和内存

发布时间:April 23, 2023 // 分类: // No Comments

默认占用CPU和内存高,内存高因为java,通过/etc/scripts/osgi_admin.sh/osgi_start.sh启动,sysmon调用/etc/scripts/jwatchdog.sh 不停检测java是否退出,导致cpu占用高。
还有内核模块ORTP_TASK每2分左右占用单核心CPU 100%,通过/etc/init.d/rcS判断猫是否支持电话加载,修改此文件无效果,估计使用的/usr/etc/,通过rmmod /lib/modules/pcm1.ko减小到20%,如果rmmod不能用可以下载openwrt mips34kc软件包或编译使用。
也可下载完整版busybox使用:https://busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/

修改/etc/scripts/pcm_startup.sh文件让它开机后kill程序和rmmod模块,优化后CPU 0占用,ORTP_TASK每2分钟占用一次20%,解决这个估计要修改固件了。

一个小问题,使用go编译的sshd服务端非要在telnet终端内启动,不然在ssh连接终端使用ctrl+c不能终止程序,x86没问题。

/etc/pkill.sh &
exit

以下/etc/pkill.sh为脚本内容,也可添加到/etc/rc.d/S10pkill脚本,开机也能执行:

#!/bin/sh
sleep 60
/etc/rmmod /lib/modules/pcm1.ko   
pkill -9 sysmon #占用大幅降低
pkill -9 voip
pkill -9 evtmgr  

pkill -9 dropbear
pkill -9 dnsproxy
pkill -9 samba
pkill -9 homenas
pkill -9 storageSrv
pkill -9 securitySrv
pkill -9 batch_upgrade
pkill -9 xl2tpd
pkill -9 udhcpd
pkill -9 dhcp6s 
pkill -9 radvd

pkill -9 http_traffic_process
pkill -9 traffic_mirror
pkill -9 lanhostsd
pkill -9 wifihostd
pkill -9 arpwan
pkill -9 umonitor

pkill -9 tcwdog
pkill -9 spccu
pkill -9 nffd
pkill -9 appmgr
pkill -9 ramond
pkill -9 usrbh

#禁用pcm启动后以下未启动
#pkill -9 trafficsrv
#pkill -9 usbsrv
#pkill -9 syssrv
#pkill -9 wifisrv
#pkill -9 wansrv
#pkill -9 lansrv
#pkill -9 diagsrv
#pkill -9 pcmcu

#pkill -9 omciMgr #这个kill后pon断线后不重连
#上面全部关闭后下面才能关闭,不然重启
#pkill -9 msgmgr #这两个关闭后网页不能登录
#pkill -9 cfgmgr
#pkill -9 parse #这两个ocmimgr依赖
pkill -9 alarmd
/etc/rmmod /lib/modules/sys_mod.ko                                                  
/etc/rmmod /lib/modules/DSPCore.ko                                                                                                                                  
/etc/rmmod /lib/modules/pcm1.ko                                                     
/etc/rmmod /lib/modules/lec.ko                                                                 
/etc/rmmod /lib/modules/spi.ko                                                      
/etc/rmmod /lib/modules/slic3_sep.ko 
/etc/rmmod /lib/modules/fxs3.ko                                         
/etc/rmmod /lib/modules/ksocket.ko                                      
/etc/rmmod /lib/modules/ortp.ko                                         
/etc/rmmod /lib/modules/acodec_x.ko                                     
/etc/rmmod /lib/modules/foip.ko                                         
#/etc/rmmod /lib/modules/ovdsp.ko                                        
/etc/rmmod /lib/modules/pcmDump.ko     
/etc/rmmod /lib/modules/lantiq/drv_ifxos.ko                                        
/etc/rmmod /lib/modules/lantiq/drv_tapi.ko                                                                                                                          
/etc/rmmod /lib/modules/lantiq/drv_dxs.ko 

修改rootfs分区禁止加载voip相关模块ORTP_TASK后CPU依然每2分钟占用单核50%左右,通过top查看是软中断占用的CPU,查看软中断wifi_ratelimit占用CPU0明显超高:

cat /proc/softirqs 
                    CPU0       CPU1       
          HI:   24304711          0
       TIMER:    2495627    2495649
      NET_TX:      81335      77293
      NET_RX:      81699     182716
       BLOCK:          0          0
BLOCK_IOPOLL:          0          0
     TASKLET:         30          4
       SCHED:    2488517     155237
     HRTIMER:          0          0
         RCU:      21636    2500274
cat /proc/interrupts
           CPU0       CPU1       
  1:      72432          0      MIPS  TC3162 UART
  7:   24950419          0      MIPS  wifi_ratelimit
  8:      21236       4723      MIPS  IPI_resched
  9:        819       3594      MIPS  IPI_call
 10:          0          0      MIPS  watchdog
 18:          0          0      MIPS  xhci-hcd:usb1
 19:          0          0      MIPS  dying gasp
 22:     244212          0      MIPS  qdma_lan
 23:          0     250646      MIPS  qdma_wan
 24:        138          0      MIPS
 31:    2496872    2496886      MIPS  timer
 33:          0          0      MIPS  bus timeout
ERR:          0
qdmamgr_lan set rxratelimit config Disable packet
qdmamgr_wan set rxratelimit config Disable packet
/etc/rmmod /lib/modules/wlan_ratelimit

到此CPU占用完全恢复正常,基本保持在0占用。

使用sshd没有ctrl+c不能终止的问题了
https://github.com/darkerego/mips-binaries/tree/master/openssh

UsePrivilegeSeparation no
Port 22
PermitRootLogin yes
ChallengeResponseAuthentication no
Subsystem       sftp    /data/sftp-server

openwrt/immortalwrt编译内核模块并修改版本号

发布时间:April 21, 2023 // 分类: // No Comments

#编译工具链
make tools/install
make toolchain/install
#先进入菜单将要编译的模块选择为M
make menuconfig
make target/linux/{clean,compile}
make package/kernel/linux/{clean,compile}

使用现成工具链,省得编译浪费时间:

wget https://downloads.openwrt.org/releases/21.02.6/targets/mediatek/mt7622/openwrt-sdk-21.02.6-mediatek-mt7622_gcc-8.4.0_musl.Linux-x86_64.tar.xz
tar Jxf openwrt-sdk-21.02.6-mediatek-mt7622_gcc-8.4.0_musl.Linux-x86_64.tar.xz 
mv staging_dir staging_dir-back
mv openwrt-sdk-21.02.6-mediatek-mt7622_gcc-8.4.0_musl.Linux-x86_64/staging_dir ./

如mtkhnat模块和ipk位置:

build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/packages/ipkg-aarch64_cortex-a53/kmod-mediatek_hnat/lib/modules/5.4.238/mtkhnat.ko
bin/targets/mediatek/mt7981/packages/kmod-mediatek_hnat_5.4.238-1_aarch64_cortex-a53.ipk 

如果编译的最新模块小版本号与系统不一致可用sed修改,要确保模块无大更新,不然可能有兼容性问题。

sed -i 's/5\.4\.238/5\.4\.225/g' build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/packages/ipkg-aarch64_cortex-a53/kmod-mediatek_hnat/lib/modules/5.4.238/mtkhnat.ko

https://openwrt.org/docs/guide-developer/toolchain/single.package
https://forum.openwrt.org/t/how-to-build-an-additional-kernel-module/56575/2

联通贝尔光猫G-140W-UG修改为桥接/管理员密码并开启telnet

发布时间:April 20, 2023 // 分类: // 2 Comments

1.修改管理员密码,WEB修改普通用户密码用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POST参数中pswdNew替换成pswdNewSuper、pswdConfirm替换成pswdConfirmSuper。
2.设置拨号桥接:
internet.jpg
iptv配置:
iptv.jpg
备份下tr09参数,可以删除
tr09.jpg
3.访问 http://192.168.1.1/system.cgi?telnet 开启telnet。
如需修改SN和MAC:

ritool dump
ritool set YPSerialNum ALCLxxxxxxxx #SN码
ritool set MACAddress xx:xx:xx:xx #MAC地址 

这猫用来桥接够用了,跑满千m宽带不占用CPU资源,top查看sirq无占用,/proc/softirqs内NET_TX和NET_RX很小,说明走的是硬桥接。
但是IPTV走的是软桥接,流量也不大,CPU够用。
更新:IPTV协议封装选PPPOE是硬桥接。
https://wp.for-get.com/538.html
https://www.sohu.com/a/389057275_662688

linux/openwrt清空iptables连接跟踪状态表conntrack

发布时间:April 19, 2023 // 分类: // No Comments

最近在用iptables mark后做qos,当规则更新后要先清空下conntrack,不然之前已建立连接的mark并不改变,影响后续的判断。
使用conntrack工具:

conntrack -F

openwrt可使用以下方法:

echo f > /proc/net/nf_conntrack

openwrt如有开启hnat需先关闭再清除conntrack,不然无效,如mtk/360t7闭源驱动:

echo 0 > /sys/kernel/debug/hnat/qos_toggle
echo 0 > /sys/kernel/debug/hnat/hook_toggle

https://forum.openwrt.org/t/mwan3-how-to-flush-firewall-conntrack-table/133776

debian11或pve编译安装最新版qbittorrent-nox

发布时间:February 5, 2023 // 分类: // No Comments

安装编译环境:

apt install build-essential pkg-config automake libtool

编译libtorrent-rasterbar-1.2.18:

apt install libboost-system-dev libssl-dev
#也可使用git clone最新代码
#git clone --branch RC_1_2 --depth=1 --recurse-submodules https://github.com/arvidn/libtorrent.git
wget https://github.com/arvidn/libtorrent/releases/download/v1.2.18/libtorrent-rasterbar-1.2.18.tar.gz
tar zxf libtorrent-rasterbar-1.2.18.tar.gz 
cd libtorrent-rasterbar-1.2.18/  
./configure --prefix=/usr/local/libtorrent-1.2.18 CXXFLAGS=-std=c++14  
make -j$(nproc) && make install

编译qbittorrent-nox4.5.0:

apt install qtbase5-dev qttools5-dev libqt5svg5-dev zlib1g-dev
#也可使用git clone最新代码
#git clone --branch v4_5_x --depth=1 https://github.com/qbittorrent/qBittorrent.git
wget https://github.com/qbittorrent/qBittorrent/archive/refs/tags/release-4.5.0.tar.gz
tar zxf release-4.5.0.tar.gz 
cd qBittorrent-release-4.5.0/  
export CPLUS_INCLUDE_PATH=/usr/local/libtorrent-1.2.18/include/               
export PKG_CONFIG_PATH=/usr/local/libtorrent-1.2.18/lib/pkgconfig
./configure --prefix=/usr/local/qbittorrent-4.5.0 --disable-gui 
make -j$(nproc) && make install

qbittorrent 4.5.0版本web不能显示中文解决:

sed -i 's/value="zh">/value="zh_CN">/' src/webui/www/private/views/preferences.html

如只安装一个版本的libtorren启动qbittorrent:

echo '/usr/local/libtorrent/lib' > /etc/ld.so.conf.d/libtorrent-x86_64.conf 
ldconfig
/usr/local/qbittorrent-4.5.0/bin/qbittorrent-nox

多个版本libtorren:

LD_LIBRARY_PATH=/usr/local/libtorrent-1.2.18/lib/ /usr/local/qbittorrent-4.5.0/bin/qbittorrent-nox

systemd service添加:

Environment="LD_LIBRARY_PATH=/usr/local/libtorrent-1.2.18/lib/"

用cmake编译libtorrent-2.0版本及qbittorrent4.5.0:

apt install cmake ninja-build
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/libtorrent-2.0.8 -DCMAKE_CXX_STANDARD=14 
cmake --build build
cmake --install build
export CPLUS_INCLUDE_PATH=/usr/local/libtorrent-2.0.8/include/              
export PKG_CONFIG_PATH=/usr/local/libtorrent-2.0.8/lib/pkgconfig
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/qbittorrent-4.5.0-lt20 -DGUI=OFF -DSTACKTRACE=OFF 
cmake --build build
cmake --install build

debian11使用qt6编译qbittorrent,需开启bullseye-backports源:

apt install qt6-base-dev qt6-tools-dev zlib1g-dev -t bullseye-backports
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/qbittorrent-4.5.1 -DGUI=OFF -DSTACKTRACE=OFF -DQT6=ON

如要在其它机器上运行需安装依赖:

apt install libqt6network6 libqt6sql6 libqt6xml6 libqt6core6 -t bullseye-backports 

libtorrent-2.0.8使用注意,默认磁盘io类型为内存映射文件,qbittorrent占用shr内存很大,且关闭系统缓存后下载上传很慢。
将磁盘io更改为posix无此问题。

经典版本4.3.9:

#wget https://github.com/arvidn/libtorrent/releases/download/v1.2.14/libtorrent-rasterbar-1.2.14.tar.gz
#tar zxf libtorrent-rasterbar-1.2.14.tar.gz 
#cd libtorrent-rasterbar-1.2.14/
git clone --branch RC_1_2 https://github.com/arvidn/libtorrent.git
cd libtorrent
#qbittorrent4.39发布时使用的libtorrent版本
git checkout 28ebc276224021d93d958e2f2de445c35898a23e
git submodule update --init --recursive
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/libtorrent-1.2.14 -DCMAKE_CXX_STANDARD=14 
cmake --build build  
cmake --install build
git clone --branch v4_3_x --depth=1 https://github.com/qbittorrent/qBittorrent.git
cd qBittorrent/
export CPLUS_INCLUDE_PATH=/usr/local/libtorrent-1.2.14/include/  
export PKG_CONFIG_PATH=/usr/local/libtorrent-1.2.14/lib/pkgconfig
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/qbittorrent-4.3.9 -DGUI=OFF -DSTACKTRACE=OFF
cmake --build build  
cmake --install build

https://web.archive.org/web/20211102073721/https://www.qbittorrent.org/download.php
https://github.com/qbittorrent/qBittorrent/wiki#compilation
https://github.com/qbittorrent/qBittorrent/wiki/Compilation:-Debian-and-Ubuntu
https://github.com/qbittorrent/qBittorrent/wiki/Compilation-with-CMake:-common-information
https://github.com/arvidn/libtorrent/blob/RC_2_0/docs/building.rst#building-with-cmake

分类
最新文章
最近回复
  • 海运: 可能版本问题
  • 海运: 如果运营商限制型号
  • 海运: 没有
  • Mruru: 烽火猫切换rootfs的方法有么大佬?
  • nono: 修改光猫型号是做啥子用的
  • 960: root账号默认密码hg2x0 不对哇
  • rer: 感谢分享!~
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
归档