大家好,我是民工哥。
一提到监控零碎,大家很快就能想到Zabbix、Prometheus等,明天,民工哥给大家举荐一款绝不逊色 Zabbix 的监控软件 Librenms。
LibreNMS 介绍
LibreNMS是一个全功能的开源网络监控零碎。它用于SNMP从不同设施获取数据。LibreNMS反对各种设施,如Cisco,Linux,FreeBSD,Juniper,Brocade,Foundry,HP等。它反对多种认证机制并反对双因素认证。它有一个可定制的警报系统,能够通过电子邮件揭示网络管理员
github:https://github.com/librenms/l...
LibreNMS 特点
- 主动发现
- 警示
- 多种环境传感器反对
- 多种协定数据收集(STP,OSPF,BGP等)
- VLAN,ARP和FDB表收集
- 可定制的仪表板
- 设施集成备份
- 分布式轮询
- 多种身份验证办法(MySQL,LDAP,Active Directory,HTTP)
- NetFlow,sFlow,IPFIX(NfSen)
- 服务监控(Nagios插件)
- Syslog(集成,Graylog)
- 流量计费
- 两因素认证
- 弱小的API
- 自动更新
LibreNMS 装置
- 环境
- 请留神,最低反对的PHP版本是7.3
- 倡议应用Nginx 作为web服务器
装置必须的软件包
yum install epel-release yum-utilsyum localinstall http://rpms.remirepo.net/enterprise/remi-release-7.rpmyum-config-manager --enable remi-php73yum install composer cronie fping git ImageMagick jwhois mariadb mariadb-server mtr MySQL-python net-snmp net-snmp-utils nginx nmap php-fpm php-cli php-common php-curl php-gd php-mbstring php-process php-snmp php-xml php-zip php-memcached php-mysqlnd python-memcached rrdtool python3 python3-pip
增加librenms用户
useradd librenms -d /opt/librenms -M -rusermod -a -G librenms nginx
下载LibreNMS
cd /optgit clone https://github.com/librenms/librenms.git
设定权限
chown -R librenms:librenms /opt/librenmschmod 770 /opt/librenmssetfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/chgrp apache /var/lib/php/session/
装置PHP依赖项
su - librenms./scripts/composer_wrapper.php install --no-devexit
数据库服务器
#配置MySQLsystemctl start mariadbmysql -u root#更改初始密码CREATE DATABASE librenms CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password';GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';FLUSH PRIVILEGES;exitvi /etc/my.cnf在此[mysqld]局部中,请增加:innodb_file_per_table=1lower_case_table_names=0systemctl enable mariadbsystemctl restart mariadb
配置并启动PHP-FPM
确保在php.ini中将date.timezone设置为您首选的时区,具体时区请参考:https://php.net/manual/en/tim...
vi /etc/php.ini date.timezone = Asia/Shanghai
在进行/etc/php-fpm.d/www.conf以下更改
vi /etc/php-fpm.d/www.conf;user = apacheuser = nginxgroup = apache ; keep group as apache;listen = 127.0.0.1:9000listen = /run/php-fpm/php-fpm.socklisten.owner = nginxlisten.group = nginxlisten.mode = 0660systemctl enable php-fpmsystemctl restart php-fpm
配置NGINX
vi /etc/nginx/conf.d/librenms.conf增加以下配置,server_name依据须要进行编辑:server { listen 80; server_name librenms.example.com; root /opt/librenms/html; index index.php; charset utf-8; gzip on; gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon; location / { try_files $uri $uri/ /index.php?$query_string; } location /api/v0 { try_files $uri $uri/ /api_v0.php?$query_string; } location ~ \.php { include fastcgi.conf; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/run/php-fpm/php-fpm.sock; } location ~ /\.ht { deny all; }}systemctl enable nginxsystemctl restart nginx
配置LibreNMS所需的上下文
semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/logs(/.*)?'semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/logs(/.*)?'restorecon -RFvv /opt/librenms/logs/semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/rrd(/.*)?'semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/rrd(/.*)?'restorecon -RFvv /opt/librenms/rrd/semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/storage(/.*)?'semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/storage(/.*)?'restorecon -RFvv /opt/librenms/storage/semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/bootstrap/cache(/.*)?'semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/bootstrap/cache(/.*)?'restorecon -RFvv /opt/librenms/bootstrap/cache/setsebool -P httpd_can_sendmail=1setsebool -P httpd_execmem 1
容许fping
应用以下内容创立文件http_fping.tt。您能够在任何中央创立此文件,因为它是一次性文件。此装置过程的最初一步将把模块装置在正确的地位。
module http_fping 1.0;require {type httpd_t;class capability net_raw;class rawip_socket { getopt create setopt write read };}#============= httpd_t ==============allow httpd_t self:capability net_raw;allow httpd_t self:rawip_socket { getopt create setopt write read };
而后运行这些命令
checkmodule -M -m -o http_fping.mod http_fping.ttsemodule_package -o http_fping.pp -m http_fping.modsemodule -i http_fping.pp
配置snmpd
cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.confvi /etc/snmp/snmpd.conf编辑显示的文字RANDOMSTRINGGOESHERE并设置您本人的社区字符串。curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distrochmod +x /usr/bin/distrosystemctl enable snmpdsystemctl restart snmpd
Cron job
cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms
logrotate 配置
LibreNMS保留日志/opt/librenms/logs。随着工夫的流逝,它们可能会变大并向外旋转。要轮换出旧日志,能够应用提供的logrotate配置文件。
cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms
Web装置
浏览器输出 http://librenms.example.com/i... 进行装置
Web安装程序可能会提醒config.php在librenms装置地位须要手动创立文件,这时将Web上显示的内容复制到该文件。而后设置权限。
chown librenms:librenms /opt/librenms/config.php
LibreNMS 界面
首页界面增加设施
创立组
设施列表
启用发现模块
流量监控
磁盘监控
网络图
LibreNMS图表
API 配置
报警规定
往期举荐:
零碎之眼!Linux零碎性能监控工具Glances
界面酷炫,功能强大!这款 Linux 性能实时监控工具超好用!