Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3016283
  • 博文数量: 535
  • 博客积分: 15788
  • 博客等级: 上将
  • 技术积分: 6507
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-07 09:11
文章分类

全部博文(535)

文章存档

2016年(1)

2015年(1)

2014年(10)

2013年(26)

2012年(43)

2011年(86)

2010年(76)

2009年(136)

2008年(97)

2007年(59)

分类: LINUX

2008-06-04 15:55:28

20111215:更新,因为新版本的cacti需要boost插件,所以现在cacti提供整合了plugin manager的cacti   cacti-0.8.7i-PIA-3.1.tar.gz。所以应该下载该版本的cacti。
For users interested in Plugin management, direct them to download the file: for installing cacti with embedded plugin management.  

注:使用RHEL5.2
一.安装apache

./configure --prefix=/usr/local/apache --enable-so --enable-mods-shared="proxy proxy_http proxy_ftp proxy_connect headers rewrite"

make 
make install


二.安装mysql
//添加用于启动MySQL的用户及用户组

groupadd mysql
useradd mysql -g mysql


passwd mysql #一定注意密码

tar -C /usr/local/ -xvzf mysql-5.0.51a-linux-i686.tar.gz


//建立符号链接,如果以后有新版本的MySQL的话,你可以仅仅将源码解压到新的路径,然后重新做一个符号链接就可以了。这样非常方便,数据也更加安全。

ln -s /usr/local/mysql-5.0.51a-linux-i686 /usr/local/mysql


//初始化授权表

cd /usr/local/mysql
scripts/mysql_install_db --user=mysql


//修改MySQl目录的所有权

chown -R mysql.mysql /usr/local/mysql-5.0.51a-linux-i686
chown -R mysql.mysql /usr/local/mysql


//启动Mysql

/usr/local/mysql/bin/safe_mysqld --user=mysql &


//配置系统启动时自动启动MySQl

cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld


//添加mysql命令到/usr/local/bin目录

echo "export PATH=/usr/local/mysql/bin:$PATH" >>/etc/profile

source /etc/profile


更改mysql root 密码

use mysql 
update user set Password=password('newpassword') where User='root'; 
flush privileges;


三 安装PHP

先安装zlib,freetype,libpng,jpeg以便于让PHP支持GD库(Cacti的WeatherMap插件必须要较新GD库的支持)

//下载需要的库
freetype-2.3.5.tar.gz,libpng-1.2.18.tar.gz,zlib-1.2.3.tar.gz
~dxy/solaris/jpegsrc/         jpegsrc.v6b.tar.gz
gd-2.0.35.tar.gz
fontconfig-2.6.0.tar.gz

1).安装zlib

tar zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install



2).安装libpng

tar zxvf libpng-1.2.18.tar.tar
cd libpng-1.2.18
./configure
make
make install
注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个


3).安装freetype

tar zxvf freetype-2.3.5 .tar.gz
cd freetype-2.3.5 
./configure --prefix=/usr/local/freetype
make
make install



4).安装Jpeg

8c: 

tar -zvxf jpegsrc-1.v6b.tar.gz (jpegsrc.v8c.tar.gz

cd jpeg-6b/


mkdir /usr/local/libjpeg
mkdir /usr/local/libjpeg/include
mkdir /usr/local/libjpeg/bin
mkdir /usr/local/libjpeg/lib
mkdir /usr/local/libjpeg/man
mkdir /usr/local/libjpeg/man/man1

./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static
make 
make install

注意,这里configure一定要带--enable-shared参数,不然,不会生成共享库


5).安装Fontconfig

tar -zxvf fontconfig-2.6.0.tar.gz
cd fontconfig-2.6.0
./configure --with-freetype-config=/usr/local/freetype/bin/freetype-config
make
make install



6).安装GD

tar -zxvf gd-2.0.35.tar.gz
cd gd-2.0.35

./configure --prefix=/usr/local/libgd \

--with-png \

--with-freetype=/usr/local/freetype \

--with-jpeg=/usr/local/libjpeg \

--with-zlib-dir=/usr/local/zlib

make
make install

编译完成后显示以下信息:

