Monthly Archives: June 2009

cacti install and threshold settings

CentOS5.2 x64/ net-snmp 5.3.1 / rrd-tool 1.2.30
Cacti 0.8.7d
cacti-plugin-0.8.7d-PA-v2.4
Settings – v0.5
Thold – v0.4.1

1. install package

yum -y install httpd
yum -y install php
yum -y install php-mysql
yum -y install php-snmp
yum -y install mysql-server
yum -y install perl
yum -y install net-snmp-utils
yum -y install libpng
yum -y install freetype
yum -y install libart_lgpl

2. set chkconfig

chkconfig httpd on
chkconfig mysqld on

3.download rrdtool http://oss.oetiker.ch/rrdtool/download.var

wget http://dag.wieers.com/rpm/packages/rrdtool/perl-rrdtool-1.2.23-1.el5.rf.i386.rpm
wget http://dag.wieers.com/rpm/packages/rrdtool/rrdtool-1.2.23-1.el5.rf.i386.rpm

4.install rddtool

rpm -ivh perl-rrdtool-1.2.23-1.el5.rf.i386.rpm rrdtool-1.2.23-1.el5.rf.i386.rpm

5. change mysql charset
vi /etc/my.cnf

[mysqld]
collation-server = utf8_general_ci
default-collation = utf8_general_ci
character-set-server = utf8
default-character-set = utf8

6. download cacti

wget http://www.cacti.net/downloads/cacti-0.8.7d.tar.gz
tar zxvf cacti-0.8.7d.tar.gz

7. download cacti-plugin-0.8.7d-PA-v2.4.zip from cactiuser & extract it
2 method of install:

1) cd /path/cacti-0.8.7d && patch -p1 -N –dry-run < /path/to/cacti-plugin-0.8.7d-PA-v2.4.diff
2) cd /path/cacti-0.8.7d && cp -R /path/to/files-0.8.7d/* ./

注: 第一种方式在我这里报错了,官方论坛上也有提及,如果你也有遇到可以直接用第二种方式更新

8. imp cacti db

mysqladmin create cacti
mysql -u root -p cacti < /path/to/cacti.sql
mysql -u root -p cacti < /path/to/pa.sql
mysql> create user cacti@’localhost’;
mysql> create user cacti@’127.0.0.1′;
mysql> grant all privileges on cacti.* to cacti@’localhost’;
mysql> grant all privileges on cacti.* to cacti@’127.0.01′;
mysql> set password for cacti@’localhost’ = password(’cactipasswd’);
mysql> set password for cacti@’127.0.0.1′ = password(’cactipasswd’);

9. ensure the db-section at global.php is correct

vi /opt/www/html/cacti/include/global.php #–>check this section: /* Default database settings*/

10. set crontab
crontab -u cacti -e

*/5 * * * * /usr/bin/php /opt/www/html/cacti/poller.php > /dev/null 2>&1

11. install threshold

wget http://cactiusers.org/downloads/settings.tar.gz
wget http://cactiusers.org/downloads/thold.tar.gz
wget http://cactiusers.org/downloads/monitor.tar.gz

12. exract

tar zxvf settings.tar.gz
tar zxvf thold.tar.gz
tar zxvf monitor.tar.gz

13. place plug-in files into appropriate directory

mv settings /opt/www/html/cacti/plugins/
mv thold /opt/www/html/cacti/plugins/
mv monitor /opt/www/html/cacti/plugins/

14. update mysql db

mysql -u root -p cacti < thold.sql
mysql -u root -p cacti < monitor.sql

15. activate plug-ins now:
vi /opt/www/html/cacti/include/global.php

$plugins = array();
$plugins[] = ’settings’;
$plugins[] = ‘thold’;
$plugins[] = ‘monitor’;

16. After installation, the 1st thing u need do is edit admin account, otherwise the “plug-in management” & “ThreshHold Templates” will not be added into console tab
Console -> User Management -> admin
cacti user

cacti plugin

Now go to:
Console -> Plugin Management
At “Thresholds”, click “Install” & “Enable”
enable thresholds

