文档章节

cacti监控安装

hiwill
 hiwill
发布于 10/16 07:51
字数 1106
阅读 13
收藏 0

cacti是用PHP实现的一个软件,它用snmp服务获取数据,然后用rrdtool存储和更新数据,并生成图表展示。比较适合用于交换机、路由器的网络监控,插件众多,可图示化显示网络状况。

cacti官方推荐版本如下:
PHP 5.4+
MySQL 5.1+
RRDtool 1.3+, 1.5+ recommended
NET-SNMP 5.5+
Web Server with PHP support

centos7.5上安装记录:
#安装php7.1和apache2.4
yum install -y epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y php71w php71w-devel php71w-common php71w-ldap php71w-gd php71w-xml php71w-cli php71w-pear php71w-mbstring php71w-mysql php71w-snmp httpd

#php配置
vi /etc/php.ini
date.timezone = Asia/Shanghai
error_log = syslog

systemctl start httpd
systemctl enable httpd

#安装MySQL5.7.23
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum install -y mysql-community-server mysql-community-devel
systemclt start mysqld
systemctl enable mysqld

grep password /var/log/mysqld.log
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

#安装cacti
yum -y install net-snmp net-snmp-devel net-snmp-utils net-snmp-libs rrdtool help2man

wget https://www.cacti.net/downloads/cacti-1.1.38.tar.gz
tar zxvf cacti-1.1.38.tar.gz

cd cacti-1.1.38
#建立cacti用户并导入数据结构
mysql -u root -p
create databases cacti;
create user 'cacti'@'localhost' identified by 'Uiop!789';
grant all privileges on *.* to 'cacti'@'localhost';
flush privileges;
use cacti;
source cacti.sql;

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

mv cacti-1.1.38 /var/www/html/cacti
adduser -d /var/www/html/cacti -s /sbin/nologin cacti
echo "*/5 * * * * cacti php /var/www/html/cacti/poller.php &>/dev/null" >> /etc/cron.d/cacti
cd /var/www/html/cacti
chown -R cacti.apache rra log  
chmod 775 rra log

#修改cacti数据库配置
vi /var/www/html/cacti/include/config.php
$database_type     = 'mysql';
$database_default  = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cacti';
$database_password = 'Uiop!789';
$database_port     = '3306';
$database_ssl      = false;

#httpd配置,注意apache2.4和2.2写法不太一样
cat > /etc/httpd/conf.d/cacti.conf <<EOF
# Cacti - the complete rrdtool-based graphing solution

# Allows only localhost by default
#
# Allowing cacti to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

# Make sure, that httpd can read your cacti directories.
# At minimum, you need
#    chmod ugo+r -R /your/cacti/dir
# Make sure to replace with your directories

# When using SELinux, set the following:
#    chcon -R -h -t httpd_sys_content_t /your/cacti/dir
# when using SELinux and you private homedir, enable
#    setsebool -P httpd_enable_homedirs 1
#    setsebool -P httpd_read_user_content 1

Alias /cacti /var/www/html/cacti
<Directory /var/www/html/cacti>
   AllowOverride All
   Require all granted
   Options Indexes Includes FollowSymLinks
</Directory>

# These directories do not require access over HTTP 
#
<Directory /var/www/html/cacti/cli>
   Require all denied
   Require all granted
</Directory>
EOF

systemctl restart httpd

#http://serverIP/cacti,按提示配置MySQL
vi /etc/my.cnf
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[client]
port            = 3306
default-character-set=utf8mb4

[mysqld]
port            = 3306
skip-name-resolve
character-set-server=utf8mb4
max_connections=1000
max_heap_table_size=1024M
max_allowed_packet=32M
tmp_table_size=128M
join_buffer_size=128M
innodb_buffer_pool_size=4096M
innodb_doublewrite=OFF
innodb_flush_log_at_timeout=5
innodb_read_io_threads=32
innodb_write_io_threads=16
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

systemctl restart mysqld

#安装cacti-spine抓包工具
wget https://www.cacti.net/downloads/spine/cacti-spine-1.1.38.tar.gz
tar zxvf cacti-spine-1.1.38.tar.gz
cd cacti-spine-1.1.38
./configure
make && make install

cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
vi /usr/local/spine/etc/spine.conf
DB_Host                 localhost
DB_Database             cacti
DB_User                 cacti
DB_Pass                 Uiop!789
DB_Port                 3306