** Configuration summary for gd 2.0.34:

Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: yes
Support for Xpm library: no
Support for pthreads: yes



make时出错

configure.ac:64: error: possibly undefined macro: AM_ICONV
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.


需要安装以下的软件包
gettext-0.14.6-4.el5.i386.rpm
gettext-devel-0.14.6-4.el5.i386.rpm
分别在第2,3张光盘里


7).编辑/etc/ld.so.conf,添加以下几行到此文件中。

/usr/local/zlib/lib
/usr/local/freetype/lib
/usr/local/libjpeg/lib
/usr/local/libgd/lib

并执行ldconfig命令,使用动态装入器装载找到共享库

8).安装PHP

PHP下载地址:

./configure --prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc \

--with-apxs2=/usr/local/apache/bin/apxs \

--with-mysql=/usr/local/mysql \

--with-gd=/usr/local/libgd \

--enable-gd-native-ttf \

--with-ttf \

--enable-gd-jis-conv \

--with-freetype-dir=/usr/local/freetype \

--with-jpeg-dir=/usr/local/libjpeg \

--with-png-dir=/usr \

--with-zlib-dir=/usr/local/zlib \

--enable-xml \

--enable-mbstring \

--enable-sockets

对于使用rpm安装的mysql,不需指定--with-mysql=/usr/local/mysql,而应该为--with-mysql

对php编译选项的解释:
--prefix=/usr/local/php //指定PHP的安装目录
--with-apxs2=/usr/local/apache2/bin/apxs //支持Apache模块
--with-mysql=/usr/local/mysql //支持MySQl
--with-gd=/usr/local/libgd //支持GD库
--enable-gd-native-ttf //激活对本地 TrueType 字符串函数的支持
--with-ttf //激活对 FreeType 1.x 的支持
--with-freetype-dir=/usr/local/freetype //激活对 FreeType 2.x 的支持
--with-jpeg-dir=/usr/local/libjpeg //激活对 jpeg-6b 的支持
--with-png-dir=/usr //激活对 png 的支持
--with-zlib-dir=/usr/local/zlib //激活对zlib 的支持
--enable-mbstring //激活mbstring模块
--enable-gd-jis-conv //使JIS-mapped可用,支持日文字体
--with-mail //支持Mail函数
--enable-xml //支持XML
--enable-sockets //支持套接字

make
make test (6)
make install



cp php.ini-recommended /usr/local/php/etc/php.ini

注:修改 short_open_tag=off为 short_open_tag=on 这个选项经常造成php错误。


vi /usr/local/apache/conf/httpd.conf
查找AddType application/x-compress .Z
在其下加入

AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType image/x-icon .ico



修改DirectoryIndex 行,添加index.php

# vi /usr/local/apache/htdocs/test.php

添加以下行:

//php标记(用<代替[)


Phpinfo();

?>


wq保存退出。

测试: 出现php版本相关信息,则表示OK

四 安装RRDTool


由于rrdtool需要一些库文件支持,在安装php之前已经安装了一部分,还需要安装libart_lgpl-2.3.17.tar.gz,cgilib-0.5.tar.gz

安装 cgilib-0.5.tar.gz


make
make install
注:如果需要./configure并且在make时报错

./configure: line 1246: syntax error near unexpected token `cgilib,'
./configure: line 1246: `AM_INIT_AUTOMAKE(cgilib, 0.7)'


则,你可能下载的是cvs版本的cgilib,换一个低一点版本的即可,当然,你也可以看文档来安装cvs版本的。

1.安装 libart_lgpl-2.3.17.tar.gz 

下载地址:

./configure 
make
make install

2.安装RRDTool

下载地址:

cp /usr/local/freetype/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/
ln -s /usr/local/include/libart-2.0 /usr/include
cp /usr/local/freetype/lib/libfreetype.* /usr/lib

./configure --disable-python --disable-tcl
make
make install

