使用Prometheus来监视SoftEther VPN
首先
SoftEther VPN是一款开源的VPN软件。我使用Rust编写了名为softether_exporter的插件,用于在Prometheus中监控它。(商用许可的PacketiX VPN也可以使用该插件)
可以使用Grafana来创建以下类似的仪表板,或者使用Alertmanager对生命活动进行监控。
本文将简单介绍softether_exporter的设置和仪表板的创建。
不涉及Prometheus或Grafana本身的配置,请参考其他文章。

软Ether Exporter的安装设置
请从以下位置下载二进制文件并解压缩到适当的位置(此处设为/usr/local/bin)。
随后,准备配置文件(位置可以是任意的,但在这里我们将其设置为/etc/prometheus/softether.toml)。
vpncmd = "/usr/local/vpnserver/vpncmd"
server = "localhost:8888"
[[hubs]]
name = "HUB1"
password = "xxx"
[[hubs]]
name = "HUB2"
password = "xxx"
vpncmd是SoftEther VPN配套分发的命令行工具,需要指定到该二进制文件的路径。
server是指SoftEther VPN服务器运行的主机和端口(在这里假设是与softether_exporter在同一台服务器上运行)。
此外,还需要为每个虚拟Hub设置名称和访问密码。
另外,由于使用systemd作为服务启动非常方便,因此我们创建以下文件。
[Unit]
Description=Prometheus SoftEther Exporter
After=network.target
[Service]
ExecStart=/usr/local/bin/softether_exporter --config.file=/etc/prometheus/softether.toml
User=nobody
[Install]
WantedBy=multi-user.target
执行systemd的重新加载和服务启动。
$ systemctl daemon-reload
$ systemctl enable softether-exporter
$ systemctl start softether-exporter
完成了softether-exporter的设置。
请根据需要添加Prometheus服务器的抓取配置。
仪表盘
以下是冒头截图中显示的仪表盘,您可以在以下位置进行公开。
只需在Grafana的“导入仪表盘”中输入以下URL并进行数据源设置即可。