環(huán)境:
主要從事網(wǎng)頁設(shè)計、PC網(wǎng)站建設(shè)(電腦版網(wǎng)站建設(shè))、wap網(wǎng)站建設(shè)(手機版網(wǎng)站建設(shè))、自適應(yīng)網(wǎng)站建設(shè)、程序開發(fā)、微網(wǎng)站、小程序制作等,憑借多年來在互聯(lián)網(wǎng)的打拼,我們在互聯(lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)積累了豐富的網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計、網(wǎng)絡(luò)營銷經(jīng)驗,集策劃、開發(fā)、設(shè)計、營銷、管理等多方位專業(yè)化運作于一體,具備承接不同規(guī)模與類型的建設(shè)項目的能力。
tomcat:apache-tomcat-7.0.35
cactiEZ:10.1
系統(tǒng):centos5.6_x64
一、配置tomcat服務(wù)器
1、添加賬號
vim tomcat-users.xml
<role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="admin" password="123" roles="manager-script,manager-jmx,manager-status"/>
重啟tomcat
2、安裝snmp協(xié)議
yum -y install net-snmp
vim /etc/snmp/snmpd.conf
com2sec notConfigUser default public
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
view all included .1 80
access notConfigGroup "" any noauth exact all none none
/etc/rc.d/init.d/snmpd restart
3、測試snmp
測試本機:snmpwalk -c public -v 2c localhost
測試遠程主機:snmpwalk -V 2c -C public -H 192.168.1.133 -L
二、配置cactiEZ
安裝 XML::Simple模塊
安裝方法: (perl -MCPAN -e "install XML::Simple")
三、下載模板,導入模板
1、載監(jiān)控tomcat的模板
TomcatStats-0.1.zip
2、修改tomcatstats.pl,將
my $url = "http://$username:$password"."\@$host/manager/status?XML=true"; my $xml = `GET $url`;
替換以下兩行為:
my $url = "http://$host/manager/status?XML=true"; my $xml = `wget -qO - --http-user=$username --http-password=$password $url`;
說明:此處的-qO中的O為大寫字母歐O;不然在你導入之后很可能出現(xiàn)數(shù)據(jù)出不來。
4、導入模板(cacti_host_template_tomcat_server.xml)
進入cacti --< Console(控制臺) ---< Import Templates(導入模板)
5、上傳監(jiān)控腳本
將tomcatstats.pl上傳放到cactiEZ服務(wù)器的/var/www/html/scripts目錄下。
四、測試腳本
#/usr/bin/perl tomcatstats.pl 192.168.1.201:8080 admin 123 \"http-bio-8080\"
jvm_memory_free:9029383656 jvm_memory_max:9963962368 jvm_memory_total:9963962368 connector_max_time:75 connector_error_count:4 connector_bytes_sent:14896 connector_processing_time:104 connector_request_count:7 connector_bytes_received:0 connector_current_thread_count:11 connector_max_threads:1000 connector_current_threads_busy:1 [root@CactiEZ scripts]#
1、如果提示:-bash: ./tomcatstats.pl: /usr/bin/perl^M: bad interpreter: No such file
編輯tomcatstats.pl,將首行改為:#!/usr/bin/perl -w (加上-w)
2、如果提示:File does not exist: at ./tomcatstats.pl line 21(21行是:my $status = XMLin($xml);)
說明無法得到遠程tomcat服務(wù)器數(shù)據(jù),檢查tomcat配置的用戶是否生效。
3、如果輸出只有jvm數(shù)據(jù),如:
jvm_memory_free:9441488 jvm_memory_max:85196800 jvm_memory_total:23777280 connector_max_time: connector_error_count: connector_bytes_sent: connector_processing_time: connector_request_count: connector_bytes_received: connector_current_thread_count: connector_min_spare_threads: connector_max_threads: connector_max_spare_threads: connector_current_threads_busy: [root@CactiEZ scripts]
則要注意測試命令和tomcat版本。
網(wǎng)上朋友解釋為:
Tomcat7的默認的http的connector名稱為http-bio-8090,tomcat6的是http-8080,而且tomcat的http-bio-8090的雙引號在perl中要轉(zhuǎn)義才能被解析,否則出現(xiàn)只有jvm相關(guān)數(shù)據(jù),其他connector沒有數(shù)據(jù)。
五、配置cactiEZ
進入cacti---< console (控制臺)--< Data Input Methods(數(shù)據(jù)輸入方法) ---< Tomcat Status
修改Input String(輸入字符串)
perl <path_cacti>/scripts/tomcatstats.pl <hostname>:8444 admin passwords http-8080
修改為:
perl <path_cacti>/scripts/tomcatstats.pl <hostname>:8080 admin 123 \"http-bio-8080\"
網(wǎng)站名稱:cacti監(jiān)控tomcat
URL分享:http://jinyejixie.com/article42/iepdec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、品牌網(wǎng)站制作、網(wǎng)站設(shè)計、做網(wǎng)站、動態(tài)網(wǎng)站、虛擬主機
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)