ln -s /usr/local/rrdtool-1.2.27/bin/* /usr/local/bin/


执行rrdtool看是否安装正确
关于在64位服务器上报错:

./rrdtool: /usr/lib64/libpng12.so.0: no version information available (required by /usr/local/rrdtool-1.3.9/lib/librrd.so.4)

./rrdtool: /usr/lib64/libpng12.so.0: no version information available (required by /usr/local/lib/libcairo.so.2)

解决:

下载libpng-1.2.44

wget http://downloads.sourceforge.net/project/libpng/03-libpng-previous/1.2.44/libpng-1.2.44.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flibpng%2Ffiles%2F&ts=1291017387&use_mirror=cdnetworks-kr-2

tar -xvzf libpng-1.2.44.tar.gz


export CFLAGS="-m64"

export LDFLAGS="-m64"

./configure --prefix=/usr --libdir=/usr/lib64

make

make install

2010-11-29:今天在一台64位centos4.5上部署rrdtool-1.3.9出现了上面的问题,解决后又出现下面的问题,不能出图,最后尝试解决未果,将rrdtoo换到1.2.30没有出现问题 /usr/local/rrdtool-1.3.9/bin/rrdtool: symbol lookup error: /usr/lib64/libpango-1.0.so.0: undefined symbol: g_slice_alloc



2009/04/28:

今天在amazon上部署cacti,在安装rrdtool-1.3.7时,报错找不到 cairo-svg, cairo-pdf,pang等

注:下面所提的软件都可以从这里下载到:

按照提示安装cairo,当然,你也可以从光盘里找到并安装,我是通过编译安装的。

configure时找不到freetype和fontconfig,之前已经编译安装过这两个程序:

cp /usr/local/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/

cp /usr/local/lib/pkgconfig/fontconfig.pc /usr/lib/pkgconfig/


再次编译安装cairo即可。

编译过程中:

configure: error: pixman >= 0.10.0 is required


编译安装pixman,然后

cp /usr/local/lib/pkgconfig/pixman-1.pc /usr/lib/pkgconfig

export PKG_CONFIG_PATH=/usr/lib/pkgconfig

重新编译cairo,如果报下面的错误:

member named 'render_major'

cairo-xlib-surface.c:3425: error: 'cairo_xlib_surface_t' has no member named 'render_minor'

cairo-xlib-surface.c:3445: error: 'cairo_xlib_surface_font_private_t' has no member named 'dpy'

cairo-xlib-surface.c:3445: error: 'cairo_xlib_surface_t' has no member named 'dpy'

cairo-xlib-surface.c:3522: error: 'cairo_xlib_surface_t' has no member named 'screen_info'

make[2]: *** [libcairo_la-cairo-xlib-surface.lo] Error 1

make[2]: Leaving directory `/opt/lamp/cairo-1.6.4/src'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/opt/lamp/cairo-1.6.4'

make: *** [all] Error 2


你可能没看到最开始的错误是:

cairo-xlib.h:44:22: error: X11/Xlib.h: No such file or directory

出现这个错误,你需要安装下面的包:

libX11-devel.i386                                             

libX11-devel.x86_64  

OK,继续,终于,编译安装完成后:

cp /usr/local/lib/pkgconfig/cairo*.pc /usr/lib/pkgconfig/

同样的,编译pango-1.21.1,glib-2.15.4.tar.gz

在编译glib-2.15.4时使用这个参数

./configure  --with-libiconv=gnu

关于:configure: error: *** pkg-config too old; version 0.16 or better required.

 wget 

 ./configure --prefix=/usr/local/pkg-config

  make

  make install

因为仅仅是为了安装glib,所以,只需要export 一下就好了,

export PATH=/usr/local/pkg-config/bin:$PATH

在安装完glib以后要将PATH改回去,不然在下面安装pang时可能会找不到cario


安装pang时:

cp /usr/local/lib/pkgconfig/glib-2.0.pc /usr/lib/pkgconfig/

export LD_LIBRARY_PATH=/usr/local/lib 

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 



上面的步骤是为解决找不到pangcairo:

You should get pangocairo by nature of pango finding cairo when pango

is compiled. So the configure output of pango is probably giving you

something like:


Checking for cairo... NO


And the fix is to make sure that when you configure pango that your

PKG_CONFIG_PATH variable points to the directory in which the cairo.pc

file was installed. Something like:


PKG_CONFIG_PATH=$prefix/lib/pkgconfig


Where cairo was configured with --prefix=$prefix.


如果确认/usr/local/lib/pkgconfig里有cairo.pc,并且环境变量也已经设置正确,可以查看

pango的config.log:

configure:22265: checking for CAIRO

configure:22272: $PKG_CONFIG --exists --print-errors "cairo >= $cairo_required"

Requested 'cairo >= 1.6.4' but version of cairo is 1.4.10


很明显了,我的cairo的版本太低了,或者说装的pango装的太高了。

pango在找到cairo后,执行./configure完成时显示:

configuration:

        backends: FreeType Cairo

完成后,重新编译rrdtool-1.3.7即可

分析:编译安装时,查找lib时是通过${INSTALL_DIR}lib/pkgconfig,即有可能是/usr/lib/pkgconfig里的.pc文件来查找的,编译安装的软件将自己.pc文件安装到${INSTALL_DIR}/lib/pkgconfig里,即/usr/local/lib/pkgconfig里。


五.安装net-snmp
1.安装net-snmp

因为RedHat默认安装的SNMP服务,没有snmpwalk,snmpget这两个命令,所以需要编译安装NET-SNMP。
注:也可以通过安装net-snmp-utils,这个包来解决。
注:还有一种说法:(我这里说的安装SNMP服务并不是要求安装SNMPD,其实是Cacti需要用到net-snmp中的两个命令――snmpwalk和snmpget进行数据的采集。
我们可以直接在系统中运行snmpwalk和snmpget看是否有该命令,如果有则不用安装了)
我是使用编译安装的。
NET-SNMP官方网站:

./configure --prefix=/usr/local/net-snmp --enable-developer


安装过程中它会问你默认版本、用户名、perl模块和路径之类的问题,不理,一路回车。

make
make install


关于在64位上编译时报错:

 /usr/lib/libpopt.so: could not read symbols: File in wrong format

./configure LDFLAGS=-L/usr/lib64 --prefix=/usr/local/net-snmp --enable-developer


ln –s /usr/local/net-snmp/bin/* /usr/local/bin/
cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf


/usr/local/net-snmp/sbin/snmpd //启动SNMP服务
//在rc.local上加入一行/usr/local/net-snmp/sbin/snmpd,系统启动时启动SNMP服务


关于在使用rpm安装net-snmp时的依赖关系:

libsensors.so.3()(64bit) is needed by net-snmp-5.3.1-24.el5.x86_64

解决:安装 lm_sensors-2.10.0-3.1.x86_64.rpm


2.SNMP客户端配置
编译安装:/usr/local/net-snmp/share/snmp/snmpd.conf
rpm安装:/etc/snmp/snmpd.conf

注:不要改错了,下面的记录有多条,有的注释掉了,有的没有注释掉,需要改的是注释掉的


更改 com2sec notConfigUser default public
改为 com2sec notConfigUser 192.168.7.244 public #注 192.168.7.244 是安装cacti服务器IP,指定只有这IP才能获取本机的SNMP信息 提高安全性

更改 access notConfigGroup "" any noauth exact systemview none none
改为 access notConfigGroup "" any noauth exact all none none


将 #view all included .1 80 前面的 # 注释去掉


精简的snmpd.conf配置文件:

  1. ####
  2. # First, map the community name "public" into a "security name"
  3. #ec.name source community
  4. com2sec my_user 192.168.1.1 public
  5. ####
  6. # Second, map the security name into a group name:
  7. # groupName securityModel securityName
  8. group my_group v2c my_user
  9. ####
  10. # Third, create a view for us to let the group have rights to:
  11. # name incl/excl subtree mask(optional)
  12. view all included .1 80
  13. ####
  14. # Finally, grant the group read-only access to the systemview view.
  15. # group context sec.model sec.level prefix read write notif
  16. access my_group "" any noauth exact all none none
  17. ####
  18. # Customer
  19. pass_persist .1.3.6.1.3.1 /usr/bin/perl /usr/local/bin/iostat-persist.pl




六.安装Cacti
1.Cacti官方网站:

tar –zxvf cacti-0.8.7b.tar.gz
mv cacti-0.8.7b /usr/local/apache/htdocs/cacti


vi /usr/local/apache/htdocs/cacti/include/config.php

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";


//添加cacti用户 
useradd cacti


//修改cacti目录所属组
chown -R cacti.cacti /usr/local/apache/htdocs/cacti

//为cacti用户添加cron任务
crontab -u cacti -e

*/5 * * * * /usr/local/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1
注意:首次执行poller.php时请使用cacti用户,否则生成的rrd文件cacti将没有写入权限。



