update-09.11

This commit is contained in:
github-actions[bot]
2021-09-11 08:28:29 +08:00
parent 63d0b84d5c
commit 2308d50344
6 changed files with 69 additions and 54 deletions

View File

@@ -4,14 +4,16 @@ PKG_NAME:=luci-app-jd-dailybonus
PKG_VERSION:=1.0.5 PKG_VERSION:=1.0.5
PKG_RELEASE:=20210316 PKG_RELEASE:=20210316
define Package/$(PKG_NAME)/conffiles PKG_MAINTAINER:=jerrykuku <jerrykuku@qq.com>
/etc/config/jd-dailybonus
endef
LUCI_TITLE:=Luci for JD dailybonus Script LUCI_TITLE:=Luci for JD dailybonus Script
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
LUCI_DEPENDS:=+node +uclient-fetch +lua +libuci-lua LUCI_DEPENDS:=+node +uclient-fetch +lua +libuci-lua
define Package/$(PKG_NAME)/conffiles
/etc/config/jd-dailybonus
endef
include $(TOPDIR)/feeds/luci/luci.mk include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature # call BuildPackage - OpenWrt buildroot signature

View File

@@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-pushbot PKG_NAME:=luci-app-pushbot
PKG_VERSION:=3.50 PKG_VERSION:=3.55
PKG_RELEASE:=2 PKG_RELEASE:=3
PKG_MAINTAINER:=tty228 zzsj0928 PKG_MAINTAINER:=tty228 zzsj0928

View File

@@ -28,6 +28,9 @@
- 故由 然后七年 @zzsj0928 重新修改为本插件为钉钉机器人API使用。 - 故由 然后七年 @zzsj0928 重新修改为本插件为钉钉机器人API使用。
- 本插件工作在openwrt - 本插件工作在openwrt
- 本插件支持:钉钉推送,企业微信推送,PushPlus推送,微信推送,企业微信应用推送,飞书推送,钉钉机器人推送,企业微信机器人推送,飞书机器人推送,一对多推送,Bark推送(仅iOS) - 本插件支持:钉钉推送,企业微信推送,PushPlus推送,微信推送,企业微信应用推送,飞书推送,钉钉机器人推送,企业微信机器人推送,飞书机器人推送,一对多推送,Bark推送(仅iOS)
- 自20210911之后的版本支持Bark群组群组名默认为设备名
- 自20210901之后的版本增加依赖jq请重新编译或在安装前同步安装jq
# 显示效果 # 显示效果
## 通知栏:直接显示推送主题,一目了然,按设备不同,分组显示 ## 通知栏:直接显示推送主题,一目了然,按设备不同,分组显示
<img src="https://raw.githubusercontent.com/zzsj0928/ReadmeContents/main/Serverchand/Msg.Notification.jpg" width="500"> <img src="https://raw.githubusercontent.com/zzsj0928/ReadmeContents/main/Serverchand/Msg.Notification.jpg" width="500">

View File

@@ -2,15 +2,15 @@
"_api": "这是Bark推送 post 模板信息 api 文件", "_api": "这是Bark推送 post 模板信息 api 文件",
"_api": "【Bark推送】", "_api": "【Bark推送】",
"url": "${bark_srv}/${bark_token}/${1}/${nowtime}${markdown_linefeed}${2}?isArchive=1", "url": "",
"data": "@${tempjsonpath}", "data": "@${tempjsonpath}",
"content_type": "Content-Type: application/json", "content_type": "",
"str_title_start": "【", "str_title_start": "【",
"str_title_end": "】", "str_title_end": "】",
"str_linefeed": "\\n", "str_linefeed": "%0D%0A%0D%0A",
"str_splitline": "\\n\\n", "str_splitline": "%0D%0A%0D%0A",
"str_space": " ", "str_space": "%20",
"str_tab": " ", "str_tab": "%20",
"table_tab": "", "table_tab": "",
"font_green": "", "font_green": "",
"font_red": "", "font_red": "",
@@ -18,9 +18,10 @@
"font_purple": "", "font_purple": "",
"font_end": "", "font_end": "",
"font_end2": "", "font_end2": "",
"percentsym": "", "percentsym": "25",
"boldstar": "", "boldstar": "",
"type": "type":
{ {
"bark_text": "\"${bark_srv}/${bark_token}/${1}/${nowtime}${str_linefeed}${2}?group=${device_name}\""
} }
} }

View File

