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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash

#######################
#for monitor ftp service
#by zhangyin
#file outer
#version 1
#date 2020 01 03
#######################

#ftp info

##shengchan peizhi
#Ftp_readHost: 172.15.1.21
#Ftp_readPort: 21
#Ftp_readUserName: susong
#Ftp_readPassword: QingDun0909
#Ftp_readBasePath: /
#
#Ftp_writeHost: 172.15.1.17
#Ftp_writePort: 21
#Ftp_writeUserName: susong
#Ftp_writePassword: QingDun0909
#Ftp_writeBasePath: /

Ftp_readHost: 127.0.0.1
Ftp_readPort: 21
Ftp_readUserName: aegisops
Ftp_readPassword: aegisops
Ftp_readBasePath: data

Ftp_writeHost: 127.0.0.1
Ftp_writePort: 21
Ftp_writeUserName: aegisops
Ftp_writePassword: aegisops
Ftp_writeBasePath: data


Work_dir="/tmp/ftp_monitor/"
Input_file=${Work_dir}Input.file
Inner_info="INNERINFO"

echo `date +%s` > ${Input_file}
echo 'outter' >> ${Input_file}

mkdir -p ${Work_dir}

Alert () {
echo ${1}
}

Ftp_putin () {
cd ${Work_dir}
ftp -i -n ${Ftp_writeHost} << EOF
user ${Ftp_writeUserName} ${Ftp_writePassword}
cd ${Ftp_writeBasePath}
put ${Input_file}
EOF
}

Ftp_monitor () {
cd ${Work_dir}
ftp -i -n ${Ftp_readHost} << EOF
user ${Ftp_readUserName} ${Ftp_readPassword}
cd ${Ftp_readBasePath}
get ${Input_file}
del ${Input_file}
EOF

if [[ -e ${Input_file} ]]; then
gerp ${Inner_info} ${Input_file}
if [[ $? != 0 ]]; then
Alert 2
fi
else
Alert 1
fi
}