Saturday, 20 February 2021

Deploying with Ansible Tower( Playbook to deploy artifact to tomcat)

The below playbook will log into tomcat server Create a folder called Downloads. Download artifact into it and copy them into the /var/lib/tomcat8/webapps  


Playbook 4
---
- name: Playbook to Download and Deploy Artifact in tomcat
  hosts: "{{ deploy_host }}"    
  tasks:
  - name: Create a Directory /opt/Downloads
    become: yes
    file:
      path: /opt/Downloads
      state: directory
      mode: 0755
      owner: tomcat8
      group: tomcat8

  - name: Download Artifact from Artifactory
    become: yes
    get_url:
      url: https://urloftheartifac
      url_password: Sarav@123
      url_username: sarav
      dest: /opt/Downloads/MyWebApp.war
      mode: 0755
      group: tomcat8
      owner: tomcat8
      
  - name: Copy File to webapp folder
    become: yes
    copy:
      src: /opt/Downloads/MyWebApp.war
      dest: /var/lib/tomcat8/webapps
      remote_src: yes
      mode: 0755
      owner: tomcat8
      group: tomcat8
      
  - name: Delete a Directory /opt/Downloads
    become: yes
    file:
      path: /opt/Downloads
      state: absent

Datadog - Continuous Monitoring

 

How to enable Apache Tomcat monitoring in Datadog Agent


Datadog is a monitoring service for cloud-scale applications that brings events and metrics from servers, databases, applications, tools and services to present a unified view of the infrastructure, which help them to work collaboratively on the infrastructure to avoid latency, resolve performance problems, and ensure that development and deployment cycles finish on time.

Apache Tomcat Integratoion with Datadog collects Following Tomcat metrics

  • Overall activity metrics: error count, request count, processing times, etc.
  • Thread pool metrics: thread count, number of threads busy, etc.
  • Servlet processing times

Step 1 – Sign up for a Datadog Account

Click on Free Trial

Fill the form to sign up

Next: Select your Stack. You can select Tomcat for now



Step 2: Install the datadog Agent on your Tomcat Server



Select your OS: Ubuntu

Then copy the command in the box: Use our easy one step install


Log into your Tomcat server and paste and run the command to install datadog agent

DD_AGENT_MAJOR_VERSION=7 DD_API_KEY=4cf1ee64a11f9c21c2020b85376e552c DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"





How to enable JMX Remote in Tomcat 8 to Monitor & Administer?

Modify catalina.sh file by adding the below lines
$ sudo vi /usr/share/tomcat8/bin/catalina.sh




CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9012 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

Save: wq!
Restart the process
$ cd /usr/share/tomcat8/bin/

$ ./shutdown.sh

$ ./startup.sh

Reference

  • https://tomcat.apache.org/tomcat-8.0-doc/monitoring.html#Enabling_JMX_Remote

How to configure and enable Tomcat intergration in Datadog agent?

$ cd /etc/datadog-agent/conf.d/tomcat.d/
$
cp conf.yaml.example conf.yaml
$
datadog-agent configcheck
$
systemctl restart datadog-agent
$
systemctl status datadog-agent
$
datadog-agent config
Next Go to your Datadog account: Integrations


Search for Tomcat and install it
Click on Infrastructure--Infrastructure List:

Select your host: And you should see the metric graphs