当前位置:主页 > 查看内容

挺带劲!这款免费开源的监控系统真强大~

发布时间:2021-04-28 00:00| 位朋友查看

简介:大家好,我是民工哥。 一提到监控系统,大家很快就能想到 Zabbix 、 Prometheu s等,今天,民工哥给大家推荐一款绝 不逊色?Zabbix 的监控软件 Librenms 。 LibreNMS 介绍 LibreNMS是一个 全功能的开源网络监控系统 。它用于SNMP从不同设备获取数据。LibreNMS……

大家好,我是民工哥。

一提到监控系统,大家很快就能想到ZabbixPrometheus等,今天,民工哥给大家推荐一款绝不逊色?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-utils

yum localinstall http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum-config-manager --enable remi-php73

yum 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?-r
usermod?-a?-G?librenms?nginx

下载LibreNMS

cd?/opt

git?clone?https://github.com/librenms/librenms.git

设定权限

chown -R librenms:librenms /opt/librenms
chmod 770 /opt/librenms
setfacl -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-dev
exit

数据库服务器

#配置MySQL
systemctl start mariadb
mysql -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;
exit

vi /etc/my.cnf
在此[mysqld]部分中,请添加:
innodb_file_per_table=1
lower_case_table_names=0

systemctl enable mariadb
systemctl 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 = apache
user = nginx

group = apache   ; keep group as apache

;listen = 127.0.0.1:9000
listen = /run/php-fpm/php-fpm.sock

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

systemctl enable php-fpm
systemctl 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 nginx
systemctl 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=1
setsebool -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.tt
semodule_package -o http_fping.pp -m http_fping.mod
semodule -i http_fping.pp

配置snmpd

cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf

vi /etc/snmp/snmpd.conf

编辑显示的文字RANDOMSTRINGGOESHERE并设置您自己的社区字符串。
curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x /usr/bin/distro
systemctl enable snmpd
systemctl 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 界面

首页界面图片添加设备

图片

创建组

图片

设备列表

图片

启用发现模块

image.png

流量监控

image.png

磁盘监控

图片

网络图

图片

图片

LibreNMS图表

图片

API 配置

图片

报警规则

图片

往期推荐:

系统之眼!Linux系统性能监控工具Glances

界面酷炫,功能强大!这款 Linux 性能实时监控工具超好用!


本文转自网络,版权归原作者所有,原文链接:https://segmentfault.com/a/1190000039916821
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文

  • 周排行
  • 月排行
  • 总排行

随机推荐