温馨提示×

怎样监控Debian FTPServer状态

小樊
48
2026-10-09 17:37:33
栏目: 智能运维

在 Debian 上监控 FTPServer(通常是 vsftpd / proftpd / pure-ftpd) 的状态,可以从服务状态、连接情况、日志、端口、性能几个层面来做。下面以最常见的 vsftpd 为例,同时兼顾通用方法。


一、查看 FTPServer 服务状态(最基础)

1. systemd 方式(推荐)

systemctl status vsftpd

或

systemctl status proftpd
systemctl status pure-ftpd

查看是否 active (running)

2. 是否开机自启

systemctl is-enabled vsftpd

二、监控 FTP 端口与监听状态

1. 查看监听端口(FTP 默认 21)

ss -lntp | grep :21

或

netstat -lntp | grep :21

2. 被动模式端口(如 30000-31000)

ss -lntp | grep -E '300[0-9][0-9]'

三、实时查看 FTP 连接情况

1. 当前连接数

ss -tn | grep :21 | wc -l

2. 查看具体连接 IP

ss -tn | grep :21

3. 查看登录中的用户(vsftpd)

ps aux | grep vsftpd

四、查看 FTP 日志(非常重要)

vsftpd 日志位置

/var/log/vsftpd.log

或

/var/log/syslog

查看实时日志:

tail -f /var/log/vsftpd.log

常见监控点:

  • 登录成功 / 失败
  • 上传 / 下载
  • 断连 / 超时

五、监控 FTP 登录与异常

1. 统计失败登录

grep "FAIL" /var/log/vsftpd.log | wc -l

2. 查看异常 IP

grep "FAIL" /var/log/vsftpd.log | awk '{print $NF}' | sort | uniq -c

六、使用简单脚本监控 FTP 状态

示例(检查服务是否存活):

#!/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

七、专业监控方案(生产环境)

1. 系统级

  • Zabbix
  • Prometheus + node_exporter
  • Netdata

2. FTP 专用

  • 自定义 Zabbix 监控项(端口 + 日志关键字)
  • Fail2ban(防暴力破解)

八、常见 FTPServer 对应命令

FTP 软件 服务名 配置文件
vsftpd vsftpd /etc/vsftpd.conf
proftpd proftpd /etc/proftpd/proftpd.conf
pure-ftpd pure-ftpd /etc/pure-ftpd/

如果你能告诉我:

  • 用的是 vsftpd / proftpd / pure-ftpd
  • 是 FTP 还是 FTPS(SSL)
  • 是个人服务器还是生产环境

我可以给你更精确的监控方案或脚本。

0 踩