-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_shell_zip
61 lines (51 loc) · 1.27 KB
/
log_shell_zip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#创建目录
function create_dir()
{
echo "----------create directions----------"
mkdir log_$(date +%y%m%d%H%M%S)
DIR=log_$(date +%y%m%d%H%M%S)
mkdir $DIR/files $DIR/tckr $DIR/instructions
}
#采集/var/log/httpd/下的文件
function collect_files()
{
echo "----------collect files----------"
cp -r /home/ts/ts_prg/probe/log/* $DIR/files
}
#导出mysql中tckr数据库
function export_tckr()
{
echo "----------export tckr----------"
mysqldump -uroot -p123456 tckr>$DIR/tckr/tckr.sql
}
#指令内容回显
function print_instruct()
{
echo "----------print instructions----------"
ps ax|tee $DIR/instructions/psax
ifconfig|tee $DIR/instructions/ifconfig
ping 172.20.0.2 -c4|tee $DIR/instructions/ping
free|tee $DIR/instructions/free
}
#将log文件压缩并添加压缩密码(tsgroup1)
function compress()
{
echo "----------compress files----------"
# tar -zcvf - $DIR |openssl des3 -salt -k tsgroup1 | dd of=/xiaocao_data/log/$DIR.tar.gz
zip -rP tsgroup1 /xiaocao_data/log/$DIR.zip $DIR
}
#删除创建的log文件夹
function delete_log()
{
echo "----------delete log----------"
rm -rf $DIR
}
create_dir
collect_files
export_tckr
print_instruct
compress
delete_log
#解压文件(密码123456)
#openssl des3 -d -k 123456 -salt -in CPE.tar.gz | tar xzf -