From 2baa58e05623c887eadc67903f7407674f002173 Mon Sep 17 00:00:00 2001 From: marcos Date: Tue, 18 Dec 2018 13:48:28 -0300 Subject: [PATCH] Send alarms by email Addition of mysql container with pinpoint database to allow the registration of users, groups and alarms. Including lib, implementation of AlarmMessageSender and settings in the pinpoint-web container to allow sending alert emails. --- docker-compose.yml | 43 ++++++++++++++++ pinpoint-mysql/Dockerfile | 11 +++++ pinpoint-web/Dockerfile | 6 ++- pinpoint-web/build/mail.zip | Bin 0 -> 3959 bytes pinpoint-web/build/scripts/start-web.sh | 63 ++++++++++++++++++++++++ 5 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 pinpoint-mysql/Dockerfile create mode 100644 pinpoint-web/build/mail.zip diff --git a/docker-compose.yml b/docker-compose.yml index c7dc35c..fd58229 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,6 +35,30 @@ services: - "16030:16030" restart: always + pinpoint-mysql: + build: + context: ./pinpoint-mysql/ + dockerfile: Dockerfile + args: + - PINPOINT_VERSION=${PINPOINT_VERSION} + + container_name: pinpoint-mysql + restart: always + image: pinpointdocker/pinpoint-mysql:${PINPOINT_VERSION} + hostname: pinpoint-mysql + ports: + - "13306:3306" + environment: + MYSQL_ROOT_PASSWORD: root123 + MYSQL_USER: admin + MYSQL_PASSWORD: admin + MYSQL_DATABASE: pinpoint + + volumes: + - mysql_data:/var/lib/mysql + networks: + - pinpoint + pinpoint-web: build: context: ./pinpoint-web/ @@ -47,6 +71,7 @@ services: depends_on: - pinpoint-hbase + - pinpoint-mysql restart: always expose: - "8080" @@ -66,6 +91,23 @@ services: - BATCH_ENABLE=${BATCH_ENABLE} - BATCH_SERVER_IP=${BATCH_SERVER_IP} - BATCH_FLINK_SERVER=${BATCH_FLINK_SERVER} + - JDBC_DRIVER=com.mysql.jdbc.Driver + - JDBC_URL=jdbc:mysql://pinpoint-mysql:3306/pinpoint?characterEncoding=UTF-8 + - JDBC_USERNAME=admin + - JDBC_PASSWORD=admin + - MAIL_HOST=stmp.test.com + - MAIL_PORT=123 + - MAIL_USERNAME=user + - MAIL_PASSWORD=pass +# - MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL=smtp + - MAIL_PROPERTIES_MAIL_SMTP_AUTH='true' + - MAIL_PROPERTIES_MAIL_SMTP_PORT=587 +# - MAIL_PROPERTIES_MAIL_SMTP_FROM=test@example.com + - MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE='true' +# - MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED='true' +# - MAIL_PROPERTIES_MAIL_DEBUG='true' + links: + - "pinpoint-mysql:pinpoint-mysql" networks: - pinpoint @@ -215,6 +257,7 @@ services: volumes: data-volume: + mysql_data: networks: pinpoint: diff --git a/pinpoint-mysql/Dockerfile b/pinpoint-mysql/Dockerfile new file mode 100644 index 0000000..dba9d2b --- /dev/null +++ b/pinpoint-mysql/Dockerfile @@ -0,0 +1,11 @@ +FROM mysql:5.7 + +ENV PINPOINT_VERSION=1.8.0 + +RUN apt update \ + && apt-get install -y --no-install-recommends ca-certificates wget \ + && wget -O /docker-entrypoint-initdb.d/CreateTableStatement-mysql.sql "https://raw.githubusercontent.com/naver/pinpoint/$PINPOINT_VERSION/web/src/main/resources/sql/CreateTableStatement-mysql.sql" \ + && wget -O /docker-entrypoint-initdb.d/SpringBatchJobRepositorySchema-mysql.sql "https://raw.githubusercontent.com/naver/pinpoint/$PINPOINT_VERSION/web/src/main/resources/sql/SpringBatchJobRepositorySchema-mysql.sql" \ + && sed -i '/^--/d' /docker-entrypoint-initdb.d/CreateTableStatement-mysql.sql \ + && sed -i '/^--/d' /docker-entrypoint-initdb.d/SpringBatchJobRepositorySchema-mysql.sql \ + && apt-get purge -y --auto-remove ca-certificates wget diff --git a/pinpoint-web/Dockerfile b/pinpoint-web/Dockerfile index e51d805..e295197 100644 --- a/pinpoint-web/Dockerfile +++ b/pinpoint-web/Dockerfile @@ -6,12 +6,16 @@ ARG PINPOINT_VERSION=${PINPOINT_VERSION:-1.8.0} ARG INSTALL_URL=https://github.com/naver/pinpoint/releases/download/${PINPOINT_VERSION}/pinpoint-web-${PINPOINT_VERSION}.war COPY /build/scripts/start-web.sh /usr/local/bin/ +COPY /build/mail.zip /assets/mail.zip RUN chmod a+x /usr/local/bin/start-web.sh \ && curl -SL ${INSTALL_URL} -o pinpoint-web.war \ && rm -rf /usr/local/tomcat/webapps \ && mkdir -p /usr/local/tomcat/webapps \ && unzip pinpoint-web.war -d /usr/local/tomcat/webapps/ROOT \ - && rm -rf pinpoint-web.war + && rm -rf pinpoint-web.war \ + && curl -SL https://maven.java.net/content/repositories/releases/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar -o /usr/local/tomcat/webapps/ROOT/WEB-INF/lib/javax.mail-1.5.2.jar \ + && unzip /assets/mail.zip -d /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/ \ + && rm -rf /assets/mail.zip ENTRYPOINT ["/usr/local/bin/start-web.sh"] diff --git a/pinpoint-web/build/mail.zip b/pinpoint-web/build/mail.zip new file mode 100644 index 0000000000000000000000000000000000000000..851516bf54f1f3cb8ce967a2b9430270b6c24b3a GIT binary patch literal 3959 zcmbuCc{r47AIB$T9Z`&(>|`BAma=3&V~iz2*2Y-EU}hNE5@M8H)(FR%tq~?mcB6<8 zvWtjPc1g12g$~j z1jzsZ1}Xr66951p&}ftk65;LQ>7nWA;qB<_E$NPMK}q?#qcW4GJu|?J9ogM>GvBxq zeM-!wAKM6aSEKyaa=o*?-&nlD?LIIXQ2+3} z?RG=+iNyz7-*ts*NzY>&3s*PT$Mad+XId^;Y31M2v6Y>>ndQ&vt!T^0qBh_=FVB_E z8isvyeMUZhF_0@=o6qz@(p>>#HzD<>qqI`cUdi_KsPlGh(X%jNrIiFD9f*zIBfXCn zbV~0)3g?BOEQBaRn^Zz&T7P=#5Tug~D3m+PVot|&L2saYRD62vTA(JfiTtdq4WiK8 zyjWiEHpWwnKZ5*WS)K!_l#-#^CtZ?U$~3!MCMWqDY;x+R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o>T4j` zn9wLF>Qpqf1uxUYOWB86PT=KmjbrR>ES)??2_X}iyYN-+evYAg5W!nZBx#{;{$ijM z&e#Cb8|-N6R)lu5Y|6?Jpaacwh5NlYnUzPqRQXJ*SpB!U-`Ran@P4jQB~tKt$xSh4 zoE-58SfOrz<5Aw`dIG+zrt6P|6po@ zWds6UvY30_uB%{9S|4&yY}z`juuajiL$LX>DqGdL;$pywvu$Ydt z!j#!9E`$(~E=J}bHLBP8`3)*-l|bqUSd!#ylrBCT2^^&t=r7i;F_FFk`_g3(r7S|5 z4fo$Nf}J2!Bmd{R=Wst9Hr`-j$kFo`RnW1~-!tx!8~|Vp-dDFd+-pCG_h;(ADvp@< zM>|s7`a^LHsK3f~#K6be(!Xf`gxg=495L~+$=iQ6`9a9XBl$Z/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/log4j.xml +WEB_INF_CLASSES_DIR=/usr/local/tomcat/webapps/ROOT/WEB-INF/classes +APPLICATION_CONTEXT_WEB_FILE=${WEB_INF_CLASSES_DIR}/applicationContext-web.xml +APPLICATION_CONTEXT_MAIL_FILE=${WEB_INF_CLASSES_DIR}/applicationContext-mail.xml + +echo -e " +jdbc.driverClassName=${JDBC_DRIVER:-com.mysql.jdbc.Driver} +jdbc.url=${JDBC_URL:-jdbc:mysql://localhost:13306/pinpoint?characterEncoding=UTF-8} +jdbc.username=${JDBC_USERNAME:-admin} +jdbc.password=${JDBC_PASSWORD:-admin} +" > ${WEB_INF_CLASSES_DIR}/jdbc.properties + +sed -i '/classpath:applicationContext-mail.xml/d' ${APPLICATION_CONTEXT_WEB_FILE} +if [ "$MAIL_HOST" != "" ]; then + sed -i 's/<\/beans>/ \ +<\/beans>/' ${APPLICATION_CONTEXT_WEB_FILE} + + sed -i "/name=\"host\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + sed -i "/name=\"port\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + sed -i "/name=\"username\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + sed -i "/name=\"password\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + + if [ "$MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL" != "" ]; then + sed -i "/prop key=\"mail.transport.protocol\"/c\ ${MAIL_PROPERTIES_MAIL_TRANSPORT_PROTOCOL}" ${APPLICATION_CONTEXT_MAIL_FILE} + else + sed -i "/prop key=\"mail.transport.protocol\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + fi + + if [ "$MAIL_PROPERTIES_MAIL_SMTP_PORT" != "" ]; then + sed -i "/prop key=\"mail.smtp.port\"/c\ ${MAIL_PROPERTIES_MAIL_SMTP_PORT}" ${APPLICATION_CONTEXT_MAIL_FILE} + else + sed -i "/prop key=\"mail.smtp.port\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + fi + + if [ "$MAIL_PROPERTIES_MAIL_SMTP_AUTH" != "" ]; then + sed -i "/prop key=\"mail.smtp.auth\"/c\ ${MAIL_PROPERTIES_MAIL_SMTP_AUTH}" ${APPLICATION_CONTEXT_MAIL_FILE} + else + sed -i "/prop key=\"mail.smtp.auth\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + fi + + if [ "$MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE" != "" ]; then + sed -i "/prop key=\"mail.smtp.starttls.enable\"/c\ ${MAIL_PROPERTIES_MAIL_STARTTLS_ENABLE}" ${APPLICATION_CONTEXT_MAIL_FILE} + else + sed -i "/prop key=\"mail.smtp.starttls.enable\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + fi + + if [ "$MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED" != "" ]; then + sed -i "/prop key=\"mail.smtp.starttls.required\"/c\ ${MAIL_PROPERTIES_MAIL_STARTTLS_REQUIRED}" ${APPLICATION_CONTEXT_MAIL_FILE} + else + sed -i "/prop key=\"mail.smtp.starttls.required\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + fi + + if [ "$MAIL_PROPERTIES_MAIL_DEBUG" != "" ]; then + sed -i "/prop key=\"mail.debug\"/c\ ${MAIL_PROPERTIES_MAIL_DEBUG}" ${APPLICATION_CONTEXT_MAIL_FILE} + else + sed -i "/prop key=\"mail.debug\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + fi + + if [ "$MAIL_PROPERTIES_MAIL_SMTP_FROM" != "" ]; then + sed -i "/prop key=\"mail.smtp.from\"/c\ ${MAIL_PROPERTIES_MAIL_SMTP_FROM}" ${APPLICATION_CONTEXT_MAIL_FILE} + else + sed -i "/prop key=\"mail.smtp.from\"/c\ " ${APPLICATION_CONTEXT_MAIL_FILE} + fi +fi exec /usr/local/tomcat/bin/catalina.sh run