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

[经验分享] cacti模板使用管理及安装问题总结

[复制链接]

尚未签到

发表于 2019-1-11 07:11:55 | 显示全部楼层 |阅读模式
  ==========
cacti模板的创建使用
==========

  1. cacti_thold插件监控网卡流量的方法
因为cacti中默认的单位是byte,这样在显示及设置起来比较麻烦,因些我们需要自定义一个cdef模板以供使用,方法如下:
Management->Graph Management->CDEFs->add-->Byte to Mbits(新建的模板名):
Item Value
Item #1 Special Data Source: CURRENT_DATA_SOURCE
Item #2 Custom String: 8
Item #3 Operator: *
Item #4 Custom String: 1024
Item #5 Operator: /
Item #6 Custom String: 1024
Item #7 Operator: /
  现在就可以在Threshold Templates添加监控流量的模板了,在
Templates-->Threshold Templates-->Add-->Interface - Traffic [traffic_in]/Traffic [traffic_out]-->Data Manipulation-->Data Type:CEDF-->Threshold CDEF:Byte to Mbits
Alert Emails-->邮件报警,多个邮件地址以逗号分隔
  2. cacti监控硬盘使用率并报警
cacti本身的模板只可以监控硬盘的使用大小,而不能监控使用百分率,所以我们要自定义cdef来监控硬盘使用率,并借助thold插件实现报警功能.
cacti目录下,vi include/global_arrays.php修改如下:


  • $custom_data_source_types = array(  
  •         "CURRENT_DATA_SOURCE" => "Current Graph Item Data Source",  
  •         "ALL_DATA_SOURCES_NODUPS" => "All Data Sources (Don't Include Duplicates)",  
  •         "ALL_DATA_SOURCES_DUPS" => "All Data Sources (Include Duplicates)",  
  •         "SIMILAR_DATA_SOURCES_NODUPS" => "All Similar Data Sources (Don't Include Duplicates)",  
  •         "SIMILAR_DATA_SOURCES_DUPS" => "All Similar Data Sources (Include Duplicates)",  
  •         "CURRENT_DS_MINIMUM_VALUE" => "Current Data Source Item: Minimum Value",  
  •         "CURRENT_DS_MAXIMUM_VALUE" => "Current Data Source Item: Maximum Value",  
  •         "CURRENT_GRAPH_MINIMUM_VALUE" => "Graph: Lower Limit",  
  •         "CURRENT_GRAPH_MAXIMUM_VALUE" => "Graph: Upper Limit",  
  •         "VALUE_OF_HDD_TOTAL" => "Value of hdd_total data source",         此为增加的一行  
  •         "COUNT_ALL_DS_NODUPS" => "Count of All Data Sources (Don't Include Duplicates)",  
  •         "COUNT_ALL_DS_DUPS" => "Count of All Data Sources (Include Duplicates)",  
  •         "COUNT_SIMILAR_DS_NODUPS" => "Count of All Similar Data Sources (Don't Include Duplicates)",  
  •         "COUNT_SIMILAR_DS_DUPS" => "Count of All Similar Data Sources (Include Duplicates)");

  cacti管理界面-->Graph Management-->CDEFs->add-->monitor-hdd-percent(新建的模板名):
Item Value
Item #1  Special Data Source: CURRENT_DATA_SOURCE  
Item #2  Custom String: 100  
Item #3  Operator: *  
Item #4  Special Data Source: VALUE_OF_HDD_TOTAL  
Item #5  Operator: /
  现在就可以在Threshold Templates添加监控硬盘的模板了:
Threshold Templates-->Add-->Host MIB - Hard Drive Space [hdd_used](新建模板名)-->Data Manipulation-->Data Type:CEDF-->Threshold CDEF:monitor-hdd-percent(选择刚自定义的模板)
Alert Emails-->邮件报警,多个邮件地址以逗号分隔
  3.模板应用
