Deployment Reviews Cat Monitoring Project

Source: Internet
Author: User

Monitoring the operation of the code in the project, you can use the Cat project to monitor the entire project, but according to the official documents to deploy cat, always encounter a variety of problems, the explanation is not concise and clear, now use a single machine to deploy the CAT monitoring project.

First, download the entire project to the project's Git Web page:

Https://github.com/dianping/cat

The next step is to enter the directory for this project and run the package install command:

MVN clean install-dskiptests (maven required)

After the execution is complete, run the CAT install plugin command:

MVN Cat:install

You will be prompted to enter the connection information, account and password for the MySQL database. You may be prompted for a missing \data\appdatas\cat directory, which you can manually add.

Finally enter the Cat-home directory: CD cat-home, run MVN jetty:run

You can start without any error prompts. Enter the address in the browser:

LOCALHOST:2281 will enter the interface, the interface has a description of the document to demonstrate the effect, etc., nothing, turn it off.

Enter the project, copy/cat-home/target/cat-alpha-1.3.6-snapshot.war this file into Tomcat's webapps inside, modify the name to: Cat.war. The directory where Tomcat is located needs to have the Data folder, which contains:

\data\appdatas\cat and \data\applogs\cat folders, if not, create them manually.

\data\appdatas\cat folder contents in MVN cat:install This step is automatically created Client.xml, Datasources.xml and Server.xml three files, Datasources.xml is the database connection information, without change, no need to modify, Client.xml and server.xml two files, how many servers, how many servers to write the address up. Since I was doing experiments on this machine, I had only one machine address.

The Client.xml file only needs to change the contents of the Red box:

Server.xml file changed the contents of the red box, there are more than one machine, just like the red box under the comment of the change can be.

After modification, start Tomcat (Bin\startup.bat)


Without any problems, we can view the logs in the \data\applogs\cat directory as prompted.



Enter HTTP://LOCALHOST:8080/CAT/R in the browser to see the deployed interface under Cat. The "Real time" function in the upper left corner is what we need most!



Click to find all examples of demo, you can see the corresponding code to learn how to use.



In the test section of the project's home module, there is a com.dianping.cat.demo.TestStorageMessage class, Inside

The code of the polygon can be found in the corresponding effect on our interface.

such as the Sendsqlmsg method, in the interface of the "Event" monitoring function, you will find the name and method of monitoring.


private void Sendsqlmsg (string name, string domain, string method, String ServerIP) throws Interruptedexception {Transacti On t = cat.newtransaction ("SQL", "Sql.method"); Cat.logevent ("SQL. Method ", method); Cat.logevent ("SQL. Database ", String.Format (Jdbc_connection, ServerIP, name)); Messagetree tree = Cat.getmanager (). Getthreadlocalmessagetree ();((D efaultmessagetree) tree). SetDomain (domain); Thread.Sleep (+ new Random () nextint), int nextint = new Random (). Nextint (3); if (nextint% 2 = = 0) {t.setstatus (Tr Ansaction. SUCCESS);} else {t.setstatus (string.valueof (Nextint));} T.complete ();}


These two line names in the corresponding code:


Cat.logevent ("SQL. Method ", method); Cat.logevent ("SQL. Database ", String.Format (Jdbc_connection, ServerIP, name));


Therefore, we can easily learn how to use it according to this. Because the Cat project has been started, the entire machine is in the range of monitoring, written projects are designated by the Cat project monitoring to achieve real-time monitoring, analysis of our code implementation effect.

Create a new project, in the project to add all the jar inside the cat-home\target\cat-home-1.3.6-snapshot\web-inf\lib, temporarily do not know what is useful, which is useless, so it is right to join the project.

Write a class in the project that reads as follows:

public class MyTest {public    static void Main (string[] args) {        Transaction t = cat.newtransaction ("TEST", "test.me Thod ");        Cat.logevent ("Method_test", "good");        Cat.logevent ("Method_event", "bad");        int nextint = new Random (). Nextint (3);        if (nextint% 2 = = 0) {            t.setstatus (transaction.success);        } else {            t.setstatus (string.valueof (Nextint));        }        T.complete ();}    }

Run, and the discovery will soon be over! Enter a hint to see the log.

Open the log and find the following prompt:

[07-20 22:05:34.780] [INFO] [Defaultmodulecontext] Starting thread (cat-modelservice-0) ... [07-20 22:10:08.922] [INFO] [Defaultmodulecontext] Starting thread (cat-modelservice-1) ... [07-20 22:20:00.677] [INFO] [Defaultmodulecontext] Current working directory is c:\hadoop_java[07-20 22:20:00.699] [INFO] [defaultclientconfigmanager] Global config file (\ Data\appdatas\cat\client.xml) found. [07-20 22:20:00.700] [INFO] [Defaultclientconfigmanager] Can ' t find app.properties in/meta-inf/app.properties[07-20 22:20:00.711] [WARN] [Defaulttransportmanager] CAT was DISABLED due to not initialized yet!

Note that it is clear that there is no app.properties this file, in the project's documentation also said that this document is mainly designated to monitor the Cat project. Because our monitoring project changed to Cat.war to start, so just add the Meta-inf folder in the source code directory, add app.properties This file, the content is very simple:

App.name=cat

This name and the browser in the domain corresponding, if you want to change to another name, then the value of this domain will be changed to the corresponding name.



Note: The Meta-inf folder must be changed to the specified format of the source file.


Run the code again, the following effect, the program will not automatically shut down, instructions in the monitoring ...

Check logs, everything works:

[07-20 22:25:58.541] [INFO] [ChannelManager] Connected to CAT server at/127.0.0.1:2280[07-20 22:25:58.543] [INFO] [ChannelManager] success when init CAT server, new A Ctive holderactive Future:/127.0.0.1:2280 index:0 ip:127.0.0.1 server config:null[07-20 22:25:58.545] [INFO] [ Defaultmodulecontext] Thread Group (CAT) created. [07-20 22:25:58.546] [INFO] [Defaultmodulecontext] Starting thread (Cat-tcpsocketsender-channelmanager) ... [07-20 22:25:58.546] [INFO] [Defaultmodulecontext] Starting thread (Cat-tcpsocketsender) ... [07-20 22:25:58.547] [INFO] [Defaultmodulecontext] Starting thread (cat-merge-atomic-task) ... [07-20 22:25:58.557] [INFO] [Defaultmodulecontext] Starting thread (cat-statusupdatetask) ...

Refresh the cat page and discover a new transaction


and two event events!

To this, the application of cat real-time monitoring system deployment success, the rest is to slowly study the code how to better use cat!

==========================================================

Sometimes you will find that the real-time monitoring page What data is not displayed, to view the log records, you will find a lot of 10.0.0.1:2280 error:

This requires us to click on the top right corner of the login, with the account and password are catadmin to login, in the "Configuration" of the last "global alarm configuration" in the "client route" inside to 127.0.0.1:2280, submit refresh live page, the data back!

<?xml version= "1.0" encoding= "Utf-8"? ><router-config backup-server= "127.0.0.1" backup-server-port= "2280" >   <default-server id= "127.0.0.1" port= "2280" enable= "true" weight= "1.0"/></router-config>






Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Deployment Reviews Cat Monitoring Project

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.