2.数据库配置

#mysql -uroot -p

Password: (初始密码为空)

mysql> create database cacti;

Query OK, 1 row affected (0.00 sec)


mysql> grant all on cacti.* to cacti@localhost identified by "cacti";

Query OK, 1 row affected (0.00 sec)


mysql>exit

# cd /usr/local/apache/htdocs/cacti

# mysql -uroot -p cacti
Password:




3.完成cacti的安装

1).在浏览器中输入:

默认用户名:admin 密码:admin

2).更改密码

3).设置cacti用到的命令路径

snmpwalk Binary Path /usr/local/ bin/snmpwalk
snmpget Binary Path /usr/local/ bin/snmpget
RRDTool Binary Path /usr/local/ bin/rrdtool
PHP Binary Path /usr/local/bin/php
Cacti Log File Path /opt/apache/htdocs/cacti/log/cacti.log
Cactid Poller File Path /usr/local/spine/bin/spine (没装spine之前没有)


4.安装spine(以前叫做cactid)

(1)、http://spine_download.php

spine 的安装需要以下支持:
net-snmp-devel (需要编译安装net-snmp时添加--enable-developer选项)
mysql 
mysql-devel (mysql源文件编译安装后默认支持)
openssl-devel (Redhat默认安装)

(2)、tar -xvzf cacti-spine-0.8.7c.tar.gz

