Cacti monitoring the implementation of multiple Tomcat ports on a single Web server

Source: Internet
Author: User
Tags new set rrd rrdtool

Because more than one Tomcat is installed on a Web application server, there are multiple ports, such as the default of 8080, followed by additional 9100,9300,9500, and so on. A cacti_host_template_tomcat_server.xml template can only be specified to monitor a tomcat service port.

So if you want to monitor more than one Tomcat server on a Web server, then you have to find another way to monitor a tomcat service in one of the hosts above, and you need to build multiple template XML files to monitor multiple Tomcat services on one host. There are currently 2 ways of thinking:

(1) Add a new Tomcat port monitoring option on the Cacti Web page by clicking on the button action step.

(2), build a new XML template file and reload it.

Preparatory work:

Cacti Monitoring Tomcat server implementation process:http://blog.csdn.net/mchdba/article/details/29372347

Cacti use installation details: http://blog.csdn.net/mchdba/article/details/27120605


1 Manually adding multiple Tomcat port monitoring options in the Web interface

See the Cacti Service page has the Add button, you can add a template step by step, so first manually add another Tomcat 9500 template on the interface, the approximate steps are as follows:

1.1 First build data Input Source

Data Input Method selects the Tomcat 9500 Status established by Step1


?

1.2 Setting up Data tempate

In the data Input Method, select the Tomcat 9500 Status established in step 1

?

Here to pay special attention to the choice of data Source type, is count or gauge, do not choose the wrong, the wrong choice, is the Nan value, the figure does not come out of data.

"PS": Here are 14 data Source Item, manually one by one is really troublesome, and a port needs to build a, a port N service, a service 14 ports, if all are manually added to each other, that to se years, in the process of adding, but also pay attention to some drop-down options , it consumes time and energy.

1.3 Setting up data Source


? Click the Create button, next:


See a hint ready to generate <PATH_RRA>/WEB-9_BYTES_RECEIVED_568.RRD's RRD drawing file, click the Save button and see that it has been established:


1.4 Creating Graph Template


1.5 Building Graph Tempate



after that, you also need to create a display of the picture color, etc. Item as well Item Input .

(1) Click the Add button after the title bar of the Graph Template Items [edit:9500 tomcat–connection rate] on the current page to refer to the existing tomcat– Connection rate to create the exact item.

(2) Click the Add button behind the Graph Item Inputs title bar to add the data source option by referring to the existing tomcat–connection rate.

(3) Ensure that all option values are the same as the original, especially the value of Unit Grid value (--unit/--y-grid) is 0 , then click the Save button to save.

1.6 Go into the graph management interface and create the graph graph as follows:


After clicking Create, go in and select Graph Item fields, open debug mode, and you can see the RRDtool commands and the debug picture data, as shown below:


Then, go to the graphs interface to view the created rate graph, the following 9500 port data came out:


This is a clumsy and time-consuming approach, but at the very least, it can be added to the finish step.

2, see Manually add cacti Tomcat template file in the Web interface, too time-consuming too cumbersome, so choose another way to construct a copy of the Tomcat template file under cacti.

2.1 Direct replacement Tomcat string followed by 9500 port

To build a template file for another Tomcat monitor yourself, you can do it on a cacti_host_template_tomcat_server.xml basis. Open the template file, you can see a lot of tags, first retrieve the tag with Tomcat, and then save, after the interface loading import successfully, Console---Collection Methods----Data Input Methods There's only one option in it. 9500 Tomcat Status, the original tomcat status is gone, which means that the original tomcat status was directly overwritten by the subsequent 9500 template XML, This kind of way can't get through.

2.2 Continue to study the data from the cacti database in the background

Study the Tomcat template configuration file, go to the Template table in the cacti background database and view the imported Tomcat template tables:

Mysql> SELECT * from ' data_template ' WHERE NAME is like '%tomcat% ';

+-----+----------------------------------+--------------------+

| ID | Hash | name |

+-----+----------------------------------+--------------------+

| 101 | 5a135ee7b52669e39cd51a89a2870f66 | 9500 Tomcat Status |

| 102 | b58769ff71c16b0126014efdf8f5892c | Tomcat 9500 Status |

+-----+----------------------------------+--------------------+

2 rows in Set (0.00 sec)

Mysql>

The 5a135ee7b52669e39cd51a89a2870f66 exists in the XML file and is

<name>9500 Tomcat status</name>

<ds>

......

Where ' hash_01 ' is labeled, the middle of ' 0012 ' is the cacti version number, in the back of a series of scattered strings ' 5a135ee7b52669e39cd51a89a2870f66 ' is the back number in the.

Analysis here, the thought of deciding whether to add a template is the key should be the hash data, if the template XML inside the hash value for the new, whether it can be loaded into another new Tomcat port XML template? Give it a try.

2.3 Start building a new hash value

Idea: First find out the original XML template of all the hash value, the latter four bits to be intercepted into the Tomcat port number 9500,

2.3.1 all cash values under Linux with the grep command

[Email protected] ~]# more Cacti_host_template_tomcat_server.xml |grep hash > Cacti_hash.xml

