Rocky Linux 9.5 LibreNMS 優化及Plugins安裝
RRDCached
ln -s /opt/librenms/dist/rrdcached/rrdcached.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now rrdcached.service
su librenms
lnms config:set rrdcached "unix:/run/rrdcached.sock"
編輯/opt/librenms/config.php將下列一行的#移除
#$config['rrdcached'] = "unix:/var/run/rrdcached.sock";
安裝SyslogNG
dnf install syslog-ng
編輯 /etc/syslog-ng/conf.d/librenms.conf,貼上下面設定
source s_net {
tcp(port(514) flags(syslog-protocol));
udp(port(514) flags(syslog-protocol));
};
destination d_librenms {
program("/opt/librenms/syslog.php" template ("$HOST||$FACILITY||$PRIORITY||$LEVEL||$TAG||$R_YEAR-$R_MONTH-$R_DAY $R_HOUR:$R_MIN:$R_SEC||$MSG||$PROGRAM\n") template-escape(yes));
};
log {
source(s_net);
source(s_sys);
destination(d_librenms);
};
重新啟動服務
service syslog-ng restart
su librenms
lnms config:set enable_syslog true
安裝Nagios Plugins
# 建立 nagios 群組
sudo groupadd nagios
# 建立 nagios 使用者並加入群組
sudo useradd -r -s /sbin/nologin -g nagios nagios
# 安裝必要工具
sudo dnf install gcc make autoconf automake openssl-devel net-snmp net-snmp-utils
# 下載原始碼
cd /temp
wget https://github.com/nagios-plugins/nagios-plugins/releases/download/release-2.4.12/nagios-plugins-2.4.12.tar.gz
tar -xzf nagios-plugins-2.4.12.tar.gz
cd nagios-plugins-release-2.4.9
# 編譯與安裝
./tools/setup
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
# 安裝完成,因為常用所以把它連結到 /opt
ln -s /usr/local/nagios/libexec /opt/nagios
編輯 /opt/librenms/config.php,設定 nagios plugins路徑
vim /opt/librenms/config.php
#增加
$config['show_services'] = 1;
$config['nagios_plugins'] = "/usr/local/nagios/libexec";
編輯 /etc/cron.d/librenms
vim /etc/cron.d/librenms
#增加服務檢查
*/5 * * * * librenms /opt/librenms/services-wrapper.py 1