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)关闭SELINUX
setenforce 0 sed -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.repo sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo wget -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.rpm yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
启用remi-php72源
yum install yum-utils yum-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 /opt tar -zxf observium-community-latest.tar.gz
3、MariaDB数据库设置
1)MariaDB数据库服务启动,密码初始化
systemctl enable mariadb systemctl start mariadb /usr/bin/mysqladmin -u root password 'MySQL@2021'
2)创建observium数据库,并设置observium库的账号与密码
mysql -uroot -pMySQL@2021 CREATE 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.php vi 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/fping vi config.php $config['fping'] = "/usr/sbin/fping";
5、rrd及httpd服务相关配置
1)Create the rrd directory to store RRDs in:
cd /opt/observium mkdir rrd chown 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 apache
mkdir /opt/observium/logs chown apache:apache /opt/observium/logs
6、设置observium crond定时任务脚本
vi /etc/cron.d/observium # Run a complete discovery of all devices once every 6 hours 33 */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 log 13 5 * * * root /opt/observium/housekeeping.php -ysel # Run housekeeping script daily for rrds, ports, orphaned entries in the database and performance data 47 4 * * * root /opt/observium/housekeeping.php -yrptb systemctl reload crond
7、web管理员用户添加并开启httpd服务
./adduser.php admin admin2021 10 systemctl enable httpd systemctl start httpd firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --reload
8、监控主机snmpd服务安装与配置
监控主机上安装并配置snmpd服务
yum install net-snmp net-snmp-utils systemctl enable snmpd vi /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,China cat /etc/snmp/snmpd.conf | grep systemview cat /etc/snmp/snmpd.conf | grep syslocation systemctl start snmpd netstat -anp | grep 161 firewall-cmd --permanent --zone=public --add-service=snmp firewall-cmd --reload
9、登录web界面,并添加监控设备
当然你可也可以后台用命令添加
./add_device.php <hostname> <community> v2c Do 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.84 systemctl restart rsyslog
日志监控效果展示