Devices-->选择主机-->Create Graphs for this Host-->Auto-create thresholds自动应用刚创建的所有模板
Created threshold for the Graph 'ucd_load5min' using the Data Source 'ucd_load5min'
Created threshold for the Graph 'Interface - Traffic' using the Data Source 'traffic_in'
Created threshold for the Graph 'Interface - Traffic' using the Data Source 'traffic_out'
Created threshold for the Graph 'Host MIB - Hard Drive Space' using the Data Source 'hdd_used'
Created threshold for the Graph 'Host MIB - Hard Drive Space' using the Data Source 'hdd_used'
Created threshold for the Graph 'Host MIB - Hard Drive Space' using the Data Source 'hdd_used'
  ==========
cacti问题总结
==========
1. 被监控服务器如果做了安全限制需开放iptables和hosts.allow的snmpd端口和协议
echo 'snmpd:192.168.7.x' >>/etc/hosts.allow
iptables -I INPUT -p udp --dport 161 -s 192.168.7.250 -m state --state NEW -j ACCEPT   只开放udp协议161端口即可
  2.cacti访问页面空白及安装过程出错信息排查
1)ldd /usr/bin/rrdtool 查看加载模块是否有not found
   如果有提示找不到的文件libfreetype
 执行命令LD_DEBUG=libs /usr/bin/rrdtool 可以查找当rrdtool文件运行时所查找的路径,提示是到/lib /usr/lib下去寻找,
  而该路径下没有些文件,locate libfreetype.so.6查看下命令在哪里做个软链接过去就行了
2)#snmpwalk -v 2c -c public 192.168.7.250 if  手动获取snmp信息是否成功
手动执行/usr/bin/php poller.php  
php cmd.php  查看出错信息
把web管理界面上的debug打开,再查看cacti.log和apache访问日志进行排查,Setting-->General-->Poller Logging Level-->DEBUG - Statistics....
安装gcc,gcc-c++ 因为rrdtool是用gcc编译的 
  3. 另root和cactiuser里crontab有重复的php执行poller.php文件,删除root的crontab定时任务,用cactiuser用户去执行
  # php poller.php  手动执行出错信息
01/24/2013 08:50:25 AM - POLLER: Poller[0] NOTE: Poller Int: '300', Cron Int: '300', Time Since Last: '24', Max Runtime '298', Poller Runs: '1'
01/24/2013 08:50:25 AM - POLLER: Poller[0] NOTE: Cron is configured to run too often!  The Poller Interval is '300' seconds, with a minimum Cron period of '300' seconds, but only 24 seconds have passed since the poller last ran.
提示poller设置每隔300s运行一次,但现在只24s就运行了一次,太频繁了。
把crontab里的php poller每5分钟执行一次改为每分钟执行一次再改回来,问题不明
最好是以cactiuser帐号来运行OK
sudo -u cactiuser /usr/bin/php -f /var/www/html/cacti/poller.php
  #php cmd.php 手动执行查看出错信息
  4. cacti部分图片显示不了  cacti目录路径/var/www/html/cacti/include/config.php下
$url_path = "/cacti/"; 或include/global.php下指定cacti路径

/* set URL path */

if (! isset($url_path)) {

        $url_path = "/cacti/";

}
  5. 创建模板不成功查看出错日志:CMDPHP: Poller[0] ERROR: SQL Assoc Failed!, Error:'1064', SQL:"SELECT * FROM thold_template ORDER BY name ASC LIMIT 0,"
  谷歌了N久答案:Just goto Console->Settings->Thresholds and press the save button  OK


==========

交换机模板添加

==========

交换机模板:ucd/net SNMP Host 或Generic SNMP-enabled Host可以监听多个端口信息。

对于H3C交换机网卡端口号太长显示不全问题,GigabitEthernet0/0/1显示成GigabitEthernet,更改:

Console ->Settings  ->Visual ->Maximum Field Length: 默认15,修改成50就好了,具体自己定。

设备里重新加载下Devices->SW01->Data Query Nameàucd->小圆圈Reload Data Query.

The maximum number of characters to display for a data query field


附件:http://down.运维网.com/data/2362240


运维网声明 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-661774-1-1.html 上篇帖子: cacti安装配置使用详结 下篇帖子: linux监控cacti配置教程(2)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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