在 Debian 上监控 FTPServer(通常是 vsftpd / proftpd / pure-ftpd) 的状态,可以从服务状态、连接情况、日志、端口、性能几个层面来做。下面以最常见的 vsftpd 为例,同时兼顾通用方法。
systemctl status vsftpd
或
systemctl status proftpd
systemctl status pure-ftpd
查看是否 active (running)
systemctl is-enabled vsftpd
ss -lntp | grep :21
或
netstat -lntp | grep :21
ss -lntp | grep -E '300[0-9][0-9]'
ss -tn | grep :21 | wc -l
ss -tn | grep :21
ps aux | grep vsftpd
/var/log/vsftpd.log
或
/var/log/syslog
查看实时日志:
tail -f /var/log/vsftpd.log
常见监控点:
grep "FAIL" /var/log/vsftpd.log | wc -l
grep "FAIL" /var/log/vsftpd.log | awk '{print $NF}' | sort | uniq -c
示例(检查服务是否存活):
#!/bin/bash
systemctl is-active --quiet vsftpd
if [ $? -ne 0 ]; then
echo "vsftpd is down" | mail -s "FTP Alert" admin@yourdomain.com
fi
加入 crontab:
*/5 * * * * /root/check_ftp.sh
| FTP 软件 | 服务名 | 配置文件 |
|---|---|---|
| vsftpd | vsftpd | /etc/vsftpd.conf |
| proftpd | proftpd | /etc/proftpd/proftpd.conf |
| pure-ftpd | pure-ftpd | /etc/pure-ftpd/ |
如果你能告诉我:
我可以给你更精确的监控方案或脚本。