设为首页 收藏本站
查看: 1826|回复: 0

[经验分享] 监控cacti/nagios/zabbix (一)cacti

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-12-9 09:14:55 | 显示全部楼层 |阅读模式
cacti 重图形,有数据历史,需用到数据库支持,支持web配置,默认不支持告警,可以加插件;
nagios重状态和结果,没有数据历史,不成图像,不支持web配置,可以自己开发脚本定制个性化监控,支持多种插件;
zabbix有数据历史,可成图像,支持web配置,可以自动发现;

第一部分:监控软件Cacti搭建
一、环境准备
             1、安装epel扩展源
  关闭selinux
临时关闭 setenforce 0
vim /etc/selinux/config
SELINUX=disbabled
1
[iyunv@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
[iyunv@cacti ~]# yum install -y  httpd php php-mysql mysql mysql-server mysql-devel php-gd  libjpeg libjpeg-devel libpng-devel
[iyunv@cacti ~]# /etc/init.d/httpd start
正在启动 httpd:                                           [确定]
[iyunv@cacti ~]# /etc/init.d/mysqld start
初始化 MySQL 数据库: Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the 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 can start 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
[iyunv@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

[iyunv@cacti ~]# /etc/init.d/snmpd start
正在启动 snmpd:                                           [确定]
[iyunv@cacti ~]# mysql -u root
Welcome to the 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
[iyunv@cacti ~]# mysql -u root cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql
[iyunv@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;

[iyunv@cacti ~]# vim /etc/httpd/conf.d/cacti.conf
Deny from all 修改为 Allow from all
[iyunv@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 添加需要被监控的主机
接下来我们添加被监控的主机
在被监控的主机上安装
[iyunv@rsa ~]# yum install -y net-snmp lm_sensors
[iyunv@rsa ~]# vim /etc/snmp/snmpd.conf

#syslocation Unknown (edit /etc/snmp/snmpd.conf)
syslocation 192.168.1.118

#group  context sec.model sec.level prefix read   write  notif
access  notConfigGroup ""      any       noauth    exact  all none none

view all    included  .1                               80   
[iyunv@rsa ~]# /etc/init.d/snmpd start
修改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 for this 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 wgethttp://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 to read configuration file! (Spineinit)



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-148605-1-1.html 上篇帖子: 当Cacti出现snmp error时 下篇帖子: 监控cacti/nagios/zabbix (二)nagios
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表