# mysql -u root -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12142 to server version: 3.23.58
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> grant select,insert,update,delete on *.* to root@"%" Identified by "123456";
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on cacti.* to cactiuser@"localhost" Identified by "cactipw" WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
上述命令创建了cacti数据库,同时创建了帐户cactiuser,并赋予了对应的访问权限。
PHP Warning: reset(): Passed variable is not an array or object in /usr/local/cacti/lib/functions.php on line 146
Warning: reset(): Passed variable is not an array or object in /usr/local/cacti/lib/functions.php on line 146
PHP Warning: Variable passed to each() is not an array or object in /usr/local/cacti/lib/functions.php on line 147
Warning: Variable passed to each() is not an array or object in /usr/local/cacti/lib/functions.php on line 147
PHP Warning: reset(): Passed variable is not an array or object in /usr/local/cacti/lib/functions.php on line 146
Warning: reset(): Passed variable is not an array or object in /usr/local/cacti/lib/functions.php on line 146
PHP Warning: Variable passed to each() is not an array or object in /usr/local/cacti/lib/functions.php on line 147
Warning: Variable passed to each() is not an array or object in /usr/local/cacti/lib/functions.php on line 147
解决方法:
这是在安装插件patch之后的一个小bug,需要修改lib/functions.php,找到function read_default_config_option,修改为如下代码:
function read_default_config_option($config_name) {
global $config, $settings;
if (is_array($settings)) {
reset($settings);
while (list($tab_name, $tab_array) = each($settings)) {
if ((isset($tab_array[$config_name])) && (isset($tab_array[$config_name]["default"]))) {
return $tab_array[$config_name]["default"];
}else{
while (list($field_name, $field_array) = each($tab_array)) {
if ((isset($field_array["items"])) && (isset($field_array["items"][$config_name]))
&& (isset($field_array["items"][$config_name]["default"]))) {
return $field_array["items"][$config_name]["default"];
}
}
}
}
}
}
poller.php无法正常采集数据,一直处于等待状态
输出的日志信息如下:
08/23/2005 11:04:59 AM - POLLER: Poller[0] Maximum runtime of 296 seconds exceeded. Exiting.
解决办法:
这有可能是由于环境中有多个php的程序,cacti初始化所用的php的路径,与crontab中执行的时候所用的php的路径不一致;
并且,cacti初始化指定的php必须是与mysql结合编译的那个php,否则的话,会出现无法连接到mysql数据库的报错。
cacti进阶应用
cacti加入msn预警
a) 获取cacti补丁
http://www.hiadmin.com/wp-content/uploads/2008/11/cacti_thold-039_settings-05_add_fetion_msn.path
b) 补丁安装
root@TS263 cacti]# patch -p1 < cacti_thold-039_settings-05_add_fetion_msn.path
The next patch would create the file index.php,
which already exists! Assume -R? [n] y
patching file index.php
Hunk #1 FAILED at 1.
File index.php is not empty after patch, as expected
1 out of 1 hunk FAILED — saving rejects to file index.php.rej
patching file settings/fetion-test.php
can’t find file to patch at input line 42
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
————————–
|diff -uNr plugins-old/settings/include/functions.php plugins/settings/include/functions.php
|— plugins-old/settings/include/functions.php 2008-04-29 14:03:40.000000000 +0800
|+++ plugins/settings/include/functions.php 2008-11-24 18:22:10.000000000 +0800
————————–
File to patch:
Skip this patch? [y] y
Skipping patch.
1 out of 1 hunk ignored
patching file settings/include/msnpauth.php
patching file settings/include/sendMsg.php
patching file settings/msn-test.php
can’t find file to patch at input line 537
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
————————–
|diff -uNr plugins-old/settings/setup.php plugins/settings/setup.php
|— plugins-old/settings/setup.php 2008-04-29 14:03:40.000000000 +0800
|+++ plugins/settings/setup.php 2008-11-24 13:07:48.000000000 +0800
————————–
File to patch: plugins/settings/
patch: **** File plugins/settings/ is not a regular file — can’t patch
c) 测试
安装成功之后可以看到:
可以在这里测试邮件和MSN,如图:
测试邮件
测试MSN
因为公司的邮件服务器需要SMTP认证,因此测试时邮件服务器使用图中的就可以了。
建立thold模板时可用选择发送多个用户,如图:
d) 修改文件
需要修改:../cacti/plugins/thold/ thold_templates.php 在352行处
perl <path_cacti>/scripts/page_load_time.pl <url>
在【Data Source】中,将需要check的url设置为绝对的url路径,例如:http://10.0.3.20:5050/aaa/portal/login.do?action=autoLogon&way=mine
在最后生成图片的时候,有一个ERROR:the RRD does not contain an RRA matching the chosen CF 这样的报错。需要修改graph templates,
将item1的CFType由原先的Last修改为Average,则图片可以显示正常了。