From 2308d503447de36779b1cb78f161b5f72ca0785a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 11 Sep 2021 08:28:29 +0800 Subject: [PATCH] update-09.11 --- luci-app-jd-dailybonus/Makefile | 8 +- luci-app-pushbot/Makefile | 4 +- luci-app-pushbot/README.md | 3 + .../root/usr/bin/pushbot/api/bark.json | 15 +-- .../root/usr/bin/pushbot/api/pushplus.json | 2 +- luci-app-pushbot/root/usr/bin/pushbot/pushbot | 91 ++++++++++--------- 6 files changed, 69 insertions(+), 54 deletions(-) diff --git a/luci-app-jd-dailybonus/Makefile b/luci-app-jd-dailybonus/Makefile index 3431c8c96..fac27df33 100644 --- a/luci-app-jd-dailybonus/Makefile +++ b/luci-app-jd-dailybonus/Makefile @@ -4,14 +4,16 @@ PKG_NAME:=luci-app-jd-dailybonus PKG_VERSION:=1.0.5 PKG_RELEASE:=20210316 -define Package/$(PKG_NAME)/conffiles -/etc/config/jd-dailybonus -endef +PKG_MAINTAINER:=jerrykuku LUCI_TITLE:=Luci for JD dailybonus Script LUCI_PKGARCH:=all LUCI_DEPENDS:=+node +uclient-fetch +lua +libuci-lua +define Package/$(PKG_NAME)/conffiles +/etc/config/jd-dailybonus +endef + include $(TOPDIR)/feeds/luci/luci.mk # call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-pushbot/Makefile b/luci-app-pushbot/Makefile index 0ec09fc70..42f6a1417 100644 --- a/luci-app-pushbot/Makefile +++ b/luci-app-pushbot/Makefile @@ -1,8 +1,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-pushbot -PKG_VERSION:=3.50 -PKG_RELEASE:=2 +PKG_VERSION:=3.55 +PKG_RELEASE:=3 PKG_MAINTAINER:=tty228 zzsj0928 diff --git a/luci-app-pushbot/README.md b/luci-app-pushbot/README.md index c8b1679b2..19e50e6f1 100644 --- a/luci-app-pushbot/README.md +++ b/luci-app-pushbot/README.md @@ -28,6 +28,9 @@ - 故由 然后七年 @zzsj0928 重新修改为本插件,为钉钉机器人API使用。 - 本插件工作在:openwrt - 本插件支持:钉钉推送,企业微信推送,PushPlus推送,微信推送,企业微信应用推送,飞书推送,钉钉机器人推送,企业微信机器人推送,飞书机器人推送,一对多推送,Bark推送(仅iOS) +- 自20210911之后的版本,支持Bark群组,群组名默认为设备名 +- 自20210901之后的版本,增加依赖jq,请重新编译或在安装前同步安装jq + # 显示效果 ## 通知栏:直接显示推送主题,一目了然,按设备不同,分组显示 diff --git a/luci-app-pushbot/root/usr/bin/pushbot/api/bark.json b/luci-app-pushbot/root/usr/bin/pushbot/api/bark.json index e78a47a95..bbcaa8699 100644 --- a/luci-app-pushbot/root/usr/bin/pushbot/api/bark.json +++ b/luci-app-pushbot/root/usr/bin/pushbot/api/bark.json @@ -2,15 +2,15 @@ "_api": "这是Bark推送 post 模板信息 api 文件", "_api": "【Bark推送】", - "url": "${bark_srv}/${bark_token}/${1}/${nowtime}${markdown_linefeed}${2}?isArchive=1", + "url": "", "data": "@${tempjsonpath}", - "content_type": "Content-Type: application/json", + "content_type": "", "str_title_start": "【", "str_title_end": "】", - "str_linefeed": "\\n", - "str_splitline": "\\n\\n", - "str_space": " ", - "str_tab": " ", + "str_linefeed": "%0D%0A%0D%0A", + "str_splitline": "%0D%0A%0D%0A", + "str_space": "%20", + "str_tab": "%20", "table_tab": "", "font_green": "", "font_red": "", @@ -18,9 +18,10 @@ "font_purple": "", "font_end": "", "font_end2": "", - "percentsym": "", + "percentsym": "25", "boldstar": "", "type": { + "bark_text": "\"${bark_srv}/${bark_token}/${1}/${nowtime}${str_linefeed}${2}?group=${device_name}\"" } } diff --git a/luci-app-pushbot/root/usr/bin/pushbot/api/pushplus.json b/luci-app-pushbot/root/usr/bin/pushbot/api/pushplus.json index fda1a3432..fc5f4a69a 100644 --- a/luci-app-pushbot/root/usr/bin/pushbot/api/pushplus.json +++ b/luci-app-pushbot/root/usr/bin/pushbot/api/pushplus.json @@ -19,7 +19,7 @@ "font_end": "", "font_end2": "", "percentsym": "", - "boldstar": "**", + "boldstar": "", "type": { "token": "\"${pp_token}\"", diff --git a/luci-app-pushbot/root/usr/bin/pushbot/pushbot b/luci-app-pushbot/root/usr/bin/pushbot/pushbot index 2188c4235..5d1e3743c 100755 --- a/luci-app-pushbot/root/usr/bin/pushbot/pushbot +++ b/luci-app-pushbot/root/usr/bin/pushbot/pushbot @@ -34,7 +34,7 @@ function read_config(){ 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 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 ipv4_urllist=`cat /usr/bin/pushbot/api/ipv4.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 "$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 "$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_end=`/usr/bin/jq -r '.str_title_end' ${jsonpath}` str_linefeed=`/usr/bin/jq -r '.str_linefeed' ${jsonpath}` @@ -77,6 +77,9 @@ function pushbot_init(){ fi down_oui & 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 [ ! -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} @@ -99,7 +102,11 @@ function diy_send(){ [ $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} - 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厂商信息 @@ -325,13 +332,13 @@ function get_client_usage(){ local time1=$(time_for_humans `expr ${time1} - ${time_up}`) if [ -z "$title" ]; then 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 - 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}" else 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 done @@ -483,7 +490,7 @@ function LockFile(){ LockFile lock fi [ $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 IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $last_IPv6 >> ${dir}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 echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】获取 IPv4 地址失败" >> ${logfile} fi @@ -719,7 +726,7 @@ function ip_changes(){ echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $IPv6 >> ${dir}ip [ -z "$title" ] && title="IPv6 地址变化" [ ! -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 echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】获取 IPv6 地址失败" >> ${logfile} 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} echo IPv4 $IPv4 > ${dir}ip && echo -e IPv6 $IPv6 >> ${dir}ip 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_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ] && content="${content}${str_linefeed}${str_tab}当前IPv6:${IPv6}" fi @@ -752,6 +759,7 @@ function ip_changes(){ function up(){ [ -f ${dir}ipAddress ] && ( cat ${dir}ipAddress|grep -q -w $1 ) && return local ip_mac=`getmac $1` + local ip_name=`getname ${1} ${ip_mac}` local ip_interface=`getinterface ${ip_mac}` getping ${1} ${up_timeout} "1";local ping_online=$? if [ "$ping_online" -eq "0" ]; then @@ -791,7 +799,7 @@ function up(){ 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}" 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 "$title" ] && echo "$title" >${dir}title [ ! -z "$content" ] && echo -n "$content" >>${dir}content @@ -858,9 +866,10 @@ function down_send(){ # 当前设备列表 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}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}'` for ip in $IPLIST; do local ip_mac=`getmac ${ip}` @@ -880,7 +889,7 @@ function current_device(){ local ip_total="${ip_total}${str_space}" done 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 done } @@ -902,7 +911,7 @@ function cpu_load(){ title="CPU 温度过高!" temperaturecd_time=`date +%s` 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 unset temperaturecd_time fi @@ -965,7 +974,7 @@ EOF rm -f ${dir}get_syslog >/dev/null 2>&1 } -# 登陆提醒通知 +# 登录提醒通知 function login_send(){ [ -z "$web_logged" ] && [ -z "$ssh_logged" ] && [ -z "$web_login_failed" ] && [ -z "$ssh_login_failed" ] && 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` if [ ! -z "$web_logged" ] && [ "$web_logged" -eq "1" ]; then if [ -z "$title" ]; then - 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}" - elif ( echo "$title"|grep -q "登陆了路由器" ); then + title="${login_ip} 通过 Web 登录了路由器" + 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 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}" else 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 - 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 echo "" > ${dir}web_login 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}" if [ ! -z "$ssh_logged" ] && [ "$ssh_logged" -eq "1" ]; then if [ -z "$title" ]; then - 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}" - elif ( echo "$title"|grep -q "登陆了路由器" ); then + title="${login_ip} 通过 SSH 登录了路由器" + 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 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}" else 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 - 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 echo "" > ${dir}ssh_login unset login_ip login_ip_list @@ -1031,18 +1040,18 @@ function login_send(){ if [ "$web_login_sum" -ge "$login_max_num" ] ;then if [ ! -z "$web_login_failed" ] && [ "$web_login_failed" -eq "1" ]; then if [ -z "$title" ]; then - 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}" - elif ( echo "$title"|grep -q "频繁尝试登陆" ); then + title="${login_ip} 通过 Web 频繁尝试登录" + 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 title="${login_ip} ${title}" content="${content}${str_splitline}${str_tab}设备 IP: ${str_space}${str_space}${str_space}${str_space}${login_ip}" else 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 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 fi done @@ -1056,18 +1065,18 @@ function login_send(){ if [ "$ssh_login_sum" -ge "$login_max_num" ] ;then if [ ! -z "$ssh_login_failed" ] && [ "$ssh_login_failed" -eq "1" ]; then if [ -z "$title" ]; then - 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}" - elif ( echo "$title"|grep -q "频繁尝试登陆" ); then + title="${login_ip} 通过 SSH 频繁尝试登录" + 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 title="${login_ip} ${title}" content="${content}${str_splitline}${str_tab}设备 IP: ${str_space}${str_space}${str_space}${str_space}${login_ip}" else 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 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 fi done @@ -1102,7 +1111,7 @@ function add_ip_black(){ function send(){ echo "`date "+%Y-%m-%d %H:%M:%S"` 【定时数据】创建定时任务" >> ${logfile} 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 "$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 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 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}CPU占用:${cpuload}${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 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}" if [ ! -z "$pushbot_ipv6" ] && [ "$pushbot_ipv6" -ne "0" ]; then 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" ] && login_send - # Noti + # 通知 if [ ! -f "${dir}send_enable.lock" ] && [ ! -z "$title" ] && [ ! -z "$content" ]; then [ ! -z "$device_name" ] && title="【$device_name】$title" ( echo "$lite_enable"|grep -q "content" ) && content="$title"