CentOS7下部署开源网络监控工具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
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
yum install yum-utils
yum-config-manager --enable remi-php72
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
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服务安装与配置
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日志监控功能启用
// Enable Syslog
$config['enable_syslog'] = 1;
vi /etc/rsyslog.conf
最后行添加
*.* @192.168.31.84
systemctl restart rsyslog
原文始发于微信公众号(释然IT杂谈):CentOS7下部署开源网络监控工具Observium
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论