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

[经验分享] Linux安装Cacti

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-6-15 10:17:16 | 显示全部楼层 |阅读模式
监控软件Cacti搭建
       一、环境准备
             1、安装epel扩展源
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

wKiom1V8MzeiPSGSAAPeoggd1E4262.jpg
图:一
wKioL1V8NVGhFx3aAAHTyQpC2Tk897.jpg
图:二
wKioL1V8NYugxMJzAATOjCCu5jE500.jpg
图:三
              到了登陆,默认的账号为admin,密码为admin

wKioL1V8NjHi1b0yAAFLckhZxvo091.jpg
图:四
              登陆之后,系统会强制用户更改密码

wKiom1V8NN3gaoNVAAGA7v5oHr0897.jpg
图:五
wKioL1V8Nt_SRyb9AALBUZ5FwYI217.jpg
图:六
             点击graphs-Default Tree-Host Localhost,进入系统监控界面
wKioL1V8N5mzFt3uAAMwQcF4P44338.jpg
图:七
              我们看到监控界面,没有出图,设置一下出图
1
2
3
4
5
6
7
8
9
10
[iyunv@cacti ~]# /usr/bin/php /usr/share/cacti/poller.php
OK u:0.00 s:0.00 r:0.00
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.03
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.08
06/13/2015 09:59:49 PM - SYSTEM STATS: Time:0.1974 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5
[iyunv@cacti ~]# crontab -e
# 让命令每5分钟执行一次
*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1



              我们在刷新一下,图就出来了
wKioL1V8OjTQRs83AAWnKWuHCdM963.jpg
图:八
             数据需要等待一会儿,才能出来
wKiom1V8OpPRL2inAASVMdQMKto471.jpg



            接下来我们添加被监控的主机
1
2
3
4
5
6
7
8
9
10
11
12
13
# 在被监控的主机上安装
[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
正在启动 snmpd:                                           [确定]



           依次点击console -> Devices -> add,添加主机
wKioL1V8PnzgxYrwAAPqpjMlnrk408.jpg

               开始添加被监控主机的信息,填写完毕,点击Create

wKioL1V8ZCvQcUXcAAdoOgWakeg875.jpg

              创建完毕,看是否通信正常,创建完主机,创建要监控的项目点击 Create Graphs for this Host,
wKioL1V8ZM-gh-q9AAgmwloP-0E215.jpg


              根据需要,去选择要监控的项目

wKiom1V8Y5DjCHuqAAYpa7QzyvE198.jpg

              监控项目添加完毕,将主机添加到监控主干线上,点击左侧Graph Trees

wKiom1V8Y-zSqBcEAAXZg1tgOhs039.jpg

               点击Add,添加被监控的主机

wKioL1V8Zo7h-UX9AANenuKwZ4E322.jpg


              类型选择Host,再选择要添加的主机

wKiom1V8ZQ7QZAziAAP2FZOJDnE426.jpg

             添加完毕,点击Save

wKioL1V8ZwbQjS8DAANMx1asnV0862.jpg

              到主界面查看,是否添加成功,最好在监控服务器上刷新一下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[iyunv@cacti ~]# /usr/bin/php /usr/share/cacti/poller.php --force
OK u:0.00 s:0.00 r:0.00
OK u:0.00 s:0.00 r:0.01
OK u:0.00 s:0.00 r:0.03
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.08
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.09
OK u:0.00 s:0.00 r:0.10
06/13/2015 05:16:53 PM - SYSTEM STATS: Time:0.2109 Method:cmd.php Processes:1 Threads:N/A Hosts:3 HostsPerProcess:3 DataSources:20 RRDsProcessed:17




wKiom1V8ZdnS8_09AAXT9mV_92I511.jpg

成功添加!!

运维网声明 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-77442-1-1.html 上篇帖子: 问一个关于如何确定一个oid具体作用的问题 下篇帖子: Cacti(RRDTOOL)中文乱码以及统计图乱码问题解决方法 Linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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