Share This:

PATROL Agent and KMs in Docker Containers

 

Overview:

This blog explains a way to create Docker image of Truesight repository package. Using this, one can build Docker image of Truesight repository package to run inside Docker container. Docker container is not replacement of full OS and hence local OS monitoring (OS KM's) is not something its intended for. Remote monitoring KM's (like VMware, OS remote motoring etc. ) are the ideal and best suited for containerization. We have used VMware KM for this exercise.

 

Docker Overview

Docker is a platform that enables users to build, package, ship and run distributed applications. Docker users package up their applications, and any dependent libraries or files, into a Docker image. Docker images are portable artifacts that can be distributed across Linux environments. Images that have been distributed can be used to instantiate containers where applications can run in isolation from other applications running in other containers on the same host operating system.

 

Pre-requisites:

  1. The PATROL components for which you want to create image should be in the form of Truesight CMA repository package only (tar file)
  2. Truesight repository should be v10.0 and above
  3. Make sure all the components are 64 bit only as Docker only support 64 architecture.
  4. Make note of all inputs used while creating repository package as same details should be used in Dockerfile as well (Ex. PATROL default account, Install dir. etc.).

 

PATROL package details used for this exercise:

  1. Components part of PATROL package are PATROL Agent for Linux v10.0, Oracle for Linux (JRE) and VMware KM v4.0.0
  2. Provide docker host root password for the root user details.
  3. Provide integration service to connect to during package creation.
  4. PATROL package should be saved as tar file.

 

Dockerfile:

 

# IMPORTANT

# -------------------------------------------------------------

# The resulting image will have PATROL components installed which are part of PATROL package used

#

# REQUIRED FILES TO BUILD THIS IMAGE

# -------------------------------------------------------------

# (1) patrol_cma_package.tar

# Please create the tar package of PATROL component from v10.0 and above CMA

#

# HOW TO BUILD THIS IMAGE

# -------------------------------------------------------------

# Create new directory on Docker host and put tar package along with this Dockerfile in it.

# Run:

#      $ docker build -t "patrol:1" .

#

# Pull base image

# -------------------------------------------------------------

FROM centos

 

# Maintainer

# ----------

MAINTAINER schopda@bmc.com

 

# [REVIEW]Environment variables required for this build (Change the values of PATUSER and INSTALLDIR if required)

# -------------------------------------------------------------

ENV TARGET Linux-2-6-x86-64-nptl

ENV BASEDIR /opt/

ENV INSTALLDIR /opt/bmc

ENV PATUSER patrol

 

# Add the installer file to container file system

# -------------------------------------------------------------

ADD patrol_cma_package.tar $BASEDIR

 

#[REVIEW] Setup filesystem and patrol user

# Encrypted value next to -p argument is the password for patrol user.

# To get encrypted value of your password for patrol user use following command.

# openssl passwd -crypt <password>

# ------------------------------------------------------------

RUN useradd -p Q70GsdNXWnwzs $PATUSER

RUN mkdir $INSTALLDIR

RUN chmod -R 777 $INSTALLDIR

 

# SETUP hostname command as this is being used by PATROL silent installer and not available as part of image

# --------------------------------------------------------------

RUN echo "cat /etc/hostname" > /usr/bin/hostname

RUN chmod +x /usr/bin/hostname

 

# Install PATROL package

# --------------------------------------------------------------

WORKDIR /opt/bmc_products

RUN sh RunSilentInstall.sh

 

# Setup required PATROL environment

# --------------------------------------------------------------

WORKDIR $INSTALLDIR/Patrol3

ENV PATH $PATH:$INSTALLDIR/Patrol3/$TARGET/bin

ENV PATROL_HOME=$INSTALLDIR/Patrol3/$TARGET

ENV PATROL_ADMIN=$PATUSER

 

# Remove PATROL installer

# --------------------------------------------------------------

RUN rm -rf /opt/bmc_products

 

# Define default command to start PATROL Agent

# This will start PATROL agent on default port 3181. To change the port replace command with following.

# CMD ["PatrolAgent", "-p", "6755"]

# -------------------------------------------------

 

CMD ["PatrolAgent"]

#***************END of Dockerfile****************

 

Building Docker Image:

  1. Create new directory on docker host
  2. Copy PATROL tar package in the new directory
  3. Copy Dockerfile in the same directory
  4. Review the Dockerfile sections marked with [REVIEW] and do the appropriate changes.
  5. Create new docker image using following command

          $ docker build -t "patrol:1" .

Note: In the command above “patrol” is the image name “1” is the tag. Do not remove “.” (dot) at the end of command.

 

Verify Docker image created:

 

Create container using Docker image:

To create container from docker image use following command:

$ docker run –d –p 5000:3181 –h patrolagent-1 “patrol:1”

Details of command above:

  1. -p 5000:3181 will bind the container port 3181 to 5000 of the docker host. To access PATROL agent externally user has to use 5000.
  2. –hostname is not mandatory however it will help to set valid hostname for the container which would be consumed by PATROL Agent for setting up device name in Truesight. By default container ID will be set as hostname

Note: To override ENV variables at run time please us –e argument of docker run command.

 

Things to know:

  1. PATROL Agent configuration running inside docker container can be changed using remote pconfig utility.
  2. Restart of PATROL agent using pconfig of console will not work. It stops the PATROL Agent however to start it container has to be started again.
  3. If not done while package creation, integration with Truesight will work by setting /AgentSetup/integration/integrationServices variable.