#测试是否正常
[root@localhost ~]# /usr/local/spine/bin/spine -C /usr/local/spine/etc/spine.conf
SPINE: Using spine config file [/usr/local/spine/etc/spine.conf]
SPINE: Version 1.1.38 starting
SPINE: Time: 0.1116 s, Threads: 5, Devices: 0

http://IP/cacti即可按提示安装
chown -R apache.apache /var/www/html/cacti/resource/
chown -R apache.apache /var/www/html/cacti/cache

1,cacti官方网站https://docs.cacti.net-> forums -> Scripts and Templates, 搜索需要的模板,可自己修改
在cacti控制页面
2,导入模板
3,添加device,并将device添加到对应模板,建立对应图形,将图形添加到tree。
随后即可在图形选项卡看到生成的图表

例如监控esxi主机172.16.90.205
开启ssh服务器登录

ESXI5.5开启snmp+zabbix 监控esxi 需要开启的服务
esxcli system snmp set --communities public 
esxcli system snmp set --enable true
####允许所有主机访问snmp服务
esxcli network firewall ruleset set --ruleset-id snmp --allowed-all true 
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart

####如果要只允许特定的IP地址访问snmp服务
esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address 10.0.101.0/24
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart

vi /etc/vmware/snmp.xml
将enable修改为true
/sbin/services.sh  restart

cacti服务器端测试使用命令snmpwalk -c public -v 1 172.16.90.205,收到数据即OK

© 著作权归作者所有

共有 人打赏支持
hiwill
粉丝 13
博文 126
码字总数 82589
作品 0
朝阳
私信 提问
部署cacti监控windows && linux

一、安装LAMP架构 本篇主要介绍cacti如何监控windows主机,cacti的搭建过程也很简单,同样,监控linux主机也不难。这里主要记录部署监控windows过程中遇到的两个问题 1、LAMP #yum install -...

nmshuishui
2014/08/14
0
0
用linux上的cacti去监控windows服务器(原)

以前一直用cacti或者mrtg来监控交换机流量,很少用来监控服务器,最近突然有个任务需要监控windows服务器,一般刚装好的cacti,里 面的监控设置都是基于交换机和linux的,没有专门监控windo...

JavaGG
2009/05/05
930
0
图文详解cacti的安装和使用

简介: 1.cacti介绍 2.安装服务端 3.安装客户端 4.添加监控的设备 cacti的介绍 Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具 Cacti是通过 snmpget来获取数据,使用...

lizheng103
2016/12/14
0
0
linux下的cacti安装、监控远程主机及优化

用cacti可以监控本机、远程机器资源与机器的状态,包括cpu、内存、tcp等等信息,当被监控的机器超负载运行时会自动发邮件通知报警。 将一台linux5.6机器作为cacti服务器,另外2台linux5.6模拟...

任小为
2014/07/15
0
0
网络服务器监控

一、监控介绍: 他是通过一种代理将数据传递到监控平台的手段。 二、监控方式一(SNMP+RRDTool+CACTI): 三:监控方式二(nagios): nagios:监控数据的状态...

嘀充值成功
2017/05/13
0
0

没有更多内容

加载失败,请刷新页面

加载更多

设计模式之单例模式

单例模式核心:保证一个类只有一个对象 单例模式分为五种:懒汉式、饿汉式、双重检测锁式、静态内部类式、枚举式 五种模式的特点:懒汉式---线程安全,调用效率高,不能延时加载 饿汉式---线...

森林之下
15分钟前
0
0
markdown语法

这篇博客是本人在使用markdown语法过程中,用于记录一些自己总是会忘记的语法,并且会持续更新; 如何增加批注/备注:>; 这是一条备注/引言 如何手动换行,行末两次空格;

BlackCanary
16分钟前
1
0
redis 设置外网可访问

前提是你已经把redis的端口放到了防火墙计划中,  /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT /etc/rc.d/init.d/iptables save 更改redis.conf 文件 bind 127.0.0.1prot...

时刻在奔跑
18分钟前
0
0
css3隐藏滚动条

chrome 和Safari .element::-webkit-scrollbar { width: 0 } IE 10+ .element { -ms-overflow-style: none; } Firefox .element { overflow: -moz-scrollbars-none; } firefox这个没试过~啦啦......

呵呵闯
34分钟前
0
0
Poco官方PPT_020-ErrorHandlingAndDebugging双语对照翻译

因工作需要用到这一块的功能,所以直接翻译了一下 此PPT来源于官方文件,地址https://pocoproject.org/documentation.html

CHONGCHEN
38分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部