@@ -19,7 +19,7 @@
"font_end": "</font>", "font_end": "</font>",
"font_end2": "", "font_end2": "",
"percentsym": "", "percentsym": "",
"boldstar": "**", "boldstar": "",
"type": "type":
{ {
"token": "\"${pp_token}\"", "token": "\"${pp_token}\"",

View File

@@ -34,7 +34,7 @@ function read_config(){
err_device_aliases=`echo "$err_device_aliases"|sed 's/ /\n/g'` 2>/dev/null err_device_aliases=`echo "$err_device_aliases"|sed 's/ /\n/g'` 2>/dev/null
client_usage_whitelist=`echo "$client_usage_whitelist"|sed 's/ /\n/g'` 2>/dev/null client_usage_whitelist=`echo "$client_usage_whitelist"|sed 's/ /\n/g'` 2>/dev/null
ip_white_list=`echo "$ip_white_list"|sed 's/ /\n/g'` 2>/dev/null ip_white_list=`echo "$ip_white_list"|sed 's/ /\n/g'` 2>/dev/null
mark_mac_list="${MAC_online_list}${MAC_offline_list}" mark_mac_list="${MAC_online_list} ${MAC_offline_list}"
mark_mac_list=`echo "$mark_mac_list"|sed 's/ /\n/g'|sed 's/-/ /'` 2>/dev/null mark_mac_list=`echo "$mark_mac_list"|sed 's/ /\n/g'|sed 's/-/ /'` 2>/dev/null
ipv4_urllist=`cat /usr/bin/pushbot/api/ipv4.list` 2>/dev/null ipv4_urllist=`cat /usr/bin/pushbot/api/ipv4.list` 2>/dev/null
ipv6_urllist=`cat /usr/bin/pushbot/api/ipv6.list` 2>/dev/null ipv6_urllist=`cat /usr/bin/pushbot/api/ipv6.list` 2>/dev/null
@@ -44,9 +44,9 @@ function read_config(){
[ -z "$up_timeout" ] || [ "$up_timeout" -eq "0" ] && up_timeout="2" [ -z "$up_timeout" ] || [ "$up_timeout" -eq "0" ] && up_timeout="2"
[ -z "$down_timeout" ] || [ "$down_timeout" -eq "0" ] && down_timeout="20";down_timeout=`expr ${down_timeout} / 2 + 1` [ -z "$down_timeout" ] || [ "$down_timeout" -eq "0" ] && down_timeout="20";down_timeout=`expr ${down_timeout} / 2 + 1`
[ -z "$timeout_retry_count" ] && timeout_retry_count="2";[ "$timeout_retry_count" -eq "0" ] && timeout_retry_count="1" [ -z "$timeout_retry_count" ] && timeout_retry_count="2";[ "$timeout_retry_count" -eq "0" ] && timeout_retry_count="1"
[ -z "$bark_srv" ] && bark_srv="https://api.day.app" [ ! -z "$bark_token" ] && [ -z "$bark_srv" ] && bark_srv="https://api.day.app"
# String Map # 字符串读取
str_title_start=`/usr/bin/jq -r '.str_title_start' ${jsonpath}` str_title_start=`/usr/bin/jq -r '.str_title_start' ${jsonpath}`
str_title_end=`/usr/bin/jq -r '.str_title_end' ${jsonpath}` str_title_end=`/usr/bin/jq -r '.str_title_end' ${jsonpath}`
str_linefeed=`/usr/bin/jq -r '.str_linefeed' ${jsonpath}` str_linefeed=`/usr/bin/jq -r '.str_linefeed' ${jsonpath}`
@@ -77,6 +77,9 @@ function pushbot_init(){
fi fi
down_oui & down_oui &
deltemp deltemp
get_syslog
add_ip_black
rm -f ${dir}fd1 ${dir}sheep_usage ${dir}old_sheep_usage ${dir}client_usage_aliases ${dir}old_client_usage_aliases /usr/bin/pushbot/errlog >/dev/null 2>&1 rm -f ${dir}fd1 ${dir}sheep_usage ${dir}old_sheep_usage ${dir}client_usage_aliases ${dir}old_client_usage_aliases /usr/bin/pushbot/errlog >/dev/null 2>&1
[ ! -f "/usr/sbin/wrtbwmon" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】未安装 wrtbwmon ,流量统计不可用" >> ${logfile} [ ! -f "/usr/sbin/wrtbwmon" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】未安装 wrtbwmon ,流量统计不可用" >> ${logfile}
[ -z "$ip_version" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法获取依赖项 iputils-arping 版本号,请确认插件是否正常运行" >> ${logfile} [ -z "$ip_version" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法获取依赖项 iputils-arping 版本号,请确认插件是否正常运行" >> ${logfile}
@@ -99,7 +102,11 @@ function diy_send(){
[ $logrow -eq "0" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【】json 文件生成失败,请检查文件格式" >> ${logfile} && return 1 [ $logrow -eq "0" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 【】json 文件生成失败,请检查文件格式" >> ${logfile} && return 1
/usr/bin/jq -r '.[]' ${tempjsonpath}|grep "null" && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】参数变量生成失败,请检查设置项 `/usr/bin/jq -r '.' ${tempjsonpath}|grep "null"`" >> ${logfile} /usr/bin/jq -r '.[]' ${tempjsonpath}|grep "null" && echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】参数变量生成失败,请检查设置项 `/usr/bin/jq -r '.' ${tempjsonpath}|grep "null"`" >> ${logfile}
curl -X POST -H "$content_type" -d "${data}" "${diyurl}" if [ ! -z "$bark_token" ]; then
local bark_text=`/usr/bin/jq -r '.bark_text' ${tempjsonpath}` && local bark_text=`echo $bark_text|sed 's/ /%20/g'` && curl -s $bark_text
else
curl -X POST -H "$content_type" -d "${data}" "${diyurl}"
fi
} }
# 下载设备MAC厂商信息 # 下载设备MAC厂商信息
@@ -325,13 +332,13 @@ function get_client_usage(){
local time1=$(time_for_humans `expr ${time1} - ${time_up}`) local time1=$(time_for_humans `expr ${time1} - ${time_up}`)
if [ -z "$title" ]; then if [ -z "$title" ]; then
title="${ip_name} 流量异常" title="${ip_name} 流量异常"
content="${content}${str_splitline}${str_title_start}${font_red}设备流量异常${font_end}${str_title_end}${str_linefeed}${str_tab}客户端名:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_name}${str_linefeed}${str_tab}客户端IP ${str_space}${str_space}${str_space}${str_space}${ip}${str_linefeed}${str_tab}客户端MAC${str_space}${str_space}${str_space}${str_space}${mac}$ip_total${str_linefeed}${str_tab}一分钟内流量: ${str_space}${str_space}${tmp_usage}${str_linefeed}${str_tab}在线时间: ${str_space}${str_space}${str_space}${str_space}${time1}" content="${content}${str_splitline}${str_title_start}${font_red} 设备流量异常${font_end}${str_title_end}${str_linefeed}${str_tab}客户端名:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_name}${str_linefeed}${str_tab}客户端IP ${str_space}${str_space}${str_space}${str_space}${ip}${str_linefeed}${str_tab}客户端MAC${str_space}${str_space}${str_space}${str_space}${mac}$ip_total${str_linefeed}${str_tab}一分钟内流量: ${str_space}${str_space}${tmp_usage}${str_linefeed}${str_tab}在线时间: ${str_space}${str_space}${str_space}${str_space}${time1}"
elif ( echo "$title"|grep -q "流量异常" ); then elif ( echo "$title"|grep -q "流量异常" ); then
title="${ip_name}${title}" title="${ip_name} ${title}"
content="${content}${str_splitline}${str_tab}客户端名:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_name}${str_linefeed}${str_tab}客户端IP ${str_space}${str_space}${str_space}${str_space}${ip}${str_linefeed}${str_tab}客户端MAC${str_space}${str_space}${str_space}${str_space}${mac}$ip_total${str_linefeed}${str_tab}一分钟内流量: ${str_space}${str_space}${str_space}${tmp_usage}${str_linefeed}${str_tab}在线时间: ${str_space}${str_space}${str_space}${str_space}${time1}" content="${content}${str_splitline}${str_tab}客户端名:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_name}${str_linefeed}${str_tab}客户端IP ${str_space}${str_space}${str_space}${str_space}${ip}${str_linefeed}${str_tab}客户端MAC${str_space}${str_space}${str_space}${str_space}${mac}$ip_total${str_linefeed}${str_tab}一分钟内流量: ${str_space}${str_space}${str_space}${tmp_usage}${str_linefeed}${str_tab}在线时间: ${str_space}${str_space}${str_space}${str_space}${time1}"
else else
title="设备状态变化" title="设备状态变化"
content="${content}${str_splitline}${str_title_start}${font_red}设备流量异常${font_end}${str_title_end}${str_linefeed}${str_tab}客户端名:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_name}${str_linefeed}${str_tab}客户端IP ${str_space}${str_space}${str_space}${str_space}${ip}${str_linefeed}${str_tab}客户端MAC${str_space}${str_space}${str_space}${str_space}${mac}$ip_total${str_linefeed}${str_tab}一分钟内流量: ${str_space}${str_space}${str_space}${tmp_usage}${str_linefeed}${str_tab}在线时间: ${str_space}${str_space}${str_space}${str_space}${time1}" content="${content}${str_splitline}${str_title_start}${font_red} 设备流量异常${font_end}${str_title_end}${str_linefeed}${str_tab}客户端名:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_name}${str_linefeed}${str_tab}客户端IP ${str_space}${str_space}${str_space}${str_space}${ip}${str_linefeed}${str_tab}客户端MAC${str_space}${str_space}${str_space}${str_space}${mac}$ip_total${str_linefeed}${str_tab}一分钟内流量: ${str_space}${str_space}${str_space}${tmp_usage}${str_linefeed}${str_tab}在线时间: ${str_space}${str_space}${str_space}${str_space}${time1}"
fi fi
fi fi
done done
@@ -483,7 +490,7 @@ function LockFile(){
LockFile lock LockFile lock
fi fi
[ $1 = "unlock" ] && rm -f ${dir}pushbot.lock >/dev/null 2>&1 [ $1 = "unlock" ] && rm -f ${dir}pushbot.lock >/dev/null 2>&1
return return 0
} }
# 检测黑白名单 # 检测黑白名单
@@ -709,7 +716,7 @@ function ip_changes(){
echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text}当前IP${IPv4}" >> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text}当前IP${IPv4}" >> ${logfile}
echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $last_IPv6 >> ${dir}ip echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $last_IPv6 >> ${dir}ip
title="IP 地址变化" title="IP 地址变化"
content="${content}${str_splitline}${str_title_start}${font_green}IP 地址变化${font_end}${str_title_end}${str_linefeed}${str_tab}当前 IP${IPv4}" content="${content}${str_splitline}${str_title_start}${font_green} IP 地址变化${font_end}${str_title_end}${str_linefeed}${str_tab}当前 IP${IPv4}"
elif [ ! -z "$pushbot_ipv4" ] && [ "$pushbot_ipv4" -ne "0" ] && [ -z "$IPv4" ]; then elif [ ! -z "$pushbot_ipv4" ] && [ "$pushbot_ipv4" -ne "0" ] && [ -z "$IPv4" ]; then
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】获取 IPv4 地址失败" >> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】获取 IPv4 地址失败" >> ${logfile}
fi fi
@@ -719,7 +726,7 @@ function ip_changes(){
echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $IPv6 >> ${dir}ip echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $IPv6 >> ${dir}ip
[ -z "$title" ] && title="IPv6 地址变化" [ -z "$title" ] && title="IPv6 地址变化"
[ ! -z "$title" ] && title="IP 地址变化" [ ! -z "$title" ] && title="IP 地址变化"
content="${content}${str_splitline}${str_title_start}${font_green}IPv6 地址变化${font_end}${str_title_end}${str_linefeed}${str_tab}当前 IPv6${IPv6}" content="${content}${str_splitline}${str_title_start}${font_green} IPv6 地址变化${font_end}${str_title_end}${str_linefeed}${str_tab}当前 IPv6${IPv6}"
elif [ ! -z "$pushbot_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ] && [ -z "$IPv6" ]; then elif [ ! -z "$pushbot_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ] && [ -z "$IPv6" ]; then
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】获取 IPv6 地址失败" >> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】获取 IPv6 地址失败" >> ${logfile}
fi fi
@@ -730,7 +737,7 @@ function ip_changes(){
[ ! -z "$pushbot_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 当前IPv6: ${IPv6}" >> ${logfile} [ ! -z "$pushbot_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ] && echo "`date "+%Y-%m-%d %H:%M:%S"` 当前IPv6: ${IPv6}" >> ${logfile}
echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $IPv6 >> ${dir}ip echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $IPv6 >> ${dir}ip
title="路由器重新启动" title="路由器重新启动"
content="${content}${str_splitline}${str_title_start}${font_green}路由器重新启动${font_end}${str_title_end}" content="${content}${str_splitline}${str_title_start}${font_green} 路由器重新启动${font_end}${str_title_end}"
[ ! -z "$pushbot_ipv4" ] && [ "$pushbot_ipv4" -ne "0" ] && content="${content}${str_linefeed}${str_tab}当前IP${IPv4}" [ ! -z "$pushbot_ipv4" ] && [ "$pushbot_ipv4" -ne "0" ] && content="${content}${str_linefeed}${str_tab}当前IP${IPv4}"
[ ! -z "$pushbot_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ] && content="${content}${str_linefeed}${str_tab}当前IPv6${IPv6}" [ ! -z "$pushbot_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ] && content="${content}${str_linefeed}${str_tab}当前IPv6${IPv6}"
fi fi
@@ -752,6 +759,7 @@ function ip_changes(){
function up(){ function up(){
[ -f ${dir}ipAddress ] && ( cat ${dir}ipAddress|grep -q -w $1 ) && return [ -f ${dir}ipAddress ] && ( cat ${dir}ipAddress|grep -q -w $1 ) && return
local ip_mac=`getmac $1` local ip_mac=`getmac $1`
local ip_name=`getname ${1} ${ip_mac}`
local ip_interface=`getinterface ${ip_mac}` local ip_interface=`getinterface ${ip_mac}`
getping ${1} ${up_timeout} "1";local ping_online=$? getping ${1} ${up_timeout} "1";local ping_online=$?
if [ "$ping_online" -eq "0" ]; then if [ "$ping_online" -eq "0" ]; then
@@ -791,7 +799,7 @@ function up(){
local title="设备状态变化" local title="设备状态变化"
local content="${str_splitline}${str_title_start}${font_green} 新设备连接${font_end}${str_title_end}${str_linefeed}${str_tab}客户端名:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_name}${str_linefeed}${str_tab}客户端IP ${str_space}${str_space}${str_space}${str_space}${1}${str_linefeed}${str_tab}客户端MAC${str_space}${str_space}${str_space}${str_space}${ip_mac}${str_linefeed}${str_tab}网络接口:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_interface}" local content="${str_splitline}${str_title_start}${font_green} 新设备连接${font_end}${str_title_end}${str_linefeed}${str_tab}客户端名:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_name}${str_linefeed}${str_tab}客户端IP ${str_space}${str_space}${str_space}${str_space}${1}${str_linefeed}${str_tab}客户端MAC${str_space}${str_space}${str_space}${str_space}${ip_mac}${str_linefeed}${str_tab}网络接口:${str_space}${str_space}${str_space}${str_space}${str_space}${ip_interface}"
fi fi
echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text}新设备 ${ip_name}${1} 连接了">> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text}新设备 ${ip_name} ${1} 连接了">> ${logfile}
#[ ! -z "$pushbot_blacklist" ] && local title="你偷偷关注的设备上线了" #[ ! -z "$pushbot_blacklist" ] && local title="你偷偷关注的设备上线了"
[ ! -z "$title" ] && echo "$title" >${dir}title [ ! -z "$title" ] && echo "$title" >${dir}title
[ ! -z "$content" ] && echo -n "$content" >>${dir}content [ ! -z "$content" ] && echo -n "$content" >>${dir}content
@@ -858,9 +866,10 @@ function down_send(){
# 当前设备列表 # 当前设备列表
function current_device(){ function current_device(){
( echo "$lite_enable"|grep -q "content" ) || ( echo "$lite_enable"|grep -q "device" ) && return
[ -f ${dir}ipAddress ] && local logrow=$(grep -c "" ${dir}ipAddress) || local logrow="0";[ $logrow -eq "0" ] && return [ -f ${dir}ipAddress ] && local logrow=$(grep -c "" ${dir}ipAddress) || local logrow="0";[ $logrow -eq "0" ] && return
[ -f ${dir}usage.db ] && local ip_total_db="总计流量${str_space}${str_space}${str_space}${str_space}" [ -f ${dir}usage.db ] && local ip_total_db="总计流量${str_space}${str_space}${str_space}${str_space}"
content="${content}${str_splitline}${str_title_start}${font_blue}现有在线设备 ${logrow} 台,具体如下${font_end}${str_title_end}${str_linefeed}${str_tab}IP 地址${str_space}${str_space}${str_space}${str_space}${str_space}${str_space}${str_space}${str_space}${str_space}${ip_total_db}${boldstar}客户端名${boldstar}" content="${content}${str_splitline}${str_title_start}${font_blue} 现有在线设备 ${logrow} 台,具体如下${font_end}${str_title_end}${str_linefeed}${str_tab}IP 地址${str_space}${str_space}${str_space}${str_space}${str_space}${str_space}${str_space}${str_space}${str_space}${ip_total_db}${boldstar}客户端名${boldstar}"
local IPLIST=`cat ${dir}ipAddress|awk '{print $1}'` local IPLIST=`cat ${dir}ipAddress|awk '{print $1}'`
for ip in $IPLIST; do for ip in $IPLIST; do
local ip_mac=`getmac ${ip}` local ip_mac=`getmac ${ip}`
@@ -880,7 +889,7 @@ function current_device(){
local ip_total="${ip_total}${str_space}" local ip_total="${ip_total}${str_space}"
done done
fi fi
content="${content}${str_linefeed}${str_tab}${ip}${ip_total}${boldstar}${font_green}${ip_name}${font_end}${boldstar}" content="${content}${str_linefeed}${str_tab}${ip}${ip_total}${boldstar}${font_green}${ip_name}${font_end2}${boldstar}"
unset i n ip_total ip_mac ip_name unset i n ip_total ip_mac ip_name
done done
} }
@@ -902,7 +911,7 @@ function cpu_load(){
title="CPU 温度过高!" title="CPU 温度过高!"
temperaturecd_time=`date +%s` temperaturecd_time=`date +%s`
echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text} CPU 温度过高: ${cpu_wendu}" >> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text} CPU 温度过高: ${cpu_wendu}" >> ${logfile}
content="${content}${str_splitline}${str_title_start}${font_red}CPU 温度过高${font_end}${str_title_end}${str_linefeed}${str_tab}CPU 温度已连续五分钟超过预设${str_linefeed}${str_tab}接下来一小时不再提示${str_linefeed}${str_tab}当前温度:${cpu_wendu}℃" content="${content}${str_splitline}${str_title_start}${font_red} CPU 温度过高${font_end}${str_title_end}${str_linefeed}${str_tab}CPU 温度已连续五分钟超过预设${str_linefeed}${str_tab}接下来一小时不再提示${str_linefeed}${str_tab}当前温度:${cpu_wendu}℃"
elif [ ! -z "$temperaturecd_time" ] && [ "$((`date +%s`-$temperaturecd_time))" -ge "3300" ] ;then elif [ ! -z "$temperaturecd_time" ] && [ "$((`date +%s`-$temperaturecd_time))" -ge "3300" ] ;then
unset temperaturecd_time unset temperaturecd_time
fi fi
@@ -965,7 +974,7 @@ EOF
rm -f ${dir}get_syslog >/dev/null 2>&1 rm -f ${dir}get_syslog >/dev/null 2>&1
} }
# 登提醒通知 # 登提醒通知
function login_send(){ function login_send(){
[ -z "$web_logged" ] && [ -z "$ssh_logged" ] && [ -z "$web_login_failed" ] && [ -z "$ssh_login_failed" ] && return [ -z "$web_logged" ] && [ -z "$ssh_logged" ] && [ -z "$web_login_failed" ] && [ -z "$ssh_login_failed" ] && return
[ ! -f ${dir}login_monitor ] && return [ ! -f ${dir}login_monitor ] && return
@@ -984,17 +993,17 @@ function login_send(){
local web_login_mode=`cat ${dir}web_login|grep -w ${login_ip}|awk '{print $3}'|grep -v "^$"|sort -u|head -n1` local web_login_mode=`cat ${dir}web_login|grep -w ${login_ip}|awk '{print $3}'|grep -v "^$"|sort -u|head -n1`
if [ ! -z "$web_logged" ] && [ "$web_logged" -eq "1" ]; then if [ ! -z "$web_logged" ] && [ "$web_logged" -eq "1" ]; then
if [ -z "$title" ]; then if [ -z "$title" ]; then
title="${login_ip} 通过 web 登了路由器" title="${login_ip} 通过 Web 登了路由器"
content="${content}${str_splitline}${str_title_start} 登信息${str_title_end}${str_linefeed}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${web_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}" content="${content}${str_splitline}${str_title_start}${font_green}信息${font_end}${str_title_end}${str_linefeed}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${web_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}"
elif ( echo "$title"|grep -q "登了路由器" ); then elif ( echo "$title"|grep -q "登了路由器" ); then
title="${login_ip} ${title}" title="${login_ip} ${title}"
content="${content}${str_splitline}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${web_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}" content="${content}${str_splitline}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${web_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}"
else else
title="设备状态变化" title="设备状态变化"
content="${content}${str_splitline}${str_title_start} 登信息${str_title_end}${str_linefeed}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${web_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}" content="${content}${str_splitline}${str_title_start}${font_green}信息${font_end}${str_title_end}${str_linefeed}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${web_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}"
fi fi
fi fi
echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text}设备 ${login_ip} 通过 web ${web_login_mode} 登了路由器 " >> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` ${disturb_text}设备 ${login_ip} 通过 web ${web_login_mode} 登了路由器 " >> ${logfile}
done done
echo "" > ${dir}web_login echo "" > ${dir}web_login
unset login_ip login_ip_list unset login_ip login_ip_list
@@ -1008,17 +1017,17 @@ function login_send(){
[ ! -z "$ssh_login_mode" ] && local content_mode="${str_linefeed}${str_tab}登录方式: ${str_space}${str_space}${str_space}${str_space}${ssh_login_mode}" [ ! -z "$ssh_login_mode" ] && local content_mode="${str_linefeed}${str_tab}登录方式: ${str_space}${str_space}${str_space}${str_space}${ssh_login_mode}"
if [ ! -z "$ssh_logged" ] && [ "$ssh_logged" -eq "1" ]; then if [ ! -z "$ssh_logged" ] && [ "$ssh_logged" -eq "1" ]; then
if [ -z "$title" ]; then if [ -z "$title" ]; then
title="${login_ip} 通过 ssh了路由器" title="${login_ip} 通过 SSH了路由器"
content="${content}${str_splitline}${str_title_start} 登信息${str_title_end}${str_linefeed}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${ssh_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}" content="${content}${str_splitline}${str_title_start}${font_green}信息${font_end}${str_title_end}${str_linefeed}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${ssh_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}"
elif ( echo "$title"|grep -q "登了路由器" ); then elif ( echo "$title"|grep -q "登了路由器" ); then
title="${login_ip} ${title}" title="${login_ip} ${title}"
content="${content}${str_splitline}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${ssh_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}" content="${content}${str_splitline}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${ssh_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}"
else else
title="设备状态变化" title="设备状态变化"
content="${content}${str_splitline}${str_title_start} 登信息${str_title_end}${str_linefeed}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${ssh_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}" content="${content}${str_splitline}${str_title_start}${font_green}信息${str_title_end}${str_linefeed}${str_tab}时间:${str_space}${str_space}${str_space}${str_space}${str_space}${ssh_login_time}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}${content_mode}"
fi fi
fi fi
echo "`date "+%Y-%m-%d %H:%M:%S"` 【info】设备 ${login_ip} 通过 ssh ${ssh_login_mode} 登了路由器 " >> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` 【info】设备 ${login_ip} 通过 SSH ${ssh_login_mode} 登了路由器 " >> ${logfile}
done done
echo "" > ${dir}ssh_login echo "" > ${dir}ssh_login
unset login_ip login_ip_list unset login_ip login_ip_list
@@ -1031,18 +1040,18 @@ function login_send(){
if [ "$web_login_sum" -ge "$login_max_num" ] ;then if [ "$web_login_sum" -ge "$login_max_num" ] ;then
if [ ! -z "$web_login_failed" ] && [ "$web_login_failed" -eq "1" ]; then if [ ! -z "$web_login_failed" ] && [ "$web_login_failed" -eq "1" ]; then
if [ -z "$title" ]; then if [ -z "$title" ]; then
title="${login_ip} 通过 web 频繁尝试登" title="${login_ip} 通过 Web 频繁尝试登"
content="${content}${str_splitline}${str_title_start} 登信息${str_title_end}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}" content="${content}${str_splitline}${str_title_start}${font_red}信息${font_end}${str_title_end}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}"
elif ( echo "$title"|grep -q "频繁尝试登" ); then elif ( echo "$title"|grep -q "频繁尝试登" ); then
title="${login_ip} ${title}" title="${login_ip} ${title}"
content="${content}${str_splitline}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}" content="${content}${str_splitline}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}"
else else
title="设备状态变化" title="设备状态变化"
content="${content}${str_splitline}${str_title_start} 登信息${str_title_end}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}" content="${content}${str_splitline}${str_title_start}${font_red}信息${font_end}${str_title_end}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}"
fi fi
fi fi
sed -i "/^${login_ip}$/d" ${dir}web_failed sed -i "/^${login_ip}$/d" ${dir}web_failed
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】设备 ${login_ip} 通过 web 频繁尝试登" >> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】设备 ${login_ip} 通过 Web 频繁尝试登" >> ${logfile}
add_ip_black $login_ip add_ip_black $login_ip
fi fi
done done
@@ -1056,18 +1065,18 @@ function login_send(){
if [ "$ssh_login_sum" -ge "$login_max_num" ] ;then if [ "$ssh_login_sum" -ge "$login_max_num" ] ;then
if [ ! -z "$ssh_login_failed" ] && [ "$ssh_login_failed" -eq "1" ]; then if [ ! -z "$ssh_login_failed" ] && [ "$ssh_login_failed" -eq "1" ]; then
if [ -z "$title" ]; then if [ -z "$title" ]; then
title="${login_ip} 通过 ssh 频繁尝试登" title="${login_ip} 通过 SSH 频繁尝试登"
content="${content}${str_splitline}${str_title_start} 登信息${str_title_end}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}" content="${content}${str_splitline}${str_title_start}${font_red}信息${font_end}${str_title_end}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}"
elif ( echo "$title"|grep -q "频繁尝试登" ); then elif ( echo "$title"|grep -q "频繁尝试登" ); then
title="${login_ip} ${title}" title="${login_ip} ${title}"
content="${content}${str_splitline}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}" content="${content}${str_splitline}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}"
else else
title="设备状态变化" title="设备状态变化"
content="${content}${str_splitline}${str_title_start} 登信息${str_title_end}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}" content="${content}${str_splitline}${str_title_start}${font_red}信息${font_end}${str_title_end}${str_linefeed}${str_tab}设备 IP ${str_space}${str_space}${str_space}${str_space}${login_ip}"
fi fi
fi fi
sed -i "/^${login_ip}$/d" ${dir}ssh_failed sed -i "/^${login_ip}$/d" ${dir}ssh_failed
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】设备 ${login_ip} 通过 ssh 频繁尝试登" >> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】设备 ${login_ip} 通过 SSH 频繁尝试登" >> ${logfile}
add_ip_black $login_ip add_ip_black $login_ip
fi fi
done done
@@ -1102,7 +1111,7 @@ function add_ip_black(){
function send(){ function send(){
echo "`date "+%Y-%m-%d %H:%M:%S"` 【定时数据】创建定时任务" >> ${logfile} echo "`date "+%Y-%m-%d %H:%M:%S"` 【定时数据】创建定时任务" >> ${logfile}
pushbot_disturb;local send_disturb=$? pushbot_disturb;local send_disturb=$?
get_config "send_title" "router_status" "client_list" "router_temp" "router_wan" get_config "send_title" "router_status" "router_temp" "router_wan" "client_list"
[ -z "$send_title" ] && local send_title="路由状态:" [ -z "$send_title" ] && local send_title="路由状态:"
[ ! -z "$1" ] && local send_title="发送测试:" && local send_content="${str_splitline}${str_title_start}内容1${str_title_end}${str_linefeed}${str_tab}设备1${str_linefeed}${str_tab}设备2${str_splitline}${str_title_start}内容2${str_title_end}${str_linefeed}${str_tab}设备3${str_linefeed}${str_tab}设备4" [ ! -z "$1" ] && local send_title="发送测试:" && local send_content="${str_splitline}${str_title_start}内容1${str_title_end}${str_linefeed}${str_tab}设备1${str_linefeed}${str_tab}设备2${str_splitline}${str_title_start}内容2${str_title_end}${str_linefeed}${str_tab}设备3${str_linefeed}${str_tab}设备4"
@@ -1113,7 +1122,7 @@ function send(){
local cpuload=`getcpu` local cpuload=`getcpu`
local ramload=`free -m|sed -n '2p'|awk '{printf "%.2f%%\n",($3/$2)*100}'` local ramload=`free -m|sed -n '2p'|awk '{printf "%.2f%%\n",($3/$2)*100}'`
local systemstatustime=`cat /proc/uptime|awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("运行时间:%d天%d时%d分%d秒",run_days,run_hour,run_minute,run_second)}'`;unset run_days run_hour run_minute run_second local systemstatustime=`cat /proc/uptime|awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("运行时间:%d天%d时%d分%d秒",run_days,run_hour,run_minute,run_second)}'`;unset run_days run_hour run_minute run_second
local send_content="${send_content}${str_splitline}${str_title_start}${font_blue}系统运行状态${font_end}${str_title_end}" local send_content="${send_content}${str_splitline}${str_title_start}${font_blue} 系统运行状态${font_end}${str_title_end}"
local send_content="${send_content}${str_linefeed}${str_tab}平均负载:${systemload}" local send_content="${send_content}${str_linefeed}${str_tab}平均负载:${systemload}"
local send_content="${send_content}${str_linefeed}${str_tab}CPU占用${cpuload}${percentsym}" local send_content="${send_content}${str_linefeed}${str_tab}CPU占用${cpuload}${percentsym}"
local send_content="${send_content}${str_linefeed}${str_tab}内存占用:${ramload}${percentsym}" local send_content="${send_content}${str_linefeed}${str_tab}内存占用:${ramload}${percentsym}"
@@ -1128,7 +1137,7 @@ function send(){
if [ -z "$1" ] && [ ! -z "$router_wan" ] && [ "$router_wan" -eq "1" ]; then if [ -z "$1" ] && [ ! -z "$router_wan" ] && [ "$router_wan" -eq "1" ]; then
local send_wanIP=`getip wanipv4`;local send_hostIP=`getip hostipv4` local send_wanIP=`getip wanipv4`;local send_hostIP=`getip hostipv4`
local send_content="${send_content}${str_splitline}${str_title_start}${font_blue}WAN 口信息${font_end}${str_title_end}${str_linefeed}${str_tab}接口ip:${send_wanIP}" local send_content="${send_content}${str_splitline}${str_title_start}${font_blue} WAN 口信息${font_end}${str_title_end}${str_linefeed}${str_tab}接口ip:${send_wanIP}"
local send_content="${send_content}${str_linefeed}${str_tab}外网ip:${send_hostIP}" local send_content="${send_content}${str_linefeed}${str_tab}外网ip:${send_hostIP}"
if [ ! -z "$pushbot_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ]; then if [ ! -z "$pushbot_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ]; then
local send_wanIPv6=`getip wanipv6`;local send_hostIPv6=`getip hostipv6` local send_wanIPv6=`getip wanipv6`;local send_hostIPv6=`getip hostipv6`
@@ -1240,10 +1249,10 @@ while [ "$pushbot_enable" -eq "1" ]; do
# 异常流量检测 # 异常流量检测
[ ! -f "${dir}send_enable.lock" ] && get_client_usage [ ! -f "${dir}send_enable.lock" ] && get_client_usage
# 登提醒通知 # 登提醒通知
[ ! -f "${dir}send_enable.lock" ] && login_send [ ! -f "${dir}send_enable.lock" ] && login_send
# Noti # 通知
if [ ! -f "${dir}send_enable.lock" ] && [ ! -z "$title" ] && [ ! -z "$content" ]; then if [ ! -f "${dir}send_enable.lock" ] && [ ! -z "$title" ] && [ ! -z "$content" ]; then
[ ! -z "$device_name" ] && title="【$device_name】$title" [ ! -z "$device_name" ] && title="【$device_name】$title"
( echo "$lite_enable"|grep -q "content" ) && content="$title" ( echo "$lite_enable"|grep -q "content" ) && content="$title"