cacti监控安装

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

转载于:https://my.oschina.net/u/2404183/blog/2246284

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值