(3)、看一下目录里的INSTALL文档

(4)、执行下面的命令(为什么要执行?上面去看INSTALL文档)

  aclocal

  libtoolize --force

  autoconf

  autoheader

  automake 

  chmod u+x configure

  ./configure --prefix=/usr/local/spine --with-mysql=/usr/local/mysql --with-snmp=/usr/local/net-snmp

  make

  make install

  cd /usr/local/spine/etc

  cp spine.conf.dist  spine.conf

 修改spine.conf里关于数据库连接的配置



(5)、使用spine,

登陆console--Configuration--Settings--poller--Poller Type改为spine
登陆console--Configuration--Settings--paths--Spine Poller File Path添加/usr/local/spine/bin/spine



七、补充

1、关于cacti的使用可以看看这篇文章
http://blog.sina.com.cn/s/blog_4e424e2101000b6o.html

2、关于错误
不出图,由于Cacti默认每5分钟到监测服务器上取一次数据,所以刚创建的监测点会出现图像不能显示的现象,需要等几分钟查看才会正常显示。

3、装完cacti后经常会预览不到图片,然而点击进去该空白图进去却是能正常显示的,原因在于cacti的设置问题,因为默认cacti是用rrdtool 1.0版本的,而我们安装的时候是用了rrdtool 1.2版,故需要作如下设置:

console->setting->General->RRDTool Utility Version 这里选择RRDTool 1.2.x显示即可正常


4、cacti console的使用:需要为每个设备建立要监控的Data sources和 Graph
(1)、cacti的流程是从Data Input Methods开始,创建一个信息采集的方法先,里面定义了采集的方法和采集需要的脚本(注意:如果使用CACTID最好使用可执行文件的全路径),可以定义一个输入和输出。输入可以为你执行这个脚本带入参数,比如连接数据库的参数,这样只要设置这个参数就可以连上不同的数据库了。输出是信息采集的输入结果,以列名+冒号+采集结果的形式返回。
(2)、然后是数据模版,里面需要选择Data Input Methods,如果数据输入方法中有参数的,这里可以设置参数,也可以选择忽略这个设置,然后到最后配置图形的时候再输入特定的参数。
(3)、创建图形模版,里面需要定义图形的ITEM,可以使用AREA方式先画一个框,然后把其他值以STACK的方式往前面的AREA上面累加。也可以使用GPRINT方式在最下面的备注那里输出些信息(一般是输入最后采集时候的值)。这里可以定义CDEF function,这个函数可以把你显示的ITEM进行转换,比如把8k转换成8192字节等,这个函数可以自定义的(可以参考Graph Management中的CDEFs中的定义来进行自定义)。
(4)、创建DATASOURCE,然后创建GRAPH。
最后可以把他们放到一个TREE上

