挺帶勁!這款免費開源的監控系統真強大~

你們好,我是民工哥。javascript

一提到監控系統,你們很快就能想到ZabbixPrometheus等,今天,民工哥給你們推薦一款絕不遜色 Zabbix 的監控軟件 Librenmsphp

圖片

LibreNMS 介紹

LibreNMS是一個全功能的開源網絡監控系統。它用於SNMP從不一樣設備獲取數據。LibreNMS支持各類設備,如Cisco,Linux,FreeBSD,Juniper,Brocade,Foundry,HP等。它支持多種認證機制並支持雙因素認證。它有一個可定製的警報系統,能夠經過電子郵件提醒網絡管理員css

github:https://github.com/librenms/l...html

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用戶java

useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms nginx

下載LibreNMSpython

cd /opt

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

設定權限mysql

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依賴項ios

su - librenms
./scripts/composer_wrapper.php install --no-dev
exit

數據庫服務器nginx

#配置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-FPMgit

確保在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 性能實時監控工具超好用!

相關文章
相關標籤/搜索