Compare commits
2 Commits
d6784fa70c
...
999b8d977d
Author | SHA1 | Date | |
---|---|---|---|
999b8d977d | |||
c6cb2cf281 |
@ -2,31 +2,36 @@
|
|||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
pformat = "%-7s%-6s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s"
|
pformat = "%-7s%-7s%-10s%-10s%-10s%-10s%-10s"
|
||||||
sformat = "%-23s%-18s%-16s%-14s%-14s%-12s%-12s"
|
sformat = "%-23s%-18s%-16s%-14s%-14s%-12s%-12s"
|
||||||
print(pformat % ('must', 'must', 'optional', 'optional', 'optional', 'optional', 'optional', 'optional', 'optional', 'optional', 'optional'))
|
print(pformat % ('must', 'must', 'optional', 'optional', 'optional', 'optional', 'optional'))
|
||||||
print(pformat % ('title', 'body', 'sound', 'icon', 'group', 'copy', 'autoCopy', 'badge', 'url', 'isArchive', 'level'))
|
print(pformat % ('title', 'body', 'sound', 'icon', 'group', 'badge', 'isArchive'))
|
||||||
print(pformat % ('-', '-', '2.0-alarm', '-', '-', '-', '1', '-', '-', '1', 'active'))
|
print(pformat % ('-', '-', '2.0-alarm', '-', 'default', '-', '1'))
|
||||||
print(pformat % ('-', '-', '1.4-bell', '-', '-', '-', '1', '-', '-', '1', 'timeSensitive'))
|
print(pformat % ('-', '-', '1.4-bell', '-', 'docker', '-', '1'))
|
||||||
print(pformat % ('-', '-', '1.6-bloom', '-', '-', '-', '1', '-', '-', '1', 'passive'))
|
print(pformat % ('-', '-', '1.6-bloom', '-', 'frp', '-', '1'))
|
||||||
print("\nThe 'sound' parameter also accepts the following as its value:")
|
print("\nThe 'sound' parameter also accepts the following as its value:")
|
||||||
print(sformat % ("1.8-healthnotification", "2.6-typewriters", "2.9-newsflash", "1.5-mailsent", "1.5-tiptoes", "4.5-update", "2.9-spell"))
|
print(sformat % ("1.8-healthnotification", "2.6-typewriters", "2.9-newsflash", "1.5-mailsent", "1.5-tiptoes", "4.5-update", "2.9-spell"))
|
||||||
print(sformat % ("2.2-multiwayinvitation", "4.5-anticipate", "1.2-telegraph", "0.9-calypso", "1.5-newmail", "1.7-glass", "2.2-choo"))
|
print(sformat % ("2.2-multiwayinvitation", "4.5-anticipate", "1.2-telegraph", "0.9-calypso", "1.5-newmail", "1.7-glass", "2.2-choo"))
|
||||||
print(sformat % ("1.4-paymentsuccess", "1.5-electronic", "0.7-birdsong", "1.9-descent", "1.3-ladder", "4.5-chime", "1.5-horn"))
|
print(sformat % ("1.4-paymentsuccess", "1.5-electronic", "0.7-birdsong", "1.9-descent", "1.3-ladder", "4.5-chime", "1.5-horn"))
|
||||||
print(sformat % ("4.7-sherwoodforest", "3.0-gotosleep", "4.2-suspense", "1.5-fanfare", "7.0-minuet", "0.6-shake", "1.9-noir"))
|
print(sformat % ("4.7-sherwoodforest", "3.0-gotosleep", "4.2-suspense", "1.5-fanfare", "7.0-minuet", "0.6-shake", "1.9-noir"))
|
||||||
exit(8)
|
print()
|
||||||
|
|
||||||
|
|
||||||
def getParams(params):
|
def getParams(
|
||||||
|
title='test',
|
||||||
params_dict = {'title': '', 'body': '', 'sound': '', 'icon': '', 'group': 'alert', 'copy': '', 'autocopy': '', 'badge': '', 'url': '', 'isarchive': '1', 'level': 'active'}
|
body='hello...',
|
||||||
elements = ['title', 'body', 'sound', 'icon', 'group', 'copy', 'autocopy', 'badge', 'url', 'isarchive', 'level', 'ciphertxt', 'device_key']
|
sound='',
|
||||||
for i in range(len(params)):
|
icon='',
|
||||||
params_dict[elements[i]] = params[i]
|
group='default',
|
||||||
|
badge='1',
|
||||||
|
isarchive=1,
|
||||||
|
):
|
||||||
|
|
||||||
|
params_dict = {'title': title, 'body': body, 'sound': sound, 'icon': icon, 'group': group, 'badge': '1', 'isarchive': '1'}
|
||||||
params_json = json.dumps(params_dict)
|
params_json = json.dumps(params_dict)
|
||||||
with open('/opt/scripts/alert/bark/option.json', 'w') as obj_option:
|
with open('/opt/scripts/alert/bark/option.json', 'w') as obj_option:
|
||||||
obj_option.write(params_json)
|
obj_option.write(params_json)
|
||||||
@ -35,12 +40,28 @@ def getParams(params):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 3:
|
if len(sys.argv) < 5:
|
||||||
print('Need at least 2 parameters, and most can have 11 parameters, exiting...')
|
|
||||||
usage()
|
usage()
|
||||||
|
parser = argparse.ArgumentParser(description='Prepare arguements for bark')
|
||||||
params = sys.argv[1:]
|
parser.add_argument('--title', help='标题,必要参数', required=True)
|
||||||
getParams(params)
|
parser.add_argument('--body', help='主题内容,必要参数', required=True)
|
||||||
|
parser.add_argument('--sound', help='提示音,非必要参数,有默认值', default='alarm')
|
||||||
|
parser.add_argument('--icon', help='图标,非必要参数,有默认值', default='0')
|
||||||
|
parser.add_argument('--group', help='群组,非必要参数,有默认值', default='default')
|
||||||
|
parser.add_argument('--badge', help='角标,非必要参数,有默认值', default='1')
|
||||||
|
parser.add_argument('--isarchive', help='是否自动归档,非必要参数,有默认值', default='1')
|
||||||
|
# if len(sys.argv) == 1:
|
||||||
|
# print('Need at least 2 parameters, and most can have 7 parameters, exiting...')
|
||||||
|
# usage()
|
||||||
|
args = parser.parse_args()
|
||||||
|
title = args.title
|
||||||
|
body = args.body
|
||||||
|
sound = args.sound
|
||||||
|
icon = 'https://www.rustle.cc/assets/img/logos/' + str(args.icon) + '.jpg'
|
||||||
|
group = args.group
|
||||||
|
badge = args.badge
|
||||||
|
isarchive = args.isarchive
|
||||||
|
getParams(title, body, sound, icon, group, badge, isarchive)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
16
update/restart_frpc.sh
Normal file
16
update/restart_frpc.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rss=$(ps aux | grep frpc.toml | grep -v grep | awk '{print $6}')
|
||||||
|
if [[ $rss == '' ]]; then
|
||||||
|
python3 /opt/scripts/alert/bark/msgsend.py --title "FRPC Warning" --body "Seems like FRPC Service has been down, need to check ASAP." --group 'frp' --icon 8
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
rss=$((rss/1024))
|
||||||
|
|
||||||
|
if [[ $rss -gt 500 ]]; then
|
||||||
|
systemctl restart frpc.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
16
update/restart_frps.sh
Normal file
16
update/restart_frps.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rss=$(ps aux | grep frps.toml | grep -v grep | awk '{print $6}')
|
||||||
|
if [[ $rss == '' ]]; then
|
||||||
|
ssh -o ConnectTimeout=60 beelink 'python3 /opt/scripts/alert/bark/msgsend.py --title "FRPS Warning" --body "Seems like FRPS Service has been down, need to check ASAP." --group "frp" --icon 8'
|
||||||
|
exit 9
|
||||||
|
fi
|
||||||
|
|
||||||
|
rss=$((rss/1024))
|
||||||
|
|
||||||
|
if [[ $rss -gt 1000 ]]; then
|
||||||
|
systemctl restart frps.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user