Observium是一个免费的开源网络管理和监控工具,可用于监控所有的网络设备,特别是交换机等网络设备。 它是用PHP编写的,使用SNMP从连接的设备收集数据并使用Web界面监视它们。 Observium支持大量的网络硬件和操作系统,包括Linux,Windows,FreeBSD,思科,戴尔,NetApp等等。 Observium提供了一个功能强大,简单易用的界面来监视网络的健康和状态,只是没有中文版本,比较遗憾。
首先运行以下命令,将系统更新到最新的稳定版本:
apt-get update -y
apt-get upgrade -y
系统更新后,重新启动系统以应用所有更新:
reboot
重新启动后,使用root用户登录并通过运行以下命令将一些必需的软件包安装到您的系统中:
apt-get install snmp fping python-mysqldb rrdtool subversion whois mtr-tiny ipmitool graphviz imagemagick -y
一旦安装了所有必需的软件包,就可以继续下一步。
Observium运行在Apache上,用PHP语言编写,并使用MySQL作为数据库。 所以你需要在你的系统上安装LAMP服务器。
首先,运行以下命令来安装Apache Web服务器:
apt-get install apache2 libapache2-mod-php7.0 -y
安装Apache之后,启动Apache服务并使用以下命令在启动时启动它:
systemctl start apache2
systemctl enable apache2
接下来,通过运行以下命令来安装PHP7和其他所需的库:
apt-get install php7.0 php7.0-cli php7.0-mysql php7.0-mysqli php7.0-gd php7.0-mcrypt php7.0-json php-pear -y
一旦安装了PHP7和所有必需的库,运行以下命令来安装MariaDB服务器:
apt-get install mariadb-server -y
接下来,启动MariaDB服务并使用以下命令在启动时启动它:
systemctl start mysql
systemctl enable mysql
默认情况下,MariaDB不安全。 您可以使用以下命令来保护它:
mysql_secure_installation
回答所有问题如下:
set root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
set root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
一旦MariaDB得到保护,您将需要为Observium创建一个数据库和用户。
首先,使用以下命令登录到MySQL shell:
mysql -u root -p
输入您的root密码,然后使用以下命令为Observium创建一个数据库:
MariaDB [(none)]>CREATE DATABASE observiumdb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
接下来,为Observium创建一个用户,并使用以下命令将所有权限授予Observium数据库:
MariaDB [(none)]>GRANT ALL PRIVILEGES ON observiumdb.* TO 'observium'@'localhost' IDENTIFIED BY 'password';
接下来,使用以下命令刷新权限:
MariaDB [(none)]>FLUSH PRIVILEGES;
最后,使用以下命令退出MySQL shell:
MariaDB [(none)]>\q
Observium有两个版本:开源版本和订阅版本,开放源代码版本可以免费下载,功能较少,安全修复程度较低,而订阅版本则附带额外的功能和硬件支持。 您可以使用以下命令从官方网站下载Observium的开源版本:
wget http://www.observium.org/observium-community-latest.tar.gz
下载后,使用以下命令提取下载的存档:
tar -xvzf observium-community-latest.tar.gz
接下来,将提取的目录复制到Apache Web根目录:
cp -ar observium /var/www/html/
接下来,重命名示例配置文件并进行一些更改:
cd /var/www/html/observium
cp config.php.default config.php
nano config.php
如下所示更改文件:
// Database config --- This MUST be configured
$config['db_extension'] = 'mysqli';
$config['db_host'] = 'localhost';
$config['db_user'] = 'observium';
$config['db_pass'] = 'password';
$config['db_name'] = 'observiumdb';
// Database config --- This MUST be configured
$config['db_extension'] = 'mysqli';
$config['db_host'] = 'localhost';
$config['db_user'] = 'observium';
$config['db_pass'] = 'password';
$config['db_name'] = 'observiumdb';
保存文件,然后使用以下命令设置MySQL数据库的默认模式:
./discovery.php -u
如果一切正常,你应该看到下面的输出:
___ _ _
/ _ \ | |__ ___ ___ _ __ __ __(_) _ _ _ __ ___
| | | || '_ \ / __| / _ \| '__|\ \ / /| || | | || '_ ` _ \
| |_| || |_) |\__ \| __/| | \ V / | || |_| || | | | | |
\___/ |_.__/ |___/ \___||_| \_/ |_| \__,_||_| |_| |_|
Observium Community Edition 17.9.0
http://www.observium.org
Install initial database schema ... done.
-- Updating database/file schema
310 -> 311 # (db) . Done (0s).
311 -> 312 # (db) .... Done (0s).
312 -> 313 # (db) Done (0s).
313 -> 314 # (db) Done (0s).
314 -> 315 # (php) . Done (0s).
315 -> 316 # (db) . Done (0s).
316 -> 317 # (db) .. Done (0s).
317 -> 318 # (db) . Done (0s).
318 -> 319 # (db) ....... Done (2s).
319 -> 320 # (db) . Done (0s).
320 -> 321 # (db) . Done (0s).
321 -> 322 # (db) . Done (0s).
322 -> 323 # (db) ... Done (1s).
323 -> 324 # (db) ... Done (0s).
324 -> 325 # (db) .... Done (1s).
325 -> 326 # (db) . Done (0s).
326 -> 327 # (db) . Done (0s).
327 -> 328 # (db) . Done (0s).
328 -> 329 # (db) . Done (0s).
329 -> 330 # (db) . Done (0s).
330 -> 331 # (db) . Done (0s).
331 -> 332 # (db) ... Done (1s).
332 -> 333 # (php) Done (0s).
333 -> 334 # (db) . Done (0s).
334 -> 335 # (php) Done (0s).
335 -> 336 # (db) . Done (0s).
336 -> 337 # (db) . Done (1s).
337 -> 338 # (db) . Done (0s).
338 -> 339 # (db) ... Done (0s).
339 -> 340 # (db) ... Done (0s).
340 -> 341 # (db) ........ Done (1s).
341 -> 342 # (db) ............... Done (0s).
342 -> 343 # (db) ... Done (0s).
343 -> 344 # (db) .... Done (1s).
344 -> 345 # (db) .. Done (0s).
345 -> 346 # (db) . Done (0s).
346 -> 347 # (db) . Done (0s).
347 -> 348 # (db) F Done (0s, 1 errors).
348 -> 349 # (db) .. Done (0s).
349 -> 350 # (php) Done (0s).
350 -> 351 # (db) ..... Done (1s).
351 -> 352 # (db) .. Done (0s).
-- Done.
/ _ \ | |__ ___ ___ _ __ __ __(_) _ _ _ __ ___
| | | || '_ \ / __| / _ \| '__|\ \ / /| || | | || '_ ` _ \
| |_| || |_) |\__ \| __/| | \ V / | || |_| || | | | | |
\___/ |_.__/ |___/ \___||_| \_/ |_| \__,_||_| |_| |_|
Observium Community Edition 17.9.0
http://www.observium.org
Install initial database schema ... done.
-- Updating database/file schema
310 -> 311 # (db) . Done (0s).
311 -> 312 # (db) .... Done (0s).
312 -> 313 # (db) Done (0s).
313 -> 314 # (db) Done (0s).
314 -> 315 # (php) . Done (0s).
315 -> 316 # (db) . Done (0s).
316 -> 317 # (db) .. Done (0s).
317 -> 318 # (db) . Done (0s).
318 -> 319 # (db) ....... Done (2s).
319 -> 320 # (db) . Done (0s).
320 -> 321 # (db) . Done (0s).
321 -> 322 # (db) . Done (0s).
322 -> 323 # (db) ... Done (1s).
323 -> 324 # (db) ... Done (0s).
324 -> 325 # (db) .... Done (1s).
325 -> 326 # (db) . Done (0s).
326 -> 327 # (db) . Done (0s).
327 -> 328 # (db) . Done (0s).
328 -> 329 # (db) . Done (0s).
329 -> 330 # (db) . Done (0s).
330 -> 331 # (db) . Done (0s).
331 -> 332 # (db) ... Done (1s).
332 -> 333 # (php) Done (0s).
333 -> 334 # (db) . Done (0s).
334 -> 335 # (php) Done (0s).
335 -> 336 # (db) . Done (0s).
336 -> 337 # (db) . Done (1s).
337 -> 338 # (db) . Done (0s).
338 -> 339 # (db) ... Done (0s).
339 -> 340 # (db) ... Done (0s).
340 -> 341 # (db) ........ Done (1s).
341 -> 342 # (db) ............... Done (0s).
342 -> 343 # (db) ... Done (0s).
343 -> 344 # (db) .... Done (1s).
344 -> 345 # (db) .. Done (0s).
345 -> 346 # (db) . Done (0s).
346 -> 347 # (db) . Done (0s).
347 -> 348 # (db) F Done (0s, 1 errors).
348 -> 349 # (db) .. Done (0s).
349 -> 350 # (php) Done (0s).
350 -> 351 # (db) ..... Done (1s).
351 -> 352 # (db) .. Done (0s).
-- Done.
接下来,您将需要创建一个目录来存储RRD和日志:
mkdir rrd logs
使用以下命令更改observium目录的所有权:
chown -R www-data:www-data /var/www/html/observium
接下来,您将需要为Observium创建一个Apache虚拟主机文件。 为此,创建一个新的配置文件observium.conf:
nano /etc/apache2/sites-available/observium.conf
添加以下行:
ServerAdmin [email protected] ServerName example.com DocumentRoot /var/www/html/observium/html Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted ErrorLog /var/log/apache2/error.log LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On ServerAdmin [email protected] ServerName example.com DocumentRoot /var/www/html/observium/html Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted ErrorLog /var/log/apache2/error.log LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On
保存该文件,然后启用observium虚拟主机文件并使用以下命令禁用默认虚拟主机文件:
a2ensite observium
a2dissite 000-default
接下来,您还需要启用Apache重写模块和PHP mcrypt模块。 您可以通过运行以下命令来执行此操作:
a2enmod rewrite
phpenmod mcrypt
最后,使用以下命令重新启动Apache Web服务器:
systemctl restart apache2
接下来,使用以下命令创建您的第一个管理员用户:
/var/www/html/observium/adduser.php admin yourpassword 10
如果一切正常,您应该看到以下输出:
Observium CE 0.17.7.8697
Add User
User admin added successfully.
Observium CE 0.17.7.8697
Add User
User admin added successfully.
在访问Observium之前,您需要通过UFW防火墙允许端口80。 默认情况下,UFW没有安装在Debian 9上,所以你需要先安装它。
apt-get install ufw -y
一旦安装了UFW,使用以下命令启用UFW:
ufw enable
接下来,使用以下命令通过UFW防火墙允许端口80:
ufw allow 80
一旦配置了防火墙,打开您的网络浏览器并键入URL http://example.com,您应该看到以下页面:
在这里,输入您的管理员用户名和密码,然后点击登录按钮,您应该看到Observium默认仪表板如下:
接下来,您将需要创建一个cron作业来轮询和发现来自网络的设备。 你可以通过在/etc/cron.d目录下创建一个cron文件来完成这个工作:
nano /etc/cron.d/observium
添加以下行:
# Run a complete discovery of all devices once every 2 hours
25 */2 * * * root /var/www/html/observium/discovery.php -h all >> /dev/null 2>&1
# Run automated discovery of newly added devices every 10 minutes
*/10 * * * * root /var/www/html/observium/discovery.php -h new >> /dev/null 2>&1
# Run multithreaded poller wrapper every 10 minutes
*/10 * * * * root /var/www/html/observium/poller-wrapper.py 4 >> /dev/null 2>&1
# Run housekeeping script daily for syslog, eventlog and alert log
10 2 * * * root /var/www/html/observium/housekeeping.php -ysel >> /dev/null 2>&1
# Run housekeeping script daily for rrds, ports, orphaned entries in the database and performance data
10 1 * * * root /var/www/html/observium/housekeeping.php -yrptb >> /dev/null 2>&1
25 */2 * * * root /var/www/html/observium/discovery.php -h all >> /dev/null 2>&1
# Run automated discovery of newly added devices every 10 minutes
*/10 * * * * root /var/www/html/observium/discovery.php -h new >> /dev/null 2>&1
# Run multithreaded poller wrapper every 10 minutes
*/10 * * * * root /var/www/html/observium/poller-wrapper.py 4 >> /dev/null 2>&1
# Run housekeeping script daily for syslog, eventlog and alert log
10 2 * * * root /var/www/html/observium/housekeeping.php -ysel >> /dev/null 2>&1
# Run housekeeping script daily for rrds, ports, orphaned entries in the database and performance data
10 1 * * * root /var/www/html/observium/housekeeping.php -yrptb >> /dev/null 2>&1
完成后保存并关闭文件,然后重新启动cron服务以应用此更改:
systemctl restart cron
发现新设备:
./discovery.php -h 192.168.10.68
./add_device.php 192.168.10.68 public v2c
./poller.php -h 192.168.10.68