17. Use Tholds
17.1 mail settings
Go to console -> Settings select the “Mail/DNS” tab
Go to console -> Settings select the “Alerting/Thold” tab
enable “Dead Hosts Notifications”
Dead Host Notifications Email: enter the web-admin mail account
From Email Address: cacti alert mail accout
Save the configuration.
Then we will receive alter-mail when a host goes down or up:

17.2 create Threshhold Templates
Go to Console -> Threshhold Templates
Create Threshhold Templates you need

17.3 Apply the Threshhold Templaes

Then Go to Console -> devices
Click the device you want to apply the Threshhold Template
And then click “Create Graphs for this Host”

Create Graphs for this Host -> Auto-create thresholds

17.4 some threshold examples

Create disk usage Thold template
When (used_space/total_space%) > 90%, cacti will send alert mail
4.1.1 Add “VALUE_OF_HDD_TOTAL” at global _arrays.php

vi /opt/www/html/cacti/include/global _arrays.php
add VALUE_OF_HDD_TOTAL

find

$custom_data_source_types = array(

add

“VALUE_OF_HDD_TOTAL” => “Value of hdd_total data source”,

add a new CDEF
Now go to Console -> Graph Management -> CDEFs click “Add” to add a new CDEF
Add new CDEF named like “Used Disk Space Percent”, at this CDEF, add 5 items:

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: /

cdef

create new Threshold Templates
Go to Console -> Threshold Templates -> click Add
For linux host, we choose “ucd/net – CPU Usage – user” template;
for windows host, we choose “Host MIB – Hard Drive Space” template
this depends on what templates we used in device graphic:

Data Field: hdd_used
Enabled: yes
Threshold Type: High / Low
High Threshold: 90
Low Threshold: 0
Data Type: CDEF

Threshold CDEF: Used Disk Space Percent (the CDEF Name we just created)
Alert E-Mail: the email-address that alert message will send to

ucdnet memroy usage linux
cacti_graph_template_ucdnet_-_memory_usage_linux

graph_image

Reference:

http://forums.cacti.net/viewtopic.php?t=13829

http://cactiusers.org/wiki/TholdDocs

http://www.bsdmap.com/2008/12/07/how-to-install-cacti/

pyopyo docs

httpd2.2 tomcat5.5 mod_jk integration

httpd 编译参数

./configure –prefix=/opt/httpd2/ \
–with-mpm=worker \
–enable-ssl \
–enable-cache \
–enable-disk-cache \
–enable-mem-cache \
–enable-rewrite \
–enable-usertrack \
–enable-proxy \
–enable-proxy-connect \
–enable-proxy-http \
–enable-deflate

编译安装

make && make install

下载 mod_jk 并 cp 至 httpd modules 目录(请根据自己的发行版选择,这里使用 centos 52 x64)

wget http://apache.etoak.com/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.28/x86_64/mod_jk-1.2.28-httpd-2.2.X.so
cp /where/is/your/mod_jk-1.2.28-httpd-2.2.X.so /opt/httpd2/modules/mod_jk.so

配置 workers.properties
vi /opt/httpd2/conf/workers.properties

#
# workers.properties
#
# list the workers by name
worker.list=s1
# localhost server 1
# ————————
worker.s1.port=8009
worker.s1.host=localhost
worker.s1.type=ajp13

配置 http.conf 添加 modjk 参数
vi /opt/httpd2/conf/httpd.conf

LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat “%w %V %T”
JkLogFile logs/mod_jk.log
JkLogLevel error

添加动态页面转发

JkMount /*.jsp s1
JkMount /*.action s1
JkMount /*Servlet* s1

httpd-mpm.conf 参数

ServerLimit 30
StartServers 2
ThreadLimit 200
MaxClients 3000
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 100
MaxRequestsPerChild 10000

配置 tomcat server.xml
默认的 server.xml 过于臃肿,可以使用 server-minimal.xml 代替

vi /opt/tomcat5/conf/server.xml
修改 8009 的参数

maxTreads=”800″ minSpareThreads=”10″ maxSpareThreads=”50″
acceptCount=”50″ connectionTimeout=”60000″
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

配置 context,注意 docBase 和 httpd 的 DocumentRoot 一致


unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

重启动 tomcat 和 httpd,大功告成。 :35:

btw: tomcat 启动内存调节
编辑 catalina.sh 添加下面的内容

JAVA_OPTS=’-Xms1024m -Xmx2048m’