您的位置:首页 > 移动开发 > IOS开发

监控cacti/nagios/zabbix (一)cacti

2015-12-08 12:32 639 查看
cacti 重图形,有数据历史,需用到数据库支持,支持web配置,默认不支持告警,可以加插件;
nagios重状态和结果,没有数据历史,不成图像,不支持web配置,可以自己开发脚本定制个性化监控,支持多种插件;
zabbix有数据历史,可成图像,支持web配置,可以自动发现;
第一部分:监控软件Cacti搭建一、环境准备 1、安装epel扩展源 关闭selinux 临时关闭 setenforce 0 vim /etc/selinux/config SELINUX=disbabled
1
[root@cacti ~]
# yum install -y epel-release

2、搭建lamp环境
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
34
35
36
37
[root@cacti ~]
# yum install -y  httpd php php-mysql mysql mysql-server mysql-devel php-gd  libjpeg libjpeg-devel libpng-devel

[root@cacti ~]
# /etc/init.d/httpd start

正在启动 httpd:                                           [确定]

[root@cacti ~]
# /etc/init.d/mysqld start

初始化 MySQL 数据库: Installing MySQL system tables...

OK

Filling help tables...

OK


Tostart mysqld at boot
time
you have tocopy

support-files
/mysql
.server tothe right place
for
your system


PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To
do
so, start the server,
then
issue the following commands:


/usr/bin/mysqladmin
-u root password
'new-password'

/usr/bin/mysqladmin
-u root -h cacti password
'new-password'


Alternatively you can run:

/usr/bin/mysql_secure_installation


which
will also give you the option of removing the
test

databases and anonymous user created by default.  This is

strongly recommended
for
production servers.


See the manual
for
more
instructions.


You canstart the MySQL daemon with:

cd
/usr
;
/usr/bin/mysqld_safe
&


You can
test
the MySQL daemon with mysql-
test
-run.pl

cd
/usr/mysql-test
;perl mysql-
test
-run.pl


Please report any problems with the
/usr/bin/mysqlbug
script!


[确定]

正在启动 mysqld:                                          [确定]

3、安装cacti监控主机
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
34
35
36
37
38
[root@cacti ~]
# yum install -y cacti  net-snmp  net-snmp-utils  rrdtool net-snmp-devel net-snmp-libs lm-sensors php-xml zlib libpng freetype cairo-devel pango-devel gd


[root@cacti ~]
# /etc/init.d/snmpd start

正在启动 snmpd:                                           [确定]

[root@cacti ~]
# mysql -u root

Welcome tothe MySQL monitor.  Commands end with ;or\g.

Your MySQL connection
id
is 4

Server version: 5.1.73 Source distribution


Copyright (c) 2000, 2013, Oracle and
/or
its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and
/or
its

affiliates. Other names may be trademarks of their respective

owners.


Type
'help;'
or
'\h'
for
help. Type
'\c'
to
clear
the current input statement.

mysql>create database cacti;


mysql>grant all on cacti.* to
'cactiuser'
@
'localhost'
identified by
'cactiuser'
;

Query OK, 0 rows affected (0.00 sec)


mysql>
exit

Bye

[root@cacti ~]
# mysql -u root cacti </usr/share/doc/cacti-0.8.8b/cacti.sql

[root@cacti ~]
# vim /usr/share/cacti/include/config.php

$database_type =
"mysql"
;

$database_default =
"cacti"
;

$database_hostname =
"localhost"
;

$database_username =
"cactiuser"
;

$database_password =
"cactiuser"
;

$database_port =
"3306"
;

$database_ssl =
false
;


[root@cacti ~]
# vim /etc/httpd/conf.d/cacti.conf

Deny from all 修改为 Allow from all

[root@cacti ~]
# /etc/init.d/httpd restart

停止 httpd:                                               [确定]

正在启动 httpd:                                           [确定]

4、通过浏览器访问

如果访问不了,请检查主机的iptables和selinux http://IP/cacti/ 点两下“next” 和一次”Finish“ 即可
输入admin admin 登录,重新设置新的密码
5 查看默认主机
执行poller.php, 生成图形, 加入计划任务
/usr/bin/php /usr/share/cacti/poller.php添加cron任务
cront -e 增加:
*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php
6 添加需要被监控的主机
接下来我们添加被监控的主机
在被监控的主机上安装

修改syslocation以及syscontact, 其中syslocation 可以写本机ip,syscontact写管理员邮箱
view systemview included .1.3.6.1.2.1.1
修改为:
view systemview included .1.3.6.1.2.1(如果不改,可能找不到网卡)
7 启动 snmp
/etc/init.d/snmpd start
8 管理cacti后台
点console , 再点Device, 在右上角点”Add“
Description 写本机ip或你自定义一个名字
Hostname 写本机ip
Host Template 选ucd/net SNMP Host
SNMP Version 选Version 2
点右下角的create
点右上角的”Create Graphs forthis Host“
Graph Types: 选择SNMP - Interface Statistics
Graph Types: 再选择 Graph Template Based
在下面的框中,选择你要监控的项目,比如ucd/net - Load Average
在右侧小方块中打对勾,然后点右下角的create
9 添加实时监控后台
选中”Default Tree“
点右上角的Add
Tree Item Type选择 ”Host“
Host 选择我们刚刚增加的那个机器ip
点右下角的create
10 点左上角的Graphs
在左侧可以看到
Defaut Tree下面已经增加了我们刚刚添加的主机,图形一开始不会那么快出来,要等一小会才可以。
参考文章:http://www.it165.net/admin/html/201310/1956.html

Cacti安装高效轮询器spine(转)

Cacti默认轮询器cmd.php执行效率有点低,spine为C语言编写的组件,性能要好许多。
编译安装spine需以下软件支持:

1 net-snmp-devel
2 mysql
3 mysql-devel
4 openssl-devel
5 gcc

安装spine要和Cacti的版本相匹配,本文以最新版cacti0.8.8a安装为例。

1 cd /usr/local/src/
2 wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz 3 tar -zxvf cacti-spine-0.8.8a.tar.gz
4 cd cacti-spine-0.8.8a

编译:
5 ./configure

6 make && make instatll

配置spine:
1 cd /usr/local/spine/etc/
2 mv spine.conf.dist
/etc/spine.conf
3 vi spine.conf

填写数据库信息,即Cacti数据库。

DB_Host localhost
DB_Database cacti
DB_User root
DB_Pass cacti
DB_Port 3306

设置spine路径,Console——Settings——Paths
cacti设置spine路径
/usr/local/spine/bin/spine
更改cacti轮询器为spine,Console——Settings——Poller
cacti更改轮询器为spine

运行:
#/usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.7g starting
SPINE: Time: 0.2410 s, Threads: 5, Hosts: 2

说明:spine默认配置文件需要放在/etc才会生效,否则报如下错误:
SPINE: Poller[0] FATAL: Unable toread configuration file! (Spine
init)

本文出自 “学习Linux” 博客,请务必保留此出处http://linuxlearn.blog.51cto.com/1437234/1720692
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: