Bash/Shell查询光猫运行状态(光纤光衰,运行温度等...)

#!/bin/bash
#查询光猫状态:光纤光衰值等...
#匹配型号:友华 PT926G

modemType="友华 PT926G"


trap "rm -f $cookieFile" 0

curl -s 'http://192.168.1.1:8080/boaform/admin/formLogin' \
  -H 'Connection: keep-alive' \
  -H 'Pragma: no-cache' \
  -H 'Cache-Control: no-cache' \
  -H 'Origin: http://192.168.1.1:8080' \
  -H 'Upgrade-Insecure-Requests: 1' \
  -H 'DNT: 1' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36' \
  -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
  -H 'Referer: http://192.168.1.1:8080/admin/login.asp' \
  -H 'Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6,zh-TW;q=0.5' \
  --data-raw 'csrfmiddlewaretoken=KbyUmhTLMpYj7CD2di7JKP1P3qmLlkPt&csrfmiddlewaretoken=KbyUmhTLMpYj7CD2di7JKP1P3qmLlkPt&username=telecomadmin&psd=xxxxxxzE3MTU1MzQ%3D&postSecurityFlag=37558&csrftoken=b5c8cda4e0a34ce43ec6abae32d443ee' \
  >/dev/null


curlInfo=$(curl -sS http://192.168.1.1:8080/status_gpon.asp|iconv -f GBK -t UTF-8|grep -A 22 '<b>光模块信息</b>')

echo "$modemType 当前光猫信息如下:"
echo "$curlInfo"|sed -r 's/<[^>]+>//g;s/\s//g;/^\s*$/d'|awk '{printf $0;if(NR%2!=0){printf "\n";}else{printf ":"}}'

posted @ 2021-07-10 20:24  晴云孤魂  阅读(1180)  评论(0编辑  收藏  举报