一 memcached
This template provides a host template and associated graphs for
graphing the output of the stats command on individual
installations.
Graphs are provided for
Bytes Used with total capacity,
Cache Hits and Misses per second,
Current Connections,
Items Cached, Inbound and Outbound
Network Traffic (bits per second), and
Requests per Second for both the get and set
commands.
The latest version and installation instructions can be found at
http://dealnews.com/developers/cacti/memcached.html.
cacti服务器使用python的memcached客户端,通过执行memcached stats command 来获取数据。
1、下载并安装memcached的pythoh客户端
ftp://ftp.tummy.com/pub/python-memcached/
当前版本:ftp://ftp.tummy.com/pub/python-memcached/python-memcached-1.47.tar.gz
安装:
tar -xvzf python-memcached-1.47.tar.gz
- [root@111 python-memcached-1.47]# python setup.py install
-
Traceback (most recent call last):
-
File "setup.py", line 3, in ?
-
from setuptools import setup
-
ImportError: No module named setuptools
缺少python的setuptools模块:
模块地址:
python -v 查看python版本
下载对应版本的模块:2.4
安装: ./setuptools-0.6c11-py2.4.egg
setuptools安装完成,再次安装memcache client
python setup.py install
2、安装cacti模板
下载:http://s1.dlnws.com/dealnews/developers/cacti-memcached-1.0.tar.gz
tar -xvzf cacti-memcached-1.0.tar.gz
cp memcached.py /scripts/
注:端口非11211? 修改该文件
测试:
python //scripts/memcached.py 192.168.1.11
- total_items:177745693 get_hits:9646440970 uptime:24449942 cmd_get:9816729275 time:1297481502 bytes:17871442 curr_connections:118 connection_structures:1187 bytes_written:2234868242829 limit_maxbytes:838860800 cmd_set:177748658 curr_items:46090 rusage_user:42798.648616 get_misses:170288305 rusage_system:133395.413814 bytes_read:353584260005 total_connections:175559625
打开cacti的consol,Import Templates,选择cacti_memcached_host_template.xml
3、为相应的服务器添加绘图
服务器ID为公网IP,而memcache监听在内网IP?
cacti console ->Data Templates->Host to query for memcached statistics.
勾选 Use Per-Data Source Value (Ignore this Value)
修改相应的服务器的Data Sources,Host to query for memcached statistics.添写内部ip
二 tomcat
数据来源:使用脚本,获取tomcat manager的数据。
1、配置tomcat
打开tomcat的manager
修改tomcat-usr.xml文件:
restart tomcat
?XML=true
2、配置cacti
(1)确保安装了需要的 XML::Simple模块
perl -MCPAN -e"install XML::Simple"
(2)拷贝tomcatstats.pl脚本到/scripts/
(3) 测试脚本
./tomcatstats.pl 1.1.1.1:8080 admin password http-8080
- jvm_memory_free:453432112 jvm_memory_max:932118528 jvm_memory_total:837353472
- connector_max_time:1008 connector_error_count:26 connector_bytes_sent:16899331953
- connector_processing_time:4441262 connector_request_count:3714312
- connector_bytes_received:0 connector_current_thread_count:64
- connector_min_spare_threads: connector_max_threads:1000
- connector_max_spare_threads: connector_current_threads_busy:1
其中http-8080是你要监控的tomcat的connector,一般是http-8080,可以通过下图看出
(4)导入cacti模板
A. Import the cacti_host_template_tomcat_server.xml into Cacti
B. If you used a password other than "passwords" or need to monitor a different connector:
Modify "Data Input Methods:Tomcat Status:Input String" as needed.
(5) 绘图
关于图片下面的注释,可以通过下面的方法修改或移除:
关于:Heap Statistics,不出图
打开data source中的debug,可以看到错误:
RRDTool Says:
ERROR: invalid y-grid format 解决办法:Templates->Tomcat - Heap Statistics->Unit Grid Value (--unit/--y-grid) ,将已经填入的值1048576清空
connection rate也不出图?按照上面的方法,清空已经填入的值
不能出图?
手动运行脚本,能够正常出数据,但是当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后面的空格和回车。
用于短信报警:
- #!/usr/bin/perl
-
#use strict;
-
use XML::Simple;
-
use Date::Format;
-
use Date::Parse;
-
-
sub current_time {
-
time2str("%Y%m%d-%T",str2time(ctime(time)))
-
};
-
-
my $host = "1.1.1.17:8080";
-
my $username = "admin";
-
my $password = "admin";
-
my $connector = "http-8080";
-
my $url = ""."\@$host/manager/status?XML=true";
-
-
my $xml = `GET $url`;
-
-
my $status = XMLin($xml);
-
-
-
$threads_count="$status->{connector}->{$connector}->{threadInfo}->{currentThreadCount}" ;
-
-
-
open $html,">","/usr/local/nginx/html/threats.html" or die $i;
-
-
( $threads_count > 800 )?print $html current_time().": false":print $html current_time().": ok";
上面的GET
我没有找到出自哪个RPM包,所以用下面的方法处理:
源自:
将bin目录下的lwp-request文件拷贝到/usr/bin目录下了
cp ./bin/lwp-request /usr/bin/GET
阅读(4156) | 评论(1) | 转发(0) |