Observium簡單介紹
Observium是一個免費的開源網路管理和監控工具,可用於監控所有的網路裝置。
Observium是用PHP編寫的,使用SNMP從連線的裝置收集資料並使用Web介面監視它們。
Observium支援大量的網路硬體和作業系統,包括Linux,Windows,FreeBSD,思科,戴爾,NetApp等等。
Observium提供了一個功能強大,簡單易用的介面來監視網路的健康和狀態
(圖片可放大檢視)
目前有兩種不同的 observium 版本。
1、Observium 社群版本是一個在 QPL 開源許可證下的免費工具,這個版本是對於較小部署的最好解決方案。該版本每6個月進行一次安全性更新。
2、第2個版本是 Observium 專業版,該版本採用基於 SVN 的釋出機制。會得到每日安全性更新。該工具適用於服務提供商和企業級部署
CentOS7下部署開源網路監控工具Observium下面介紹CentOS7下部署開源網路管理和監控工具Observium
環境說明:
1、CentOS7.9 VM虛擬機器192.168.31.84部署Observium,作為服務端
2、CentOS7.9 VM虛擬機器192.168.31.121監控主機,作為Observium的被監控裝置
具體部署步驟如下1、基礎環境準備1)關閉SELINUXsetenforce 0sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
2)yum源配置
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.reposed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repowget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
新增opennms-repo和remi源
yum -y install http://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpmyum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
啟用remi-php72源
yum install yum-utilsyum-config-manager --enable remi-php72
yum安裝Observium所需元件httpd,php72,net-snmp,fping,mariadb-server,rrdtool,ipmitool等等
yum install wget.x86_64 httpd.x86_64 php.x86_64 php-opcache.x86_64 php-mysql.x86_64 php-gd.x86_64 \ php-posix php-pear.noarch cronie.x86_64 net-snmp.x86_64 net-snmp-utils.x86_64 \ fping.x86_64 mariadb-server.x86_64 mariadb.x86_64 MySQL-python.x86_64 rrdtool.x86_64 \ subversion.x86_64 jwhois.x86_64 ipmitool.x86_64 graphviz.x86_64 ImageMagick.x86_64 \ php-sodium.x86_64
2、下載observium社群版本最新安裝包並解壓下載地址
http://www.observium.org/observium-community-latest.tar.gz
建立/opt/observium目錄,並將社群版本安裝包解壓到此路徑
mkdir -p /opt/observium && cd /opttar -zxf observium-community-latest.tar.gz
3、MariaDB資料庫設定1)MariaDB資料庫服務啟動,密碼初始化
systemctl enable mariadbsystemctl start mariadb/usr/bin/mysqladmin -u root password 'MySQL@2021'
2)建立observium資料庫,並設定observium庫的賬號與密碼
mysql -uroot -pMySQL@2021CREATE DATABASE observium DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;GRANT ALL PRIVILEGES ON observium.* TO 'observium'@'localhost' IDENTIFIED BY 'observium@2021';exit;
3)修改config.php中資料庫連線引數cp config.php.default config.phpvi config.php修改資料庫的賬戶與密碼為上面設定的mariadb的賬戶與密碼$config['db_user'] = 'observium';$config['db_pass'] = 'observium@2021';
4)Insert MySQL Schema
./discovery.php -u
4、在config.php中新增fping工具配置
which fping/usr/sbin/fpingvi config.php$config['fping'] = "/usr/sbin/fping";
5、rrd及httpd服務相關配置1)Create the rrd directory to store RRDs in:cd /opt/observiummkdir rrdchown apache:apache rrd
2)httpd服務配置檔案新增與修改
vi /etc/httpd/conf.d/observium.conf <VirtualHost *> DocumentRoot /opt/observium/html/ ServerName observium.domain.com CustomLog /opt/observium/logs/access_log combined ErrorLog /opt/observium/logs/error_log <Directory "/opt/observium/html/"> AllowOverride All Options FollowSymLinks MultiViews Require all granted </Directory></VirtualHost>
3)Create logs directory for apachemkdir /opt/observium/logschown apache:apache /opt/observium/logs
6、設定observium crond定時任務指令碼
vi /etc/cron.d/observium# Run a complete discovery of all devices once every 6 hours33 */6 * * * root /opt/observium/discovery.php -h all >> /dev/null 2>&1# Run automated discovery of newly added devices every 5 minutes*/5 * * * * root /opt/observium/discovery.php -h new >> /dev/null 2>&1# Run multithreaded poller wrapper every 1 minutes*/1 * * * * root /opt/observium/poller-wrapper.py >> /dev/null 2>&1# Run housekeeping script daily for syslog, eventlog and alert log13 5 * * * root /opt/observium/housekeeping.php -ysel# Run housekeeping script daily for rrds, ports, orphaned entries in the database and performance data47 4 * * * root /opt/observium/housekeeping.php -yrptbsystemctl reload crond
7、web管理員使用者新增並開啟httpd服務./adduser.php admin admin2021 10
systemctl enable httpdsystemctl start httpdfirewall-cmd --permanent --zone=public --add-service=httpfirewall-cmd --reload
8、監控主機snmpd服務安裝與配置
監控主機上安裝並配置snmpd服務
yum install net-snmp net-snmp-utilssystemctl enable snmpdvi /etc/snmp/snmpd.conf
1)OID修改
原先view systemview included .1.3.6.1.2.1.1修改為view systemview included .1.3.6.1.2.1
2)系統位置資訊修改syslocation Unknown (edit /etc/snmp/snmpd.conf)#syslocation Unknown (edit /etc/snmp/snmpd.conf)syslocation HangZhou,Zhejiang,Chinacat /etc/snmp/snmpd.conf | grep systemviewcat /etc/snmp/snmpd.conf | grep syslocation
systemctl start snmpdnetstat -anp | grep 161firewall-cmd --permanent --zone=public --add-service=snmpfirewall-cmd --reload
9、登入web介面,並新增監控裝置
(圖片可放大檢視)
(圖片可放大檢視)
(圖片可放大檢視)
當然你可也可以後臺用命令新增
./add_device.php <hostname> <community> v2cDo an initial discovery and polling run to populate the data for the new device:
拉取裝置資料
./discovery.php -h all./poller.php -h all
監控效果展示
(圖片可放大檢視)
(圖片可放大檢視)
(圖片可放大檢視)
(圖片可放大檢視)
10、syslog日誌監控功能啟用config.php最後行加入
// Enable Syslog$config['enable_syslog'] = 1;
observium伺服器開啟rsyslog接收,並配置接收的配置檔案
監控主機開啟rsyslog外送
vi /etc/rsyslog.conf最後行新增*.* @192.168.31.84systemctl restart rsyslog
日誌監控效果展示
(圖片可放大檢視)
(圖片可放大檢視)