简单的:选中Device 点击* 自动创建ds和graph

注意:在选择模板时,如果是远程服务器应该选择 ucd/net snmp host,host mib等。

     如果是本机,可以选择linux,unix。即数据模板中,Data Input Method类型类似为Linux - Get Memory Usage  Unix - Get Load Average的为取本机数据。Get SNMP Data的可以取远程服务器数据。


ucd/net snmp 指的是UCD-SNMP和NET-SNMP


5、UCD-SNMP和NET-SNMP之间的区别是什么?

实际上是一回事,NET-SNMP是现在的版本。请参看下文。
Not a great deal, really. Although the project originally started at UC Davis (hence the name), and it has always been based there, most of the contributors have had little or no connection with this institution. The move to SourceForge was intended to provide a more flexible environment for the project, and to distribute the administrative workload more evenly. The change of name simply reflects this move, which was the last remaining link with UC Davis. The 4.2.x line is the last release line that uses the ucd-snmp name, and all releases under this banner will be bug-fixes only. Release 5.0 is the first version using the net-snmp name, and all new features and significant development will be released under this name. (Though the dividing line between a bug-fix and a new feature is something of a vague one, so some changes in the 4.2.x line may be relatively non-trivial!) Starting with the 5.0 release, we are also trying to review and rework the underlying code base to improve the readability and maintainability of the package. The 5.0 changes have mostly concentrated on the agent architecture, though there have been some significant changes to the library as well. Future releases may include further restructuring of the library. This process will probably result in some changes to the API, though we will attempt to retain some form of backwards compatibility as far as possible, and clearly mark anything that has changed. The most significant change with the 5.0 release is a restructuring of the header file organisation - not least a change from to .


6、FAQ
更多见

强烈推荐好好看看这个



cacti的data sources和Graph Management均有debug。


八、关于disk usage

2010-11-29 新的解决办法:

在snmpd.conf中添加要监控的磁盘如:(详细的说明及例子在snmpd.conf中有介绍)

disk / 100000000

disk /data 1000000000

使用

Associated Data Queries

”ucd/net - Get Monitored Partitions“ 通过Verbose Query来查询数据,然后点击*Create Graphs for this Host来为数据画图。

注,对于大于1TB的磁盘,由于snmp的bug,只能监控到1TB,所以,不要使用这种方法,使用下面介绍的方法。

bug:


旧的解决办法:

似乎cacti自带的

下载:

%3Adata%3Ahost_mib%3Adisk_usage&cache=cache

Installation:

This is a pure SNMP based replacement of the standard cacti disk usage templates. It requires support by the non-standard HOST MIB, however.

untar the attached resource file

Drop hrStorageTable.xml into your /resources/snmp_queries/ folder.

Import the cacti087d_data_query_snmp_-_hrstoragetable template via import feature

Add the Data Query to a device.

From the 'Create Graphs for this Host' screen, select the required disks and click Create.

注:关于Add the Data Query to a device.这一步:

在点击菜单时,Add Data Query: 能只能看到3个,而看不到SNMP - hrStorageTable,这时使用上下翻的箭头就可以了。
添加完以后,点击(),然后就可以在*

默认的画出来的图有点大,和其他图格格不入,把他们改成一样的大小:
Width (--width)  改成500

九、有关snmp
1 netsnmp_assert !"registration != duplicate" failed agent_registry.c:535 netsnmp_subtree_load(),
这个错误不影响使用,我在使用编译安装net-snmp时出现的这个错误,是因为我更改了com2sec local localhost COMMUNITY为com2sec rhel52 192.168.7.242 public,但是下面的group却没有做相应的修改,修改正确后就不会出现这个错误了。

