Compare commits
40 Commits
d6784fa70c
...
main
Author | SHA1 | Date | |
---|---|---|---|
987ac44575 | |||
e8159fc8cb | |||
cc1463b166 | |||
14c72fe080 | |||
2922806e9c | |||
06e5111309 | |||
b04b9e9205 | |||
cad7792fa1 | |||
fd553b3442 | |||
9b849897e2 | |||
05f461f8c1 | |||
1cee89cd0a | |||
203138947b | |||
3d2e0e33af | |||
e11dc60438 | |||
7123fa1147 | |||
f1fd1aaff5 | |||
2dec392e50 | |||
6cb768a05e | |||
a0f8f49b27 | |||
09d63b6630 | |||
44ef429d5a | |||
de6d1d47c8 | |||
b335f61c72 | |||
c61686065e | |||
9a001021b1 | |||
6080fe48c1 | |||
36a18e870f | |||
40e14b5cc7 | |||
a96f533f8f | |||
b36c0b6939 | |||
7e68bbb891 | |||
21f481076c | |||
fc60587252 | |||
d1afa8e0ad | |||
09f73bb770 | |||
ed631e97c2 | |||
f5c9f65fe7 | |||
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__":
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
> /tmp/docker_alarm.log
|
> /tmp/docker_alarm.log
|
||||||
docker ps -a --format "table {{.Names}}\t{{.Status}}" > /opt/logs/docker_status.log
|
docker ps -a --format "table {{.Names}}\t{{.Status}}" > /opt/logs/docker_status.log
|
||||||
while read line; do
|
while read line; do
|
||||||
echo $line | grep -q 'Exited'
|
echo $line | grep -v 'v2raya' | grep -q 'Exited'
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
name=`echo $line | awk '{print $1}'`
|
name=`echo $line | awk '{print $1}'`
|
||||||
echo "Docker Alarm - $name: Container $name has been off line, please check ASAP." >> /tmp/docker_alarm.log
|
echo "Docker Alarm - $name: Container $name has been off line, please check ASAP." >> /tmp/docker_alarm.log
|
||||||
@ -12,6 +12,6 @@ done < /opt/logs/docker_status.log
|
|||||||
|
|
||||||
if [[ -s /tmp/docker_alarm.log ]]; then
|
if [[ -s /tmp/docker_alarm.log ]]; then
|
||||||
alarm=`cat /tmp/docker_alarm.log`
|
alarm=`cat /tmp/docker_alarm.log`
|
||||||
python3 /opt/scripts/alert/sendmail.py "Docker Alarms" "$alarm"
|
python3 /opt/git/scripts/alert/sendmail.py "Docker Alarms" "$alarm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -8,8 +8,7 @@ cp -rf /var/spool/cron/crontabs/ /opt/configs/
|
|||||||
cp -rf /usr/local/nginx/conf/nginx.conf /opt/configs/nginx/nginx.conf
|
cp -rf /usr/local/nginx/conf/nginx.conf /opt/configs/nginx/nginx.conf
|
||||||
cp -rf /usr/local/nginx/conf/domain_confs/ /opt/configs/nginx/
|
cp -rf /usr/local/nginx/conf/domain_confs/ /opt/configs/nginx/
|
||||||
cp -rf /etc/docker/daemon.json /opt/configs/conf/
|
cp -rf /etc/docker/daemon.json /opt/configs/conf/
|
||||||
cp -rf /etc/sysctl.conf /opt/configs/conf/
|
cp -rf /etc/netdata/ /opt/configs/
|
||||||
cp -rf /etc/sysctl.d/99-tailscale.conf /opt/configs/conf/
|
|
||||||
cp -rf /etc/pip.conf /opt/configs/conf/
|
cp -rf /etc/pip.conf /opt/configs/conf/
|
||||||
cp -rf /etc/apt/sources.list /opt/configs/conf/
|
cp -rf /etc/apt/sources.list /opt/configs/conf/
|
||||||
cp -rf /etc/ssh/sshd_config /opt/configs/conf/
|
cp -rf /etc/ssh/sshd_config /opt/configs/conf/
|
||||||
@ -19,11 +18,15 @@ cp -rf /root/.ssh/config /opt/configs/conf/
|
|||||||
cp -rf /etc/samba/smb.conf /opt/configs/conf/
|
cp -rf /etc/samba/smb.conf /opt/configs/conf/
|
||||||
cp -rf /etc/network/interfaces /opt/configs/conf/
|
cp -rf /etc/network/interfaces /opt/configs/conf/
|
||||||
cp -rf /root/.acme.sh/*ecc /opt/configs/acme/
|
cp -rf /root/.acme.sh/*ecc /opt/configs/acme/
|
||||||
|
cp -rf /root/.acme.sh/rustle.cc_ecc/rustle.cc.{key,cer} /opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/
|
||||||
cp -rf /opt/apps/syncthing/data/common/A_Program/FRP/* /opt/apps/frp/frpc-xtcp-visitor/
|
cp -rf /opt/apps/syncthing/data/common/A_Program/FRP/* /opt/apps/frp/frpc-xtcp-visitor/
|
||||||
|
cp -rf /etc/systemd/network /opt/configs/conf/
|
||||||
|
cp -rf /etc/modprobe.d/pcspkr-blacklist.conf /opt/configs/conf/
|
||||||
|
cp -rf /lib/firmware/intel/ ibt-0040-1050* /opt/configs/conf/intel/
|
||||||
|
|
||||||
cd /opt && t=`date +%Y%m%dT%H%M%S`
|
cd /opt && t=`date +%Y%m%dT%H%M%S`
|
||||||
# rsync --delete-after -avz --exclude=apps/localcr/B_koel/local/music apps configs logs scripts websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
|
# rsync --delete-after -avz --exclude=apps/localcr/B_koel/local/music apps configs logs scripts websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
|
||||||
rsync --delete-after -avz apps configs logs scripts websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
|
rsync --delete-after -avz --exclude=apps/syncthing apps configs logs git websites wd/72-Backups/VPS/ > /opt/logs/rsync/rsync_${t}.log
|
||||||
cd /opt/logs/rsync/
|
cd /opt/logs/rsync/
|
||||||
let count=`ls | wc -l`
|
let count=`ls | wc -l`
|
||||||
if [[ $count -gt 10 ]]; then
|
if [[ $count -gt 10 ]]; then
|
||||||
@ -42,9 +45,7 @@ if [[ `date +%d` == '01' ]]; then
|
|||||||
t=`date +%Y%m%d%H%M%S` && cd /opt/wd/72-Backups/
|
t=`date +%Y%m%d%H%M%S` && cd /opt/wd/72-Backups/
|
||||||
|
|
||||||
tar -I pigz -cf vps-${t}.tar.gz \
|
tar -I pigz -cf vps-${t}.tar.gz \
|
||||||
--exclude=VPS/apps/localcr/B_koel/local/music \
|
|
||||||
--exclude=VPS/apps/localcr/I_cloudreve/local/cloudreve/uploads \
|
--exclude=VPS/apps/localcr/I_cloudreve/local/cloudreve/uploads \
|
||||||
--exclude=VPS/apps/localcr/K_nextcloud/local/nextcloud/data/nextcloud/files \
|
|
||||||
--exclude=VPS/apps/syncthing/data \
|
--exclude=VPS/apps/syncthing/data \
|
||||||
VPS/ > /dev/null 2>&1
|
VPS/ > /dev/null 2>&1
|
||||||
# tar -I unpigz -xf vps-20231101162641.tar.gz
|
# tar -I unpigz -xf vps-20231101162641.tar.gz
|
||||||
|
41
update/chatbot_suqian.sh
Normal file
41
update/chatbot_suqian.sh
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function sendMsg() {
|
||||||
|
|
||||||
|
# 个人测试
|
||||||
|
# curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ddea3f5f-fbfc-4c21-994a-71e9fc50e4ef' \
|
||||||
|
# -H 'Content-Type: application/json' \
|
||||||
|
# -d '
|
||||||
|
# {
|
||||||
|
# "msgtype": "markdown",
|
||||||
|
# "markdown": {
|
||||||
|
# "content": "**'"$alarmTitle"'**\n
|
||||||
|
# > <font color=\"warning\">'"$alarmInfo"'</font>"
|
||||||
|
# }
|
||||||
|
# }' > /dev/null 2>&1
|
||||||
|
|
||||||
|
# 群hook
|
||||||
|
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=924c62e3-1bb8-4d17-84b1-e543eb27ba1e' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '
|
||||||
|
{
|
||||||
|
"msgtype": "text",
|
||||||
|
"text": {
|
||||||
|
"content": "'"$alarmTitle"':\n'"$alarmInfo"'",
|
||||||
|
"mentioned_list":["@all"]
|
||||||
|
}
|
||||||
|
}' > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
isFriday=$(date +%A)
|
||||||
|
time_opt=$1
|
||||||
|
alarmTitle="每日/周工作记录提醒"
|
||||||
|
|
||||||
|
if [[ $isFriday == 'Friday' ]]; then
|
||||||
|
alarmInfo='周五了[庆祝][庆祝][庆祝],请各位及时填写周报,感谢大家本周的辛苦付出,别忘了还有今日工作内容安排记录,以及问题进展跟新~~~'
|
||||||
|
else
|
||||||
|
alarmInfo='大家记得写每日工作内容安排,上午10点之前写完,工作期间可以补充内容,下班前17点左右完善一下,争取日事日毕~[拳头][拳头][拳头]\n有事没事找找客户经理,发个信息啥的也可~~\n客户走访记录,问题解决以及客户经理需求记录,也要记得跟进更新闭环~~~'
|
||||||
|
fi
|
||||||
|
|
||||||
|
sendMsg $alarmTitle $alarmInfo
|
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
/usr/bin/qbittorrent-nox --webui-port=10005 -d
|
/usr/bin/qbittorrent-nox --webui-port=10005 -d
|
||||||
# /usr/bin/bash /opt/scripts/update/calibre.sh
|
|
||||||
mv /opt/wd/99-Temp/shutdown /opt/wd/99-Temp/shutdown.old
|
mv /opt/wd/99-Temp/shutdown /opt/wd/99-Temp/shutdown.old
|
||||||
mv /opt/wd/99-Temp/reboot /opt/wd/99-Temp/reboot.old
|
mv /opt/wd/99-Temp/reboot /opt/wd/99-Temp/reboot.old
|
||||||
|
sleep 20
|
||||||
|
ifconfig > /opt/wd/99-Temp/ifconfig.txt
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
# ip link set enp1s0 promisc on
|
# ip link set enp1s0 promisc on
|
||||||
# ip link set enp2s0 promisc on
|
# ip link set enp2s0 promisc on
|
||||||
# ip link set wlx90de80ca01ec promisc on
|
# ip link set wlx90de80ca01ec promisc on
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
# sleep 20
|
# sleep 20
|
||||||
# /usr/bin/bash /opt/scripts/update/macvlan.sh
|
# /usr/bin/bash /opt/git/scripts/update/macvlan.sh
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
# nohup /usr/bin/bash /opt/scripts/update/jekyll_update.sh > /dev/null 2>&1 &
|
|
||||||
# /usr/bin/mount -t ext4 -w UUID="b7c2c4b8-bfde-479b-80bb-655432a433b8" /opt/wd
|
# /usr/bin/mount -t ext4 -w UUID="b7c2c4b8-bfde-479b-80bb-655432a433b8" /opt/wd
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# get latest hosts for accelerate github visiting
|
# get latest hosts for accelerate github visiting
|
||||||
curl https://raw.hellogithub.com/hosts >> /opt/logs/hosts
|
# curl https://raw.hellogithub.com/hosts >> /opt/logs/hosts
|
||||||
|
|
||||||
# renew images.json file for background picture of homepage
|
# renew images.json file for background picture of homepage
|
||||||
cd /opt/websites/homepage/
|
cd /opt/websites/homepage/
|
||||||
@ -9,7 +9,7 @@ node assets/js/bing.js > /dev/null 2>&1
|
|||||||
|
|
||||||
if [[ `date +%d` == '01' ]]; then
|
if [[ `date +%d` == '01' ]]; then
|
||||||
# random logo for dash
|
# random logo for dash
|
||||||
# bash /opt/scripts/update/dash_rand_logo.sh
|
# bash /opt/git/scripts/update/dash_rand_logo.sh
|
||||||
cp /root/.acme/rustle.cc_ecc/fullchain.cer '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
|
cp /root/.acme/rustle.cc_ecc/fullchain.cer '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
|
||||||
cp /root/.acme/rustle.cc_ecc/rustle.cc.key '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
|
cp /root/.acme/rustle.cc_ecc/rustle.cc.key '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
|
||||||
fi
|
fi
|
||||||
@ -19,4 +19,4 @@ let numOfAvatar=`ls /opt/websites/homepage/assets/img/logos | wc -l`
|
|||||||
let randNumber=$RANDOM%$numOfAvatar
|
let randNumber=$RANDOM%$numOfAvatar
|
||||||
cp /opt/websites/homepage/assets/img/logos/${randNumber}.jpg /opt/websites/homepage/assets/img/logo.jpg
|
cp /opt/websites/homepage/assets/img/logos/${randNumber}.jpg /opt/websites/homepage/assets/img/logo.jpg
|
||||||
|
|
||||||
docker exec -u www-data nextcloud php /var/www/html/occ files:scan --all
|
# docker exec -u www-data nextcloud php /var/www/html/occ files:scan --all
|
||||||
|
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/git/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 500 ]]; then
|
||||||
|
systemctl restart frps.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
18
utool/pid_in_docker.sh
Normal file
18
utool/pid_in_docker.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
psid=$1
|
||||||
|
|
||||||
|
ids=$(docker inspect -f "{{.Id}}" $(docker ps -q))
|
||||||
|
|
||||||
|
for did in $ids; do
|
||||||
|
docker top $did | awk '{print $2, $3}' | grep -wq $psid
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo "Docker ID : $did"
|
||||||
|
name=$(docker inspect -f '{{.Name}}' $did | tr -d "/")
|
||||||
|
echo "Docker Name: $name"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Not a docker (sub)process..."
|
||||||
|
|
17
utool/ps_top_20.sh
Normal file
17
utool/ps_top_20.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ps -ely | sort -nrk 8 | head -n 20 | awk 'BEGIN{print "UID", "PID", "PPID", "RSS", "CMD"} {print $2, $3, $4, $8/1024"M", $NF}' | column -t
|
||||||
|
fmt="%-9s%-9s%-6s%-6s\033[1;32m%-8s\033[0m%-10s\n"
|
||||||
|
awk -v fmt=$fmt 'BEGIN{printf fmt, "PID","PPID","%CPU","%MEM","RSS","COMM"}' > /tmp/mem.top
|
||||||
|
ps -eo pid,ppid,pcpu,pmem,rss,comm | grep -Ev "grep|ps" | sort -nrk 5 | head -n 20 | awk -v fmt=$fmt '{printf fmt, $1,$2,$3,$4,int($5/1024)"M",$6}' >> /tmp/mem.top
|
||||||
|
|
||||||
|
> /tmp/deli.top
|
||||||
|
for i in `seq 21`; do
|
||||||
|
echo '|' >> /tmp/deli.top
|
||||||
|
done
|
||||||
|
|
||||||
|
fmt="%-9s%-9s\033[1;34m%-6s\033[0m%-6s%-8s%-10s\n"
|
||||||
|
awk -v fmt=$fmt 'BEGIN{printf fmt, "PID","PPID","%CPU","%MEM","RSS","COMM"}' > /tmp/cpu.top
|
||||||
|
ps -eo pid,ppid,pcpu,pmem,rss,comm | sort -nrk 3 | grep -Ev "grep|ps|utool" | head -n 20 | awk -v fmt=$fmt '{printf fmt, $1,$2,$3,$4,int($5/1024)"M",$6}' >> /tmp/cpu.top
|
||||||
|
|
||||||
|
paste /tmp/mem.top /tmp/deli.top /tmp/cpu.top | column -t
|
||||||
|
rm -rf /tmp/{mem.top,cpu.top,deli.top}
|
@ -24,7 +24,7 @@ def utool(option):
|
|||||||
# -a
|
# -a
|
||||||
def list_local_using_port():
|
def list_local_using_port():
|
||||||
exit_on_wrong_number()
|
exit_on_wrong_number()
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/ipports.sh port')
|
os.system('/usr/bin/bash /opt/git/scripts/utool/ipports.sh port')
|
||||||
|
|
||||||
# -b
|
# -b
|
||||||
def github_two_factor():
|
def github_two_factor():
|
||||||
@ -34,7 +34,7 @@ def utool(option):
|
|||||||
# -c
|
# -c
|
||||||
def get_external_ip():
|
def get_external_ip():
|
||||||
exit_on_wrong_number()
|
exit_on_wrong_number()
|
||||||
os.system("/usr/bin/python3 /opt/scripts/roll_api/get_self_ip.py")
|
os.system("/usr/bin/python3 /opt/git/scripts/roll_api/get_self_ip.py")
|
||||||
|
|
||||||
# -d
|
# -d
|
||||||
def get_ip_location():
|
def get_ip_location():
|
||||||
@ -44,7 +44,7 @@ def utool(option):
|
|||||||
ipv4 = re.match(r"^((([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))\.){3}(([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))$", checked_ip)
|
ipv4 = re.match(r"^((([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))\.){3}(([01]?\d\d?)|(2[0-4]\d)|(25[0-5]))$", checked_ip)
|
||||||
if ipv4:
|
if ipv4:
|
||||||
os.environ['checked_ip'] = checked_ip
|
os.environ['checked_ip'] = checked_ip
|
||||||
os.system('/usr/bin/python3 /opt/scripts/roll_api/get_ip.py $checked_ip')
|
os.system('/usr/bin/python3 /opt/git/scripts/roll_api/get_ip.py $checked_ip')
|
||||||
else:
|
else:
|
||||||
print(f"{c_br}Plz enter correct IP...{c_e}")
|
print(f"{c_br}Plz enter correct IP...{c_e}")
|
||||||
exit(ord(option.strip('-')))
|
exit(ord(option.strip('-')))
|
||||||
@ -69,12 +69,12 @@ def utool(option):
|
|||||||
def number2date():
|
def number2date():
|
||||||
exit_on_wrong_number(2)
|
exit_on_wrong_number(2)
|
||||||
os.environ['param'] = sys.argv[2]
|
os.environ['param'] = sys.argv[2]
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/number2d.sh $param')
|
os.system('/usr/bin/bash /opt/git/scripts/utool/number2d.sh $param')
|
||||||
|
|
||||||
# -g
|
# -g
|
||||||
def date2number():
|
def date2number():
|
||||||
if len(sys.argv) < 3:
|
if len(sys.argv) < 3:
|
||||||
print(f"{c_br}-k选项:将输入的时间转换成十进制和十六进制,需要一个字符串格式的时间作为输入,退出...{c_e}\n")
|
print(f"{c_br}-g选项:将输入的时间转换成十进制和十六进制,需要一个字符串格式的时间作为输入,退出...{c_e}\n")
|
||||||
exit(ord(option.strip('-')))
|
exit(ord(option.strip('-')))
|
||||||
|
|
||||||
param=''
|
param=''
|
||||||
@ -82,13 +82,42 @@ def utool(option):
|
|||||||
param += item + ' '
|
param += item + ' '
|
||||||
|
|
||||||
os.environ['param'] = param
|
os.environ['param'] = param
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/date2n.sh $param')
|
os.system('/usr/bin/bash /opt/git/scripts/utool/date2n.sh $param')
|
||||||
|
|
||||||
|
# -h
|
||||||
|
def usage():
|
||||||
|
exit_on_wrong_number()
|
||||||
|
print_usage()
|
||||||
|
|
||||||
|
# -i
|
||||||
|
def ps_top_20():
|
||||||
|
exit_on_wrong_number()
|
||||||
|
os.system("/usr/bin/bash /opt/git/scripts/utool/ps_top_20.sh")
|
||||||
|
|
||||||
|
# -j
|
||||||
|
def docker_pid():
|
||||||
|
exit_on_wrong_number(2)
|
||||||
|
os.environ['param'] = sys.argv[2]
|
||||||
|
os.system('/usr/bin/bash /opt/git/scripts/utool/pid_in_docker.sh $param')
|
||||||
|
|
||||||
|
# -k
|
||||||
|
def company_two_factor():
|
||||||
|
exit_on_wrong_number()
|
||||||
|
# method 1
|
||||||
|
# os.system("/usr/bin/echo -n 'ujjpsx7q'")
|
||||||
|
# os.system("/usr/bin/oathtool -b --totp '22IH2VYKEQYOWVFCCHY5KTU4CYTJ7Z3O'")
|
||||||
|
# method 2
|
||||||
|
pin = 'ujjpsx7q'
|
||||||
|
totp = os.popen("/usr/bin/oathtool -b --totp '22IH2VYKEQYOWVFCCHY5KTU4CYTJ7Z3O'").read()
|
||||||
|
res = pin + totp
|
||||||
|
print(res, end='')
|
||||||
|
return res
|
||||||
|
|
||||||
# -p
|
# -p
|
||||||
def gen_passwd():
|
def gen_passwd():
|
||||||
exit_on_wrong_number(2)
|
exit_on_wrong_number(2)
|
||||||
os.environ['length'] = sys.argv[2]
|
os.environ['length'] = sys.argv[2]
|
||||||
os.system('/usr/bin/bash /opt/scripts/utool/genpw.sh length')
|
os.system('/usr/bin/bash /opt/git/scripts/utool/genpw.sh length')
|
||||||
|
|
||||||
def exit_on_wrong_number(number=1):
|
def exit_on_wrong_number(number=1):
|
||||||
if len(sys.argv) != (number+1):
|
if len(sys.argv) != (number+1):
|
||||||
@ -104,7 +133,7 @@ def utool(option):
|
|||||||
'-o': ['Reserved', None],
|
'-o': ['Reserved', None],
|
||||||
'-c': [' show external IP of this machine', get_external_ip],
|
'-c': [' show external IP of this machine', get_external_ip],
|
||||||
'-p': ['*generate password of length 1~79', gen_passwd],
|
'-p': ['*generate password of length 1~79', gen_passwd],
|
||||||
'-d': [' show the location of ip(only v4 for now)', get_ip_location],
|
'-d': ['*show the location of ip(only v4 for now)', get_ip_location],
|
||||||
'-q': ['Reserved', None],
|
'-q': ['Reserved', None],
|
||||||
'-e': ['*generate md5 value of the input string', gen_md5],
|
'-e': ['*generate md5 value of the input string', gen_md5],
|
||||||
'-r': ['Reserved', None],
|
'-r': ['Reserved', None],
|
||||||
@ -114,11 +143,11 @@ def utool(option):
|
|||||||
'-t': ['Reserved', None],
|
'-t': ['Reserved', None],
|
||||||
'-h': [' show this help information and exit', print_usage],
|
'-h': [' show this help information and exit', print_usage],
|
||||||
'-u': ['Reserved', None],
|
'-u': ['Reserved', None],
|
||||||
'-i': ['Reserved', None],
|
'-i': [' print top 20 mem and cpu process', ps_top_20],
|
||||||
'-v': ['Reserved', None],
|
'-v': ['Reserved', None],
|
||||||
'-j': ['Reserved', None],
|
'-j': ['*find a docker subprocess, if true then print info', docker_pid],
|
||||||
'-w': ['Reserved', None],
|
'-w': ['Reserved', None],
|
||||||
'-k': ['Reserved', None],
|
'-k': [' generate two-factor key of GITHUB', company_two_factor],
|
||||||
'-x': ['Reserved', None],
|
'-x': ['Reserved', None],
|
||||||
'-l': ['Reserved', None],
|
'-l': ['Reserved', None],
|
||||||
'-y': ['Reserved', None],
|
'-y': ['Reserved', None],
|
||||||
|
Reference in New Issue
Block a user