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

How to realize Server+client+ early warning in Cat

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "how to achieve Server+client+ early warning in Cat". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to achieve Server+client+ early warning in Cat".

one。 Server deployment

1. Download source code from github, import idea, load dependencies, plug-ins

two。 Maven packaging after loading (packaging is easy to fail, so pack a few more times)

Mvn clean install-DskipTests

3. After being packed into a war package, you can start it in tomcat under linux, or you can configure tomcat local startup directly in idea (take window as an example)

4. After startup, the project read configuration directory is automatically generated (this directory requires read and write permissions)

/ data/appdatas/cat/

5. At this point, the project will fail to start because only the directory has no configuration file.

6. Create a client.xml,datasources.xml configuration file under the / data/appdatas/cat/ directory as follows

Client.xml

# the address and port of the Cat server are configured here

Datasources.xml

3 1s 10m 1000 com.mysql.jdbc.Driver # server Cat database address jdbc:mysql://127.0.0.1:3306/cat root 123456

7. Initialization sql will be loaded into the database we filled in under the script directory of the project.

8. Start after the configuration is completed. The project access path to be started needs to be / cat.

9. Start successfully, visit http://localhost:8080/cat/s/config?op=routerConfigUpdate, and enter the server page successfully

10. Default user name: admin default password: admin

11. At this point, the server has successfully connected.

two。 Client access (take springBoot project as an example)

1. Import dependencies (according to the version of our server)

Com.dianping.cat cat-client 3.0.0

two。 New configuration class

@ Configurationpublic class CatFilterConfigure {@ Bean public FilterRegistrationBean catFilter () {FilterRegistrationBean registration = new FilterRegistrationBean (); CatFilter filter = new CatFilter (); registration.setFilter (filter); registration.addUrlPatterns ("/ *"); / / registration.addInitParameter ("exclusions", "* .js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); registration.setName ("cat-filter") Registration.setOrder (2); return registration;}}

3. Establish the following structure under resources before Cat can find the corresponding project name

App.name=phoenix

4. The root directory launched by the client should also have a / data/appdatas/cat/ directory. Only client.xml is needed in this directory. In this directory, the address needs to be changed to the ip+ port of the server, so that the client can find the address of the server.

5. At this point, the client is successfully connected to the Cat server when it starts. If we visit the client interface URL, we can see it in the server.

three。 Early warning function, taking abnormal early warning as an example

1. Alarm server

After triggering the early warning, it will send a http request according to the address we assigned. Therefore, we need to write the specific early warning business ourselves.

# the interface address we wrote is configured here, and this interface will be adjusted after the early warning is triggered. # 200 means that the return of our interface needs to be "200".

two。 Server configuration

# other configuration does not need to move # define whether the current service alarm is sent. These two are to define for true # whether the current service is an alarm machine.

3. Exceptions usually occur in Event, so we only need to configure Event alarm configuration

4. Other configurations can be configured by default. Go back to the Event list at this time. If Exception appears within 1 minute, an alarm will be triggered.

5. If the project is caught by try catch or an exception, the exception cannot be monitored, and you need to bury it where the exception occurs.

Cat.logError (e)

5. At this point, a simple abnormal monitoring alarm is completed.

IV. Exception+Event burial site

Event is generally used to record more exceptions, and Transaction can record it according to the business.

# Transaction burial Transaction t = Cat.newTransaction ("DDDDDType", "DDDDDTypeName"); # Event burial Cat.logEvent ("dddEventType", "dddEventName", Event.SUCCESS, "keyValuePairs"); try {yourBusiness (); t.setStatus (Transaction.SUCCESS);} catch (Exception e) {t.setStatus (e); # Event exception burial Cat.logError (e);} finally {t.complete ();}

After this code is executed, we can see it in the Translation and Event lists

five。 Be careful

1. The clent.xml in\ data\ appdatas\ cat in the client is indispensable! The ip+ port that is configured to point to the server

two。 After the server is deployed to the server, several ip in the client route need to be replaced with the actual ip of its own server

3. It is recommended that the ip in the server configuration be replaced with the actual ip of the server.

4. If the server model in the server configuration is changed, the server needs to be restarted.

Thank you for your reading, the above is the content of "how to achieve Server+client+ early warning in Cat". After the study of this article, I believe you have a deeper understanding of how to achieve Server+client+ early warning in Cat, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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