2 当监控其他服务器时,可以使用下面的命令测试服务器的snmp是否正常。

snmpwalk -v 2c -c public 192.168.0.1 if
该命令表示,使用SNMPV2c版本和community 名称 “public”,取服务器(192.168.0.1)的所有interface(网卡)的信息。
如果192.168.0.1的SNMP服务正常,则会返回服务器或交换设备的网卡信息。如果返回错误信息,请检查你的SNMP配置或网络是否正常。

snmpwalk -v 2c -c public 192.168.7.242 cpu
UCD-SNMP-MIB::ssCpuRawSoftIRQ.0 = Counter32: 870

snmpwalk -v 2c -c public 192.168.7.242 memory
UCD-SNMP-MIB::memIndex.0 = INTEGER: 0
UCD-SNMP-MIB::memErrorName.0 = STRING: swap
UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 819192 kB
UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 819136 kB
UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 271660 kB
UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 4864 kB
UCD-SNMP-MIB::memTotalFree.0 = INTEGER: 824000 kB
UCD-SNMP-MIB::memMinimumSwap.0 = INTEGER: 16000 kB
UCD-SNMP-MIB::memShared.0 = INTEGER: 0 kB
UCD-SNMP-MIB::memBuffer.0 = INTEGER: 8960 kB
UCD-SNMP-MIB::memCached.0 = INTEGER: 226580 kB
UCD-SNMP-MIB::memSwapError.0 = INTEGER: noError(0)
UCD-SNMP-MIB::memSwapErrorMsg.0 = STRING: 


说明snmp没问题

小技巧:可以使用snmpd -f -Le -Dread_config 命令来查看日志文件信息,排错。

有关cpu的user值为nan的解决办法(cpu利用率超100%)
原因: this server uses multiple Xeon CPUs and maybe the value is too high because it reflects the values of not only one CPU but 2 or more. ,that a dual cpu machine can have a load up to 200% - which will break the graphing。
解决:You may be correct. Check MAXIMUM values of the corresponding data source of the Data Template. If you plan to change this, remember that existing rrd files must be rrdtool tuned for this, too。

你可以更改data template模板中的MAXIMUM values来对所有的data source生效,也可以勾选MAXIMUM values下面的“ Use Per-Data Source Value (Ignore this Value)”选来,然后单独修改需要修改的datasource,



当然,你仍然需要修改已经存在的rrd文件,方法如下:

查看

rrdtool info gandalf_cpu_user_10.rrd |more 
filename = "gandalf_cpu_user_10.rrd" 
rrd_version = "0001" 
step = 300 
last_update = 1153321503 
ds[cpu_user].type = "COUNTER" 
ds[cpu_user].minimal_heartbeat = 600 
ds[cpu_user].min = 0.0000000000e+00 
ds[cpu_user].max = 1.0000000000e+02 
ds[cpu_user].last_ds = "268239" 
ds[cpu_user].value = 4.1720000000e+01 
ds[cpu_user].unknown_sec = 0 

更改:

The commands I used, in case anyone is stuck: Code:

rrdtool tune HOST_cpu_nice_46.rrd --maximum cpu_nice:200
rrdtool tune HOST_cpu_system_47.rrd --maximum cpu_system:200
rrdtool tune HOST_cpu_user_48.rrd --maximum cpu_user:200

问题解决,相关:


spine 的debug

/usr/local/spine/bin/spine -C /usr/local/spine/etc/spine.conf --verbosity=5   -H 8

其中-H为device的ID,可以在devices菜单中看到



nginx client为NAN的问题

手动运行脚本,能够正常出数据,但是当poller为spine时,output却为0.

debug:
 /usr/local/spine/bin/spine -C /usr/local/spine/etc/spine.conf --verbosity=5 -H 3
其中-H 3为指定host,host的ID可以在device中看到。
问题出在输出的数据的格式上,去掉每行print后面的空格和回车。
或者:打补丁


关于
last message repeated 2 times
解决:vi /etc/init.d/snmpd

