上一篇文章介绍了Cacti1.2.2新版安装部署流程,本文继续来说下cacti监控。
本篇教程基于Cacti1.2.2版本验证,其他版本自测!
如果你现在已经按照上一篇文章部署好了一套cacti监控系统,不要着急,你仅仅是基础服务部署好了,现在你不会看到任何图形。
此时你在cacti图形监控页,全部会显示The Cacti Poller has not run yet.,请继续跟着本教程来创建本机的图形吧!
1、Poller轮询器配置
spine是一个高速的轮询器,是cmd.php的替代品,在cmd.php的基础上,拥有更好的灵活性、速度和并发性。
cacti默认使用的cmd.php进行轮询,由于我们之前已经安装好了spine,所以我这里就更改成spine。
在cacti监控系统中,选择系统配置→设置→Poller→采集类型选择spine→保存
2、验证snmp
使用以下命令验证snmp能否获取到本机的数据
snmpwalk -v 2c -c public localhost
如果正常,会返回以下内容
SNMPv2-MIB::sysDescr.0 = STRING: Linux whsir7 3.10.0-957.5.1.el7.x86_64 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (208948) 0:34:49.48 SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf) SNMPv2-MIB::sysName.0 = STRING: whsir7 SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf) SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup SNMPv2-MIB::sysORID.6 = OID: TCP-MIB::tcpMIB SNMPv2-MIB::sysORID.7 = OID: IP-MIB::ip SNMPv2-MIB::sysORID.8 = OID: UDP-MIB::udpMIB SNMPv2-MIB::sysORID.9 = OID: SNMP-NOTIFICATION-MIB::snmpNotifyFullCompliance SNMPv2-MIB::sysORID.10 = OID: NOTIFICATION-LOG-MIB::notificationLogMIB SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching. SNMPv2-MIB::sysORDescr.2 = STRING: The management information definitions for the SNMP User-based Security Model. SNMPv2-MIB::sysORDescr.3 = STRING: The SNMP Management Architecture MIB. SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP. SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing TCP implementations SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing IP and ICMP implementations SNMPv2-MIB::sysORDescr.8 = STRING: The MIB module for managing UDP implementations SNMPv2-MIB::sysORDescr.9 = STRING: The MIB modules for managing SNMP Notification, plus filtering. SNMPv2-MIB::sysORDescr.10 = STRING: The MIB module for logging SNMP Notifications. SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.6 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.7 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.9 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.10 = Timeticks: (0) 0:00:00.00 HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (274817) 0:45:48.17 HOST-RESOURCES-MIB::hrSystemUptime.0 = No more variables left in this MIB View (It is past the end of the MIB tree)
3、配置crontab
Centos7安装crontab服务(系统默认一般都自带此服务)
yum install crontabs -y
配置crontab前,请使用以下命令测试是否可以获取数据
/usr/bin/php /data/www/cacti/poller.php
正常会返回以下内容
OK u:0.00 s:0.01 r:1.02 OK u:0.00 s:0.01 r:1.02 OK u:0.00 s:0.01 r:1.04 OK u:0.00 s:0.01 r:1.04 OK u:0.00 s:0.01 r:1.05 OK u:0.00 s:0.01 r:1.05 OK u:0.00 s:0.01 r:1.06 OK u:0.00 s:0.01 r:1.06 OK u:0.00 s:0.02 r:1.08 OK u:0.00 s:0.02 r:1.08 2019/00/25 00:20:48 - SYSTEM STATS: Time:1.3197 Method:spine Processes:1 Threads:1 Hosts:1 HostsPerProcess:1 DataSources:5 RRDsProcessed:5
使用crontab命令添加任务
crontab -e
添加以下任务,我这里配置成每五分钟运行一次
*/5 * * * * /usr/bin/php /data/www/cacti/poller.php > /dev/null 2>&1
4、设置crontab自启动
添加好crontab计划任务后,验证下crond服务是否已经启动,并设置开机自启
systemctl status crond systemctl enable crond
5、验证
登陆cacti监控平台,查看图形,等个十来分钟就可以看到了
原文出处:whsir -> https://blog.whsir.com/post-4371.html
本文链接:https://www.kinber.cn/post/1258.html 转载需授权!
推荐本站淘宝优惠价购买喜欢的宝贝: