No SNMP data returned;Data Query Debug Information ;run this data query in debug mode;Create Graphs for this Host;cacti没数据之二;支持中文。
*/5 * * * * /usr/bin/php /usr/local/server/cacti/poller.php > /dev/null 2>&1
===================================================
注意在测试端使用敏感的测试命令:
snmpwalk -v1 被监控端IP -c 团体名 system----------->这个是版本1,而且只取system信息
snmpwalk -v2 被监控端IP -c 团体名 if------------>这个是错误的;
snmpwalk -v2c 被监控端IP -c 团体名 if----------------->使用版本2,采集网卡信息
===================================================
搜索检查了一整天,结果发现问题非常弱,非常低级,就是被监控端snmpd.conf中:
[1]仅仅只添加了 团体名
[2]没指定服务端IP地址
[3]没授权all信息的采集
######参考资料如下地址####
http://blog.csdn.net/pwlazy/article/details/3169989
snmpwalk -v 2c -c public your_remote_ip if
错误:
Timeout: No Response from your_remote_ip
于是修改snmpd配置 并启动snmpd
com2sec notConfigUser default public--->com2sec notConfigUser your_snmpd_server_ip public
#view all included .1 80---->view all included .1 80
snmpwalk -v 2c -c public your_remote_ip system ok
但
snmpwalk -v 2c -c public your_remote_ip if
错误:
IF-MIB::ifTable = No Such Object available on this agent at this OID
于是再次修改snmpd.conf,并重启snmpd
access notConfigGroup "" any noauth exact systemview none none-->
access notConfigGroup "" any noauth exact all none none
再次snmpwalk -v 2c -c public your_remote_ip if
ok
再访问页面终于图和数据出来了
########################################
=========================================
报 插入表失败的错:
http://hc0510.blog.51cto.com/537035/566307
查看Cacti的日志/var/www/cacti/log/cacti.log,发现有很多错误:
05/15/2011 11:40:09 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1062', SQL:"insert into poller_output (local_data_id, rrd_name, time, output) values (188, 'traffic_out', '2011-05-15 23:40:08', '5986769347144')'
之后出现三次运行时长的总结:
05/15/2011 11:40:10 PM - SYSTEM STATS: Time:8.4333 Method:cmd.php Processes:1 Threads:N/A Hosts:11 HostsPerProcess:11 DataSources:259 RRDsProcessed:134
此错误貌似表poller_output有问题,repair table poller_output也没有得到改善。之后发现原因在于系统中有多处crontab在运行 /usr/bin/php /var/www/cacti/poller.php >> /var/log/cacti 2>&1 :)
一在cacti安装过程中自动生成了/etc/crontab/cacti;
二以root用户用crontab -e 加载了此命令;
三以cacti用户以crontab -e 也加载了此命令;
以上三个脚本同时运行,短时间内三次向poller_output表写同一个local_data_id,自然会报错。
注销掉后两个crontab项,cacti.log马上就消停了,每5分钟只有一条总结语句出现了。一下子就解决了两个疑问。
很多时候异常的日志还是事出有因的。
http://doc.okbase.net/chengchow/archive/17769.html
10.1 日志报错
08/19/2013 11:55:05 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1062', SQL:"insert into poller_output (local_data_id, rrd_name, time, output) values (7, 'proc', '2013-08-19 23:55:04', '88')' |
08/19/2013 11:55:04 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1062', SQL:"insert into poller_output (local_data_id, rrd_name, time, output) values (6, 'users', '2013-08-19 23:55:04', '1')' |
解决方法:
chmod 755 –R log rra
chown cactiuser:cactiuser –R log rra
不过做完以后日志的purge权限没了
http://blog.sina.com.cn/s/blog_67e41ce90100ywrx.html
1.日志报错:
01/09/2012 04:10:05 PM - CMDPHP: Poller[0] ERROR: A DB Exec Failed!, Error:'1062', SQL:"insert into poller_output (local_data_id, rrd_name, time, output) values (60, 'cpu_nice', '2012-01-09 16:10:04', '3560')'
这是由于执行了2个cron导致的,在通过yum安装cacti的时候,已经默认设置了一个cron,在/etc/cron.d/cacti里,所以把自己设置的cron取消掉即可。
======================================
php的报错处理:
[1]
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 673
[2]
[root@aliyun snmp]# /usr/bin/php /usr/local/server/cacti/poller.php -force
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/module.so' - /usr/lib64/php/modules/module.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 165
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 165
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 166
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 166
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 167
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 167
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 168
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 168
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 169
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 169
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 170
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 170
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 171
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_constants.php on line 171
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 671
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 671
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 672
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 672
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 673
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 673
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 674
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 674
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 675
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 675
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 676
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 676
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 677
PHP Warning: date(): It is not safe to rely on the system's timezone settings.
You are *required* to use the date.timezone setting or the date_default_timezone_set() function.
In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.
We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/server/cacti/include/global_arrays.php on line 677
ERROR: Invalid Argument: (-force)
Cacti Poller Version 0.8.8b, Copyright 2004-2013 - The Cacti Group
A simple command line utility to run the Cacti Poller.
usage: poller.php [--force] [--debug|-d]
Options:
--force Override poller overrun detection and force a poller run
--debug|-d Output debug information. Similar to cacti's DEBUG logging level.
[3]
[root@aliyun modules]# /usr/bin/php /usr/local/server/cacti/poller.php -force
ERROR: Invalid Argument: (-force)
Cacti Poller Version 0.8.8b, Copyright 2004-2013 - The Cacti Group
A simple command line utility to run the Cacti Poller.
usage: poller.php [--force] [--debug|-d]
Options:
--force Override poller overrun detection and force a poller run
--debug|-d Output debug information. Similar to cacti's DEBUG logging level.
[root@aliyun modules]# /usr/bin/php /usr/local/server/cacti/poller.php --force
OK u:0.00 s:0.00 r:0.03
OK u:0.00 s:0.00 r:0.03
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.04
OK u:0.00 s:0.00 r:0.06
OK u:0.00 s:0.00 r:0.06
OK u:0.00 s:0.00 r:0.08
OK u:0.00 s:0.00 r:0.08
09/29/2014 11:42:41 AM - SYSTEM STATS: Time:0.1992 Method:cmd.php Processes:1 Threads:N/A Hosts:3 HostsPerProcess:3 DataSources:5 RRDsProcessed:5
OK u:0.00 s:0.00 r:0.12
OK u:0.00 s:0.00 r:0.12
[root@aliyun modules]#
[root@aliyun modules]# /usr/bin/php /usr/local/server/cacti/poller.php -force
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php.d/mcrypt.ini on line 2 in Unknown on line 0
ERROR: Invalid Argument: (-force)
[root@aliyun php.d]# vi mcrypt.ini
; Enable mcrypt extension module
#extension=module.so
extension=mcrypt.so
http://www.pangyiguang.com/a_70
一般刚刚配置好的环境,php.ini是没有对date.timezone进行设置的,所以一般配置好都会对php.ini文件进行timezone的配置,要不涉及到
使用时间的一些函数之前进行date_default_timezone_set()设置,否则就会抛出警告的错误,所以你会测试一下环境里使用:phpinfo();
错误是:
Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in E:\documentRoot\index.php on line 2
所以我们应该在php.ini做好配置,预防错误发生,查找php.ini里“date.timezone”,会定位到差不多923行吧,把注释去掉,后面跟上我们的时区:Asia/Shanghai
然后:date.timezone = Asia/Shanghai
重启一下httpd就可以了。
http://blog.wlzs.cn/?p=61
Centos PHP提示:/usr/lib64/php/modules/module.so: cannot
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/module.so' - /usr/lib64/php/modules/module.so: cannot open shared object file: No such file or directory in Unknown on line 0
解决方法:
vi /etc/php.d/mcrypt.ini
; Enable mcrypt extension module
extension=module.so
将module.so改为mcrypt.so即可
http://wz102.blog.51cto.com/3588520/1243649
PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone
在用PHP5.3以上的PHP版本时,只要是涉及时间的会报一个
这样的错。如何解决呢
实 际上,从 PHP 5.1.0 ,当对使用date()等函数时,如果timezone设置不正确,在每一次调用时间函数时,都会产生E_NOTICE 或者 E_WARNING 信息。而又在php5.1.0中,date.timezone这个选项,默认情况下是关闭的,无论用什么php命令都是格林威治标准时间,但是 PHP5.3中好像如果没有设置也会强行抛出了这个错误的,解决此问题,只要本地化一下,就行了。
以下是三种方法(任选一种都行):
重启http服务(如apache2或iis等)即可。
XXX 可以任意正确的值。对于我们国内来说:可以为以下值:Asia/Chongqing ,Asia/Shanghai ,Asia/Urumqi (依次为重庆,上海,乌鲁木齐)港台地区可用:Asia/Macao ,Asia/Hong_Kong ,Asia/Taipei (依次为澳门,香港,台北),还有新加坡:Asia/Singapore,当然PRC也行。
本文出自 “林纳斯” 博客,请务必保留此出处http://wz102.blog.51cto.com/3588520/1243649
=======================================
添加网卡监控:
https://www.centos.bz/2012/06/cacti-monitor-traffic/
上次www.centos.bz已经详细介绍如何安装cacti了,这次我们来学习如何简单地配置cacti来监控服务器流量。
下面是cacti的工作流程图:
1、登录cacti,点击“Devices”,然后点击"Add"创建设备,如图:
2、然后输入Description,Hostname,Host Template选择“Generic SNMP-enabled
Host”,SNMP Version一般选择“Version
1”(当然得根据你具体的snmp如何配置)。完成后点击"create"创建设备,如图:
3、接着在顶部点击“Create Graphs for this Host”创建图表,如图:
4、在“SNMP - Interface Statistics”下面会显示你的网卡,选择其中一个监控即可,我们这里选"eth0",之后单击“create”。
5、现在已经成功创建图表,我们点击左侧的“Graph Management”查看图表列表,此时已经可以看到刚才创建的图表,点击相应的图表标题进去查看。
6、现在可能图表还没开始生成,最多等待5分钟,5分钟后图表是创建了,但图表没有数据,需要等待一段时间程序收集数据。
转载请标明文章来源:《https://www.centos.bz/2012/06/cacti-monitor-traffic/》
=====================
支持中文:
http://www.zhaofengcao.com/archives/1194
让Cacti上的流量图显示中文
正常情况cacti监控图显示的都是英文字符,如果使用中文的话,会出现乱码。查阅资料,解决步骤如下:
1. 检查linux的字符编码:
[root@IT-Mon ~]# cat /etc/sysconfig/i18n
2.检查httpd字符
[root@IT-Mon ~]# vi /etc/httpd/conf/httpd.conf
3.编辑/etc/sysconfig/httpd为apache指定locale
HTTPD_LANG=zh_CN.utf8
4.定制rrdtool
首先将原来的/usr/bin/rrdtool改名为/usr/bin/rrdtool.local
接着创建/usr/bin/rrdtool脚本,内容如下
#! /bin/sh export LANG=zh_CN.utf8 /usr/bin/rrdtool.local "$@"
之后给新的rrdtool文件赋予执行权限。
5.重启http
#service httpd restart
http://otaku119.blogspot.jp/2013/12/cacti.html
在 Cacti 中顯示中文
http://www.zhaofengcao.com/archives/1194
在centOS 6.4,cacti 0.8.8b上面,只要修改下面这个档案
vi /etc/httpd/conf/httpd.conf
改为:HTTPD_LANG=zh_CN.utf8
重起httpd,之后就能看到流量图显示中文了