Use cacti monitor http online users
1.vi /etc/snmp/snmpd.conf, add scripts
extend .1.3.6.1.4.1.2021.50 tuhttp /bin/bash /opt/httpd2/conf/tuhttp.sh
2.vi tuhttp.sh
#!/bin/bash
num=$(ps -e |grep http|grep -v grep|grep -v jkhttp|wc -l)
#num=$(grep "ONLINE USERS=" /opt/photo/log/tu.log | sed '$!d' | sed 's/\(.*\)USERS=\([0-9]*\)$/\2/')
echo $num
echo OK
ps: tu.log is my system log, ignore
3.reload snmpd
/etc/init.d/snmpd reload
4.check snmp info
snmpwalk -v 2c 10.30.0.22 -c public .1.3.6.1.4.1.2021.50
display:
UCD-SNMP-MIB::ucdavis.50.1.0 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.50.2.1.2.6.116.117.104.116.116.112 = STRING: "/bin/bash"
UCD-SNMP-MIB::ucdavis.50.2.1.3.6.116.117.104.116.116.112 = STRING: "/opt/httpd2/conf/tuhttp.sh"
UCD-SNMP-MIB::ucdavis.50.2.1.4.6.116.117.104.116.116.112 = ""
UCD-SNMP-MIB::ucdavis.50.2.1.5.6.116.117.104.116.116.112 = INTEGER: 5
UCD-SNMP-MIB::ucdavis.50.2.1.6.6.116.117.104.116.116.112 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.50.2.1.7.6.116.117.104.116.116.112 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.50.2.1.20.6.116.117.104.116.116.112 = INTEGER: 4
UCD-SNMP-MIB::ucdavis.50.2.1.21.6.116.117.104.116.116.112 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.50.3.1.1.6.116.117.104.116.116.112 = STRING: "3"
UCD-SNMP-MIB::ucdavis.50.3.1.2.6.116.117.104.116.116.112 = STRING: "3
OK"
UCD-SNMP-MIB::ucdavis.50.3.1.3.6.116.117.104.116.116.112 = INTEGER: 2
UCD-SNMP-MIB::ucdavis.50.3.1.4.6.116.117.104.116.116.112 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.50.4.1.2.6.116.117.104.116.116.112.1 = STRING: "3"
UCD-SNMP-MIB::ucdavis.50.4.1.2.6.116.117.104.116.116.112.2 = STRING: "OK"
ps:we need .1.3.6.1.4.1.2021.50.3.1.1.6.116.117.104.116.116.112
5.add cacti data templates
Console -> Data Templates

6.add cacti graph templates
Console -> Graph Templates

7.add these templates to host
Console -> Devices -> Create Graphs for this Host
refer: http://bbs.linuxtone.org/thread-1372-1-1.html
Compile Memcached + Php extension at Centos5.2 x64
1.get source
wget http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz
wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
2.compile libevent
tar -zxvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure
make
make install
3.compile memcached
tar -zxvf memcached-1.4.4.tar.gz
cd memcached-1.4.4
./configure --prefix=/opt/memcached --with-libevent
make
make install
4.start memcached
cd /opt/memcached/bin
./memcached -d -m 256 -p 11211 -u root // -d daemon, -m ram, -p port default is 11211, -u user
if your os is 64bit maybe get a error "cant find libevent" try this
在 64bit 系统启动,会报找不到 libenent,可以如下操作
cp -R /usr/local/lib/libevent* /usr/lib64/
5.php memcache ext
wget http://pecl.php.net/get/memcache-2.2.4.tgz
cd memcache-2.2.4
whereis php-config
whereis phpize
phpize && ./configure --enable-memcache --with-php-config=/usr/local/bin/php-config
make
make test
make install
vi /usr/local/lib/php.ini
extension_dir = "/usr/local/lib/php/extensions/no-debug-zts-20060613/"
extension = "memcache.so"
6.monitor memcached
wget http://livebookmark.net/memcachephp/memcachephp.zip
put memcache.php file to wwwroot
vi memcache.php
define('ADMIN_USERNAME','user'); // Admin Username
define('ADMIN_PASSWORD','pass'); // Admin Password
$MEMCACHE_SERVERS[] = 'yourMemCachedHost:11211'; // add more as an array
http://host.com/memcache.php
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

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

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
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: /
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
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,大功告成。
btw: tomcat 启动内存调节
编辑 catalina.sh 添加下面的内容
JAVA_OPTS='-Xms1024m -Xmx2048m'
change to wordpree
最近偶得 spb 越來越慢 Page Generated 有時居然要達到 70s emoticon,在忍無可忍的情況下偶準備換一個 php+mysql 的 blog 程序(原來 spb 是 textbase 的),在 bblog/wordpress 優於了半天最後還是選擇了比較大路的 wordpress,希望不會讓偶再換了。
apache 253 + mod_jk2
将一台 apache+resin 的服务器换成了 apache+mod_jk2,发现负载一下低了很多有可能是原来 resin 配置的问题偶没有做深究
大概的配置贴在论坛上了
PPTP Server Behind Firewall
pptpd 需要映射两个 port
TCP destination port = 1723 (0x6BB) Allows PPTP tunnel maintenance traffic from the PPTP client to the PPTP server.
IP Protocol ID = 47 (0x2F) Allows PPTP tunneled data from the PPTP client to the PPTP server.
在 iptables gw 增加下面的 rules
iptables -t nat -A PREROUTING -d a.b.c.d -p tcp –dport 1723 -j DNAT –to-destination 192.168.0.2
iptables -t nat -A PREROUTING -d a.b.c.d -p 47 -j DNAT –to-destination 192.168.0.2
iptables -t nat -A POSTROUTING -s 192.168.0.2-o eth0 -j MASQUERADE
iptables -A FORWARD -d 192.168.0.2 -i eth1 -p tcp -m tcp –dport 9000 -j ACCEPT
iptables -A FORWARD -d 192.168.0.2 -i eth1 -p 47 -j ACCEPT
change httpd
今天起了个大早本准备重新配置一下 apache/php 但不晓得为虾米在 compile php 的时候无法生成 libphp4.so google 一上午依然无果
无奈之下只好换成 zeus,同样的 php 版本编译成 fastcgi 一点问题没有,真是郁闷咧.
set notes forward
在 notes 5.x 的系统,每个用户只能设置一个转发地址,而最要命的是被设置转发的用户自己收再也收不到邮件.所以要设置一个邮件转发多人的情况,需多增设一个群组.
以我们公司 hr 邮件做比方
对外统一公开使用 hr@urcompany.com,内部增加 hr1/hr2/hr3 等邮件用户,将 123 统一加入一个群组比如”人事部邮箱”.然后设置 hr 这个用户的转发地址为群组名.这样以后如有新用户使用 hr 信箱直接加入群组即可.
host is down
由于种种原因,偶 PiGGY 的主机在十二月二日 shutdown 咯(5555~~~)上面所有的 epop 基本已 mirror 到 tiggy。近几天一直忙于迁移自己的 web 和论坛,这里感谢 bluewolf 兄提供给偶 free 的主机使用(momo),顺带也要感谢 cy sama 帮做 dns 解析!
btw:piggy 上的 bnc 可以继续使用,关闭日期未知。