The contents of the cacti_hash.xml contained here are as follows:

[Email protected] ~]# more Cacti_hash2.xml |more

<graph_templates>hash_0000121df1e862da7c09e91e3d9ccc3f359500|hash_0000123810995e1194c890f50a09388efc9500 |hash_000012cf60b10d60b07078fe1429a0575c9500|hash_000012892489f6e4de56c

7762e90d52cc39500</graph_templates>

...

<task_item_id>hash_08001217cef337fc98ed9edbf507407eb19500</task_item_id>

<gprint_id>hash_060012e9c43831e54eca8069317a2ce8c69500</gprint_id>

.....

See a lot of tags like <task_item_id> </gprint_id > and so on, directly with shell commands

:%s/<task_item_id>//and:%s/<\/gprint _id>//The replacement command was removed and all the XML tags were replaced, leaving all the hash values. Note that for several hash values that are linked with the | symbol, you need to remove the | symbol separately from the line to ensure that a hash value is a row.

A cacti_hash.xml file that eventually gets a line of hash values.

2.3.2 iterates through the hash value file, generating a new hash value XML template.

The principle is to write the shell script to traverse the Cacti_hash.xml file, traverse the hash value, and then go to the original template file inside cacti_host_template_tomcat9500_ Server.xml find the hash value for, replace the latter 4 bits with the Tomcat port number 9500,shell command as follows:

(1) , Copy a copy XML file

[Email protected] ~]#

CP Cacti_host_template_tomcat_server.xml Cacti_host_template_tomcat9500_server.xml

(2) , write a loop Shell Script

[Email protected] ~]# more cacti2.sh

For i in ' Cat Cacti_hash.xml '

Do

# echo $i;

port= ' 9500 ';

NEW_HASH=${I:0:39} $port;

# echo $new _hash;

Sed-i "s/$i/$new _hash/" Cacti_host_template_tomcat9500_server.xml

Done

[Email protected] ~]#

(3) , perform Shell command to generate a new 9500 Templates

[Email protected] ~]# sh cacti2.sh

2.4 Copy Travel 9500 port file, loading in interface

Once loaded, you'll see the newly added 9500 Tomcat status option in console--Collection Methods----and Data Input Methods.


Remember to click on the 9500 hyperlink to enter the input string into the 9500-port access connection so that all data obtained by this 9500-port monitoring is from the 9500-port Tomcat server, as shown in:


You can also see the newly added 9500 Tomcat status option on the console------Templates Data templates/graph Templates, as shown in:



OK, now it's time to go to console--Create--and Management---add Tomcat to another 9500-port monitoring option, and when you click on the button, remember Select the 9500 labeled template on the Selected Graph template drop-down box and add it as follows:


2.5, error handling

An error is as follows:

RRDTool Says:

Error:could not parse line ' GPRINT::MAX:MAXIMUM\:%8.2LF%s\n '

Go in-->graph Templates.

> 9500 tomcat-connection Rate--and Data Source [Error_count]--Item #4: Gprint (MAX) tick, as follows:

?

Go to Graphs window to see the effect, on the same web-9 server, a basic port 80,801 9500 port images are out, as follows:

?

Finally go to the backstage cacti database to see our verification

Mysql> SELECT * from ' data_template ' WHERE NAME is like '%tomcat% ';

+-----+----------------------------------+--------------------+

| ID | Hash | name |

+-----+----------------------------------+--------------------+

| 101 | 5a135ee7b52669e39cd51a89a2870f66 | 9500 Tomcat Status |

| 102 | b58769ff71c16b0126014efdf8f5892c | Tomcat 9500 Status |

+-----+----------------------------------+--------------------+

2 rows in Set (0.00 sec)

Mysql> SELECT * from ' data_template ' WHERE NAME is like '%tomcat% ';

+-----+----------------------------------+--------------------+

| ID | Hash | name |

+-----+----------------------------------+--------------------+

| 101 | 5a135ee7b52669e39cd51a89a2870f66 | 9500 Tomcat Status |

| 102 | b58769ff71c16b0126014efdf8f5892c | Tomcat 9500 Status |

| 104 | 5a135ee7b52669e39cd51a89a2879500 | 9500 Tomcat Status |

+-----+----------------------------------+--------------------+

3 Rows in Set (0.00 sec)

looking at the hash value of ID 101 and 104 and the name description, the hash value after four bits from 0f66 into 9500.


Summarize:

In all loaded cacti template files, the hash value of the core distinction points, if a new set of hash values are constructed, then the new monitoring option is loaded.
?

If you now add a 9300 Tomcat service to a Web server, you only need to replace the hash end 9500 of the 9500-port XML I shared with 9300, then a new XML template.


And so on, now like to build a MySQL multi-instance on a Linux server, then how to monitor multi-instance MySQL under Cacti, you can also use the similar method in this article to build a new MySQL multi-port template XML file to reload the implementation.


cacti monitoring Tomcat Multi-port template files:http://download.csdn.net/detail/mchdba/7531125

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.