PinPoint implements mail alert

Keywords: MySQL JDK Java JDBC

PinPoint installation deployment and the pit I encountered

PinPoint collector deploys, configures Tomcat and Dubbo services

PinPoint Use Tutorial

Some pits PinPoint trampled on

HBase and PrinPoint are deployed on different servers

PinPoint implements mail alert

After installing pinpoint, click the settings button in the upper right corner of the page, and the following will happen:

The newly installed pinpoint does not support the implementation of alarm function, and then according to the author's Alarm configuration tutorial Only in this way can we start this skill. However, I have to say that the author's tutorial is too simple and straightforward, and there are some errors in the code posted in the tutorial, there are still some areas to be changed, the author did not explain. The current situation is that there are still some pinpoint installation and deployment tutorials in China, but the following warning opening tutorials should be the only one in this blog. The tutorial for sending short messages is exactly the same as that for email. Here's just an example of email.

1. Compiling war packages

1.1 Download the required resources
pinpoint-1.6.2 Resource Download

1.2 Compile war package

yimi$ cd pinpoint-1.6.2

yimi$ mvn -f ./pom.xml install -Dmaven.test.skip=true

Note 1: If the following errors occur during compilation

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-pinpoint-build-requirements) on project pinpoint: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

Do the following

vi /etc/profile

#Modify profile file configuration information (jdk path and maven path)
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
export JAVA_6_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
export JAVA_7_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_6_HOME/bin
export CLASSPATH=.:$JAVA_6_HOME/jre/lib:$JAVA_6_HOME/lib:$JAVA_6_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_7_HOME/bin
export CLASSPATH=.:$JAVA_7_HOME/jre/lib:$JAVA_7_HOME/lib:$JAVA_7_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_8_HOME/bin
export CLASSPATH=.:$JAVA_8_HOME/jre/lib:$JAVA_8_HOME/lib:$JAVA_8_HOME/lib/tools.jar
export PATH=/usr/local/Cellar/maven/3.3.9/bin:$PATH

Note 2: If the following errors occur during compilation

[ERROR] Failed to execute goal org.codehaus.mojo:animal-sniffer-maven-plugin:1.15:check (ensure-java-1.7-class-library) on project pinpoint-collector: Signature errors found. Verify them and ignore them with the proper annotation if needed. -> [Help 1]

Do the following

yimiyangguang$ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

yimiyangguang$ vi collector/pom.xml

Modify according to local jdk version, before modification

<properties>
    <jdk.version>1.7</jdk.version>
    <jdk.home>${env.JAVA_7_HOME}</jdk.home>
    <sniffer.artifactid>java17</sniffer.artifactid>
    <fastxml.jackson.version>2.8.5</fastxml.jackson.version>
</properties>

Revised

<properties>
    <jdk.version>1.8</jdk.version>
    <jdk.home>${env.JAVA_8_HOME}</jdk.home>
    <sniffer.artifactid>java18</sniffer.artifactid>
    <fastxml.jackson.version>2.8.5</fastxml.jackson.version>
</properties>

Compile again and you will succeed

2. Integrated Send Mail Code

2.1 Download Send Mail Code
Links: Send mail alarm code Password: pu5x

2.2 Adding dependencies to pom.xml in web folders

<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>javax.mail</artifactId>
    <version>1.5.6</version>
</dependency>

2.3 Import Code
Place the AlarmMessageSenderImple.java file and email folder in the web/src/main/java/com/navercorp/pinpoint/web/alarm directory

Modify the AlarmWriter file in the web/src/main/java/com/navercorp/pinpoint/web/alarm directory

//Before revision
private AlarmMessageSender alarmMessageSender = new EmptyMessageSender();

//Revised
private AlarmMessageSender alarmMessageSender = new AlarmMessageSenderImple();

3. Deployment of war packages

3.1 Modify the batch.enable configuration

yimiyangguang$ vi /data/service/pp-web/webapps/ROOT/WEB-INF/classes/batch.properties

Before revision

#batch enable config
batch.enable=false

#batch server ip to execute batch
batch.server.ip=127.0.0.127

Revised

#batch enable config
batch.enable=true

#batch server ip to execute batch
batch.server.ip=127.0.0.1

3.2 Configure mysql
Modify jdbc.properties configuration

yimiyangguang$ vi /data/service/pp-web/webapps/ROOT/WEB-INF/classes/jdbc.properties

#jdbc.properties configuration information
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://10.168.16.116:3306/pinpoint?characterEncoding=UTF-8
jdbc.username=dev
jdbc.password=devApp2013

/ Create a new folder point under the home directory, and put the downloaded CreateTableStatement-mysql.sql and Spring BatchJob ReositorySchema-mysql.sql files into the folder
Links: sql file download Password: wx3m

yimiyangguang$ mysql -u root -p

#view the database
MySQL [(none)]> SHOW DATABASES;
+---------------------+
| Database            |
+---------------------+
| information_schema  |
+---------------------+

#Create a database
MySQL [(none)]> CREATE DATABASE pinpoint;
Query OK, 1 row affected (0.03 sec)

#FunctionCreateTableStatement-mysql.sql
MySQL [pinpoint]> source /home/point/CreateTableStatement-mysql.sql

#FunctionSpringBatchJobReositorySchema-mysql.sql
MySQL [pinpoint]> source /home/point/SpringBatchJobReositorySchema-mysql.sql

#View the tables available in the database
MySQL [pinpoint]> show tables;
+------------------------------+
| Tables_in_ht_alarm           |
+------------------------------+
| agent_statistics             |
| alarm_history                |
| alarm_rule                   |
| batch_job_execution          |
| batch_job_execution_context  |
| batch_job_execution_params   |
| batch_job_execution_seq      |
| batch_job_instance           |
| batch_job_seq                |
| batch_step_execution         |
| batch_step_execution_context |
| batch_step_execution_seq     |
| puser                        |
| user_group                   |
| user_group_member            |
+------------------------------+

3.2 Result Display

Posted by Jiin on Sun, 09 Jun 2019 13:07:23 -0700