====== openvpn 納入 Zabbix 監控 ====== ===== @openvpn Server 設定程序 ===== * 安裝相關的套件 yum install zabbix-sender nc * OpenVPN 設定啟用 management 功能 * /etc/selinux/config 內要關閉 SELINUX=disabled * vi /etc/openvpn/server.conf : : management 127.0.0.1 7505 service openvpn restart netstat -na | grep 7505 [root@openvpn ~]# netstat -na | grep 7505 tcp 0 0 127.0.0.1:7505 0.0.0.0:* LISTEN * 加入 zabbix script * cd /usr/local/bin/ wget https://gist.githubusercontent.com/alice-xu/bf89c5f1174a3e793ff8/raw/316719f654f4b95b3277c4bc08f210c3fdce2bcd/zbx_functions wget https://gist.githubusercontent.com/alice-xu/2cfd97766cf61c1d1ba4/raw/3d87c94db64fdcd60b072e2500d2e317aa7d3178/openvpn_stats.sh chmod a+x openvpn_stats.sh * 測試 zabbix script - openvpn_stats.sh /usr/local/bin/openvpn_stats.sh [root@openvpn bin]# /usr/local/bin/openvpn_stats.sh SUCCESS: nclients=7,bytesin=204069,bytesout=208556 zabbix_sender [2861]: DEBUG: answer [{"response":"success","info":"processed: 0; failed: 3; total: 3; seconds spent: 0.000113"}] info from server: "processed: 0; failed: 3; total: 3; seconds spent: 0.000113" sent: 3; skipped: 0; total: 3 * 設定每分鐘回報一次 vi /etc/crontab : # Zabbix - openvpn * * * * * root /usr/local/bin/openvpn_stats.sh > /tmp/openvpn_stats.log : service crond restart ==== @Zabbix Server 設定程序 ===== * 下載 [[https://gist.githubusercontent.com/alice-xu/c0831c26f8ac86f51779/raw/197206b4e44461d872683c74860250a8e8a1196e/zabbix_custom_template_for_OpenVPN.xml|zabbix_custom_template_for_OpenVPN.xml]] * 將 zabbix_custom_template_for_OpenVPN.xml 匯入至 Zabbix Server → Configuration → Templates → Import ===== 參考網址 ===== * https://gist.github.com/alice-xu * https://gist.github.com/alice-xu/2cfd97766cf61c1d1ba4 * https://gist.github.com/alice-xu/bf89c5f1174a3e793ff8 * https://gist.github.com/alice-xu/c0831c26f8ac86f51779 * https://openvpn.net/index.php/open-source/documentation/howto.html#server {{tag>openvpn zabbix}}