最近装了台server用来对网络设备进行准实时监控
系统组成
Centos5.2
mysql -4.1.22
php-4.6.4
apache2.1.2
cacti 0.8.7d
rrdtool 1.0.5 为什么还使用1.0.5呢,主要是这个版本集成了很多库,安装调试方便,而只是生成的图稍微颗粒点,没有多大的关系。
NET-snmp5.1.22
spine-0.8.7c
本来不打算安装spine的,就使用cmd.php来完成数据采集,可是后来发现cmd.php采集存在很大的延迟,执行效率太低了。两厢比较了一下,从添加device好到设备up,spine只需要不到一分钟,而cmd等的时间较长,超过10分钟。
当设备down后 2分钟之内spine可以发出alert,而cmd可能需要10分钟以上。
所以还是要使用spine
当设备down后 2分钟之内spine可以发出alert,而cmd可能需要10分钟以上。
所以还是要使用spine
=========================
顺便一提:最近因为搞这个监控,找来找去到最后发现cacti的报警使用移动的邮箱最好了! 139的邮箱现在提供“邮件到达通知”而且是免费的,只要有邮件到达,就会有一个短消息给你。
2009年3月份139邮箱升级后,邮件到达通知可以有好多选择,支持超长短信了。把接受到的邮件主题和内容作为短信发送给你,长度达到350个字符!
使用139邮箱,实现cacti实时报警发送sms的很有效途径,我觉得比网络上现在那些所谓的pushmail及时、准确多了。关键是不用花钱!!
=========================
下载的是cacti-spine-0.8.7c
tar -zxvf ./tools/cacti-spine-0.8.7c.tar.gz 按照install文档执行之!
[root@mycentos52 cacti-spine-0.8.7c]# aclocal
[root@mycentos52 cacti-spine-0.8.7c]# libtoolize --force
Using `AC_PROG_RANLIB' is rendered obsolete by `AC_PROG_LIBTOOL'
Putting files in AC_CONFIG_AUX_DIR, `config'.
[root@mycentos52 cacti-spine-0.8.7c]# autoconf
[root@mycentos52 cacti-spine-0.8.7c]# autoheader
[root@mycentos52 cacti-spine-0.8.7c]# automake
[root@mycentos52 cacti-spine-0.8.7c]# ./configure
-bash: ./configure: Permission denied
[root@mycentos52 cacti-spine-0.8.7c]# chmod 755 configure
[root@mycentos52 cacti-spine-0.8.7c]# ./configure
checking build system type... i686-redhat-linux-gnu
checking host system type... i686-redhat-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
[root@mycentos52 cacti-spine-0.8.7c]# aclocal
[root@mycentos52 cacti-spine-0.8.7c]# libtoolize --force
Using `AC_PROG_RANLIB' is rendered obsolete by `AC_PROG_LIBTOOL'
Putting files in AC_CONFIG_AUX_DIR, `config'.
[root@mycentos52 cacti-spine-0.8.7c]# autoconf
[root@mycentos52 cacti-spine-0.8.7c]# autoheader
[root@mycentos52 cacti-spine-0.8.7c]# automake
[root@mycentos52 cacti-spine-0.8.7c]# ./configure
-bash: ./configure: Permission denied
[root@mycentos52 cacti-spine-0.8.7c]# chmod 755 configure
[root@mycentos52 cacti-spine-0.8.7c]# ./configure
checking build system type... i686-redhat-linux-gnu
checking host system type... i686-redhat-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for mysql_init in -lmysqlclient_r... no
configure: error: MySQL libraries not found
下载 mysql的共享包
检查安装位置:
rpm -qlp MySQL-shared-standard-4.1.22-0.rhel4.i386.rpm
/usr/lib/libmysqlclient.so
/usr/lib/libmysqlclient.so.15
/usr/lib/libmysqlclient.so.15.0.0
/usr/lib/libmysqlclient_r.so
/usr/lib/libmysqlclient_r.so.15
/usr/lib/libmysqlclient_r.so.15.0.0
/usr/lib/libndbclient.so
/usr/lib/libndbclient.so.2
/usr/lib/libndbclient.so.2.0.0
检查安装位置:
rpm -qlp MySQL-shared-standard-4.1.22-0.rhel4.i386.rpm
/usr/lib/libmysqlclient.so
/usr/lib/libmysqlclient.so.15
/usr/lib/libmysqlclient.so.15.0.0
/usr/lib/libmysqlclient_r.so
/usr/lib/libmysqlclient_r.so.15
/usr/lib/libmysqlclient_r.so.15.0.0
/usr/lib/libndbclient.so
/usr/lib/libndbclient.so.2
/usr/lib/libndbclient.so.2.0.0
执行安装:
[root@mycentos52 tools]# rpm -ivh MySQL-shared-standard-4.1.22-0.rhel4.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-shared-standard ########################################### [100%]
[root@mycentos52 tools]# rpm -ivh MySQL-shared-standard-4.1.22-0.rhel4.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-shared-standard ########################################### [100%]
查看:
[root@mycentos52 tools]# cd /usr/lib
[root@mycentos52 lib]# ls libmysql*
libmysqlclient_r.so libmysqlclient_r.so.14.0.0 libmysqlclient.so.14
libmysqlclient_r.so.14 libmysqlclient.so libmysqlclient.so.14.0.0
[root@mycentos52 lib]#
[root@mycentos52 tools]# cd /usr/lib
[root@mycentos52 lib]# ls libmysql*
libmysqlclient_r.so libmysqlclient_r.so.14.0.0 libmysqlclient.so.14
libmysqlclient_r.so.14 libmysqlclient.so libmysqlclient.so.14.0.0
[root@mycentos52 lib]#
执行spine的编译:
[root@mycentos52 cacti-spine-0.8.7c]#./configure
checking for mysql_thread_init in -lmysqlclient_r... yes
configure: error: Cannot find SNMP headers. Use --with-snmp= to specify non-default path.
提示snmp的目录没有发现,指定自己安装的snmp的目录后再进行编译
[root@mycentos52 cacti-spine-0.8.7c]#./configure
checking for mysql_thread_init in -lmysqlclient_r... yes
configure: error: Cannot find SNMP headers. Use --with-snmp= to specify non-default path.
提示snmp的目录没有发现,指定自己安装的snmp的目录后再进行编译
[root@mycentos52 cacti-spine-0.8.7c]#
./configure --with-snmp=/usr/local/net-snmp/
checking if UCD-SNMP needs crypto support... no
checking if Net-SNMP needs crypto support... yes
checking for snmp_timeout in -lnetsnmp... yes
checking for the spine results buffer size... 1024 bytes
checking for the maximum simultaneous spine .s... 20
checking for the maximum MySQL buffer size... 65536
checking whether we are using nifty popen... no
checking for glibc gethostbyname_r... yes
checking for Solaris/Irix gethostbyname_r... no
checking for HP-UX gethostbyname_r... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config/config.h
config.status: executing depfiles commands
编译成功了!
checking if UCD-SNMP needs crypto support... no
checking if Net-SNMP needs crypto support... yes
checking for snmp_timeout in -lnetsnmp... yes
checking for the spine results buffer size... 1024 bytes
checking for the maximum simultaneous spine .s... 20
checking for the maximum MySQL buffer size... 65536
checking whether we are using nifty popen... no
checking for glibc gethostbyname_r... yes
checking for Solaris/Irix gethostbyname_r... no
checking for HP-UX gethostbyname_r... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config/config.h
config.status: executing depfiles commands
编译成功了!
下面
make;make install
将产生spine的安装目录[root@mycentos52 spine]#pwd
/usr/local/spine
[root@mycentos52 spine]#cp ./etc/spine.conf.dist ./spine.conf 建立spine的配置文件
[root@mycentos52 etc]# vi spine.conf
检查数据库名、用户名等
将产生spine的安装目录[root@mycentos52 spine]#pwd
/usr/local/spine
[root@mycentos52 spine]#cp ./etc/spine.conf.dist ./spine.conf 建立spine的配置文件
[root@mycentos52 etc]# vi spine.conf
检查数据库名、用户名等
试着运行spine看行不行?、
./spine
SPINE: Using spine config file [spine.conf]
MYSQL: Connection Failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
11/02/2007 04:02:51 PM - SPINE: Poller[0] FATAL: Connection Failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) (Spine init)
./spine
SPINE: Using spine config file [spine.conf]
MYSQL: Connection Failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
11/02/2007 04:02:51 PM - SPINE: Poller[0] FATAL: Connection Failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) (Spine init)
google问题,最后
在/var/lib/ 下建立mysql文件夹
[root@monitor mysql]# pwd
/var/lib/mysql
[root@monitor mysql]#
在/var/lib/ 下建立mysql文件夹
[root@monitor mysql]# pwd
/var/lib/mysql
[root@monitor mysql]#
[root@monitor mysql]#
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
产生一个mysql.sock 的文件。 和tmp目录下的连接起来。 tmp下的mysql.sock 是安装mysql的时候产生的,而/var/lib/mysql/mysql.sock ln产生的。
产生一个mysql.sock 的文件。 和tmp目录下的连接起来。 tmp下的mysql.sock 是安装mysql的时候产生的,而/var/lib/mysql/mysql.sock ln产生的。
然后
[root@mycentos52 bin]# ./spine
SPINE: Using spine config file [../etc/spine.conf]
SPINE: Version 0.8.7c starting
SPINE: Time: 2.8546 s, Threads: 1, Hosts: 5
[root@mycentos52 bin]#
SPINE: Using spine config file [../etc/spine.conf]
SPINE: Version 0.8.7c starting
SPINE: Time: 2.8546 s, Threads: 1, Hosts: 5
[root@mycentos52 bin]#
不知道spine的conf文件是怎么回事,一定要到/var/lib/mysql/下去找mysql.sock 这个文件。也不知道怎么调整。所以就做了这么个ln来解决。