Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。用来监控网络流量、cpu使用率、内存使用率、硬盘使用率等。可以直观的监控各种数据流量,可以安装扩展插件,同时支持短信邮件告警等功能。
Nagios是一个监视系统运行状态和网络信息的监视系统。Nagios能监视所指定的本地或远程主机以及服务,提供异常通知功能,同时还可以安装各种模块插件,自定义监控脚本等。
两者区别:Cacti偏重于网络流量,系统负载方面的监控。而 Nagios偏重于系统服务方面的监控,你可以在被监控的机器上写自己的程序(shell,c 或 perl都可以) 。Nagios则通过这些脚本来对服务进行监控。Nagios可以和短信发送机配合用来监控规模较大的网站。
1 2 3 4 5 6 7 | [root@www ~]
Retrieving http: //mirrors .yun-idc.com /epel/6/i386/epel-release-6-8 .noarch.rpm
warning: /var/tmp/rpm-tmp .1jSHmn: Header V3 RSA /SHA256 Signature, key ID 0608b895: NOKEY
Preparing...
1:epel-release
[root@www ~]
/etc/yum .repos.d /epel .repo /etc/yum .repos.d /epel-testing .repo
|
##########CACTI#########
一、安装LAMP环境
二、安装net-snmp、php-snmp、net-snmp-utils
三、安装rrdtool图形整合工具
1 2 3 4 5 6 7 8 9 10 11 | [root@www ~]
[root@www ~]
RRDtool 1.3.8 Copyright 1997-2009 by Tobias Oetiker <tobi@oetiker.ch>
Compiled Apr 3 2014 13:07:03
Usage: rrdtool [options] command command_options
Valid commands: create, update, updatev, graph, graphv, dump, restore,
last, lastupdate, first, info, fetch, tune,
resize, xport
RRDtool is distributed under the Terms of the GNU General
Public License Version 2. (www.gnu.org /copyleft/gpl .html)
For more information read the RRD manpages
|
四、安装cacti主程序
[root@www ~]# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz
[root@www ~]# tar zxf cacti-0.8.8f.tar.gz
[root@www ~]# mv cacti-0.8.8f /var/www/html/cacti/
[root@www ~]# chown -R root. /var/www/html/cacti/
[root@www ~]# /etc/init.d/mysqld start
1 2 3 4 5 6 7 | [root@www ~]
Enter current password for root (enter for none):
Set root password? [Y /n ] y
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
|
1 2 | [root@www ~]
[root@www ~]
|
1 2 3 4 5 6 7 8 | [root@www ~]
$database_type = "mysql" ;
$database_default = "cacti" ;
$database_hostname = "localhost" ;
$database_username = "cacti" ;
$database_password = "cactipass" ;
$database_port = "3306" ;
$database_ssl = false ;
|
1 2 3 | [root@www ~]
[root@www ~]
[root@www ~]
|
1 2 | [root@www ~]
date .timezone = 'Asia/Shanghai'
|
1 2 3 | [root@www ~]
[root@www ~]
* /5 * * * * /usr/bin/php /var/www/html/cacti/poller .php
|
五、Web界面安装和配置cacti





六、安装cacti优化轮询器spine
[root@www ~]# wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8f.tar.gz
[root@www ~]# yum -y install gcc
[root@www ~]# tar zxf cacti-spine-0.8.8f.tar.gz
[root@www ~]# cd cacti-spine-0.8.8f
1 2 3 4 5 6 7 8 9 10 11 12 13 | [root@www cacti-spine-0.8.8f]
[root@www cacti-spine-0.8.8f]
gcc -DHAVE_CONFIG_H -I. -I. /config -I /usr/include/mysql -g -O2 -MT sql.o -MD -MP -MF .deps /sql .Tpo -c -o sql.o sql.c
In file included from sql.c:34:
common.h:133:38: error: net-snmp /net-snmp-config .h: No such file or directory
common.h:134:32: error: net-snmp /utilities .h: No such file or directory
common.h:135:40: error: net-snmp /net-snmp-includes .h: No such file or directory
common.h:136:33: error: net-snmp /config_api .h: No such file or directory
common.h:137:30: error: net-snmp /mib_api .h: No such file or directory
In file included from spine.h:505,
from sql.c:35:
snmp.h:41: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
make : *** [sql.o] Error 1
|
1 2 | [root@www cacti-spine-0.8.8f]
[root@www cacti-spine-0.8.8f]
|
1 2 3 4 5 6 7 8 9 10 11 12 | [root@www cacti-spine-0.8.8f]
[root@www cacti-spine-0.8.8f]
make [1]: Entering directory ` /root/cacti-spine-0 .8.8f'
/bin/mkdir -p '/usr/local/spine/bin'
/bin/sh . /libtool --mode= install /usr/bin/install -c spine '/usr/local/spine/bin'
libtool: install : /usr/bin/install -c spine /usr/local/spine/bin/spine
/bin/mkdir -p '/usr/local/spine/etc'
/usr/bin/install -c -m 644 spine.conf.dist '/usr/local/spine/etc'
make [1]: Leaving directory ` /root/cacti-spine-0 .8.8f'
You have new mail in /var/spool/mail/root
[root@www cacti-spine-0.8.8f]
bin etc
|
1 2 3 4 5 6 7 | [root@www ~]
[root@www ~]
DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass cactipass
DB_Port 3306
|
1 2 3 4 | [root@www ~]
SPINE: Using spine config file [ /etc/spine .conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 0.1549 s, Threads: 5, Hosts: 2
|
【console--->Settings--->Paths--->Spine Poller File Path--->/usr/local/spine/bin/spine】
【Poller--->Poller Type--->spine】
七、Cacti添加监控客户机
[root@sh ~]# rpm -ivh http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm
[root@sh ~]# yum -y install net-snmp net-snmp-devel net-snmp-utils
1 2 3 4 5 6 | [root@sh ~]
55 view systemview included .1.3.6.1.2.1
162
163
164 syslocation 192.168.1.251
165 syscontact Root root@huangmingming.cn
|


1 2 3 4 | [root@www ~]
SPINE: Using spine config file [ /etc/spine .conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 0.1185 s, Threads: 1, Hosts: 3
|
##########NAGIOS#########
一、下载软件包
1、下载nagios核心源码包
wget http://sourceforge.net/projects/nagios/files/latest/download
2、下载nagios插件nagios-plugins
wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
3、下载客户端软件nrpe
wget http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
http://sourceforge.net/projects/nagios-snmp/files/latest/download
二、添加nagios用户和nagcmd组
[root@www ~]# useradd -s /sbin/nologin nagios
[root@www ~]# groupadd nagcmd
[root@www ~]# usermod -G nagcmd nagios
[root@www ~]# usermod -G nagcmd apache
[root@www ~]# id apache
uid=48(apache) gid=48(apache) groups=48(apache),502(nagcmd)
[root@www ~]# id nagios
uid=501(nagios) gid=501(nagios) groups=501(nagios),502(nagcmd)
[root@www ~]# mkdir /usr/local/nagios
[root@www ~]# chown -R nagios.nagios /usr/local/nagios
三、安装nagios-4.1.1.tar.gz
[root@www ~]# tar zxf nagios-4.1.1.tar.gz
[root@www ~]# cd nagios-4.1.1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [root@www nagios-4.1.1]
......
General Options:
-------------------------
Nagios executable: nagios
Nagios user /group : nagios,nagios
Command user /group : nagios,nagcmd
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file : ${prefix} /var/nagios .lock
Check result directory: ${prefix} /var/spool/checkresults
Init directory: /etc/rc .d /init .d
Apache conf.d directory: /etc/httpd/conf .d
Mail program: /bin/mail
Host OS: linux-gnu
IOBroker Method: epoll
Web Interface Options:
------------------------
HTML URL: http: //localhost/nagios/
CGI URL: http: //localhost/nagios/cgi-bin/
Traceroute (used by WAP):
|
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
[root@www nagios-4.1.1]# make all
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install
- This installs the main program, CGIs, and HTML files
make install-init
- This installs the init script in /etc/rc.d/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /etc/nagios
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
make install-webconf
- This installs the Apache config file for the Nagios
web interface
make install-exfoliation
- This installs the Exfoliation theme for the Nagios
web interface
make install-classicui
- This installs the classic theme for the Nagios
web interface
*** Support Notes *******************************************
[root@www nagios-4.1.1]# make install
[root@www nagios-4.1.1]# make install-init
[root@www nagios-4.1.1]# make install-commandmode
[root@www nagios-4.1.1]# make install-config
[root@www nagios-4.1.1]# ls /usr/local/nagios/
bin libexec sbin share var
[root@www nagios-4.1.1]# ls /etc/nagios/
cgi.cfg nagios.cfg objects resource.cfg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | [root@www nagios-4.1.1]
Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL
Website: https: //www .nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 8 services.
Checked 1 hosts.
Checked 1 host groups .
Checked 0 service groups .
Checked 1 contacts.
Checked 1 contact groups .
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
|
[root@www ~]# chkconfig --add nagios
[root@www ~]# chkconfig nagios on
四、安装插件nagios-plugins-2.1.1.tar.gz
[root@www ~]# tar zxf nagios-plugins-2.1.1.tar.gz
[root@www ~]# cd nagios-plugins-2.1.1
[root@www nagios-plugins-2.1.1]# ./configure --prefix=/usr/local/nagios
[root@www nagios-plugins-2.1.1]# make && make install
[root@www nagios-plugins-2.1.1]# ls /usr/local/nagios/
bin include libexec sbin share var
五、安装nrpe-2.15.tar.gz
[root@www ~]# tar zxf nrpe-2.15.tar.gz
[root@www ~]# cd nrpe-2.15
[root@www nrpe-2.15]# ./configure
[root@www nrpe-2.15]# make all
[root@www nrpe-2.15]# cd src/
[root@www src]# make install
[root@www src]# make install-pligin
六、Apache配置
1 2 3 4 | [root@www ~]
New password:
Re- type new password:
Adding password for user nagiosadmin
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | [root@www ~]
242 User apache
243 Group apache
402 DirectoryIndex index.html index.html.var index.php
781 AddType application /x-httpd-php .php .phtml
在最后增加以下内容:
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin" >
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /etc/nagios/passwd
Require valid-user
< /Directory >
Alias .........................................................
|