Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Cacti Monitoring tomcat

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Environment:

Tomcat:apache-tomcat-7.0.35

CactiEZ:10.1

System: centos5.6_x64

1. Configure tomcat server

1. Add an account

Vim tomcat-users.xml

Restart tomcat

2. Install snmp protocol

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. Test snmp

Test this machine: snmpwalk-c public-v 2c localhost

Test remote host: snmpwalk-V 2c-C public-H 192.168.1.133-L

2. Configure cactiEZ

Install the XML::Simple module

Installation method: (perl-MCPAN-e "install XML::Simple")

Download and import the template

1. The template for monitoring tomcat

TomcatStats-0.1.zip

2. Modify the tomcatstats.pl to set the

My $url = "http://$username:$password"."\@$host/manager/status?XML=true";my $xml = `GET $url`"

Replace the following two behaviors:

My $url = "http://$host/manager/status?XML=true";my $xml = `wget-qO-http-user=$username-- http-password=$password $url`

Note: the O in the-qO here is an uppercase O; otherwise, the data may not come out after you import it.

4. Import template (cacti_host_template_tomcat_server.xml)

Enter cacti-- < Console (console)-< Import Templates (Import template)

5. Upload monitoring script

Upload the tomcatstats.pl to the / var/www/html/scripts directory of the cactiEZ server.

IV. Test script

# / usr/bin/perl tomcatstats.pl 192.168.1.20115 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. If prompted:-bash:. / tomcatstats.pl: / usr/bin/ Perl ^ M: bad interpreter: No such file

Edit tomcatstats.pl and change the first line to: #! / usr/bin/perl-w (plus-w)

2. If prompted: File does not exist: at. / tomcatstats.pl line 21 (line 21 is: my $status = XMLin ($xml);)

Indicates that the remote tomcat server data cannot be obtained, and check whether the user configured by tomcat is valid.

3. If the output is only jvm data, such as:

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]

Pay attention to the test command and the tomcat version.

Online friends explain as:

The default connector name of Tomcat7's http is http-bio-8090,tomcat6, and the double quotation marks of tomcat's http-bio-8090 must be escaped in perl before they can be parsed, otherwise there is only jvm-related data, and other connector has no data.

5. Configure cactiEZ

Enter cacti--- < console (console)-< Data Input Methods (data input method)-< Tomcat Status

Modify Input String (input string)

Perl / scripts/tomcatstats.pl: 8444 admin passwords http-8080

Modified to:

Perl / scripts/tomcatstats.pl: 8080 admin 123\ "http-bio-8080\"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report