#   OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd -a"
OPTIONS="-LS 0-4 d -Lf /dev/null -p /var/run/snmpd.pid -a"

servie snmpd restart



4
不出图,cacti.log有下面的错误(该问题可能出现在安装php之前没有关闭selinux的情况下)
07/15/2008 05:55:00 PM - POLLER: Poller[0] Maximum runtime of 298 seconds exceeded. Exiting.
07/15/2008 05:55:00 PM - SYSTEM STATS: Time:299.0878 Method:spine Processes:1 Threads:1 Hosts:3 HostsPerProcess:3 DataSources:17 RRDsProcessed:0
使用cmd.php则没有问题
解决:
使用cacti用户手动执行poller.php,将错误重定向到一个文件中
/usr/local/bin/php /usr/local/apache/htdocs/cacti/poller.php > ./123 2>&1
查看错误
[cacti@send4 ~]$ cat 123
/usr/local/spine/bin/spine: error while loading shared libraries: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory

[cacti@send4 ~]$  ldd /usr/local/spine/bin/spine
        linux-gate.so.1 =>  (0x00c8b000)
        libnetsnmp.so.15 => /usr/local/net-snmp/lib/libnetsnmp.so.15 (0x00458000)
        libmysqlclient_r.so.15 => not found
        libcrypto.so.6 => /lib/libcrypto.so.6 (0x490f9000)
        libz.so.1 => /usr/lib/libz.so.1 (0x4857c000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x48563000)
        libm.so.6 => /lib/libm.so.6 (0x48534000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x48ff3000)
        libc.so.6 => /lib/libc.so.6 (0x483f5000)
        libdl.so.2 => /lib/libdl.so.2 (0x4855d000)
        /lib/ld-linux.so.2 (0x483d3000)
做个软链接,问题解决
ln -s /usr/local/mysql/lib/libmysqlclient_r.so.15 /usr/lib


关于现使用Cacti对网关服务器监控,发现CPU监控的结果有时显示为占用主频,有时显示为百分比形式,在Graph Template中的ucd/net CPU usage 可以选择
GPRINT Type----选择:Percent






关于cacti服务器宕机后,造成mysql表损坏,查看cact.log,有下面的错误:
  1. 02/16/2011 05:40:02 PM - SPINE: Poller[0] FATAL: MySQL Error:'1194', Message:'Table 'poller_item' is marked as crashed and should be
  2. repaired' (Spine thread)
  3. 02/16/2011 05:40:03 PM - SPINE: Poller[0] FATAL: MySQL Error:'126', Message:'Incorrect key file for table './cacti/poller_item.MYI';
  4. try to repair it' (Spine thread)
解决:
  1. /usr/local/mysql/bin/mysqlcheck -ucacti_username -pcacti_password --auto-repair --databases cacti

关于迁移时:
ERROR: This RRD was created on another architecture
ERROR: This RRD was created on another architecture
ERROR: This RRD was created on another architecture

解决:
先dump出rrd文件里的内容,然后restore到新的服务器上
dump

  1. #!/bin/bash
  2. dir="/usr/local/nginx/html/cacti"
  3. for fh in `$dir/rra`
  4. do
  5. bn=`basename $fh`
  6. bn_no_rrd=`echo $bn|awk -F ".rrd" '{print $1}'`
  7. echo $bn_no_rrd
  8. rrdtool dump $dir/$fh /tmp/$bn_no_rra.restore
  9. done

restore
  1. #!/bin/bash
  2. dir="/usr/local/nginx/html/cacti"
  3. for fh in `ls /tmp/rra`
  4. do
  5. bn=`basename $fh`
  6. bn_no_rrd=`echo $bn|awk -F ".restore" '{print $1}'`
  7. echo $bn_no_rrd
  8. rrdtool restore /tmp/rra/$bn $dir/rra/$bn_no_rrd.rrd
  9. done
  10. chown -R cacti.cacti $dir/rra

阅读(6203) | 评论(0) | 转发(0) |
0

上一篇:awstats日志分析

下一篇:一些不常用的命令

给主人留下些什么吧!~~