Enable SNMP on VMware ESXi host

Simple Network Management Protocol (SNMP) allows management programs to monitor VMware and control networked devices in VMware ESXi. SNMP configuration for ESXi requires vSphere Command-Line Interface.

vCenter Server and ESXi systems include different SNMP agents.

  • vCenter Server SNMP agent. The SNMP agent included with vCenter Server can send traps when the vCenter Server system is started or when an alarm is triggered on vCenter Server.
  • Host-based embedded SNMP agent. ESXi 4.0 and later includes an SNMP agent embedded in the host daemon (hostd) that can send traps and receive polling requests such as GET requests.
  • Net-SNMP-based agent. Versions of ESX released before ESX/ESXi 4.0 include a Net-SNMP-based agent. You can continue to use this Net-SNMP-based agent in ESX 4.x with MIBs supplied by your hardware vendor and other third-party management applications.

The host-based embedded SNMP agent is disabled by default. You must configure at least one community for the agent. Use the below steps to Enable SNMP on VMware ESXi host.

Enable SNMP on VMware ESXi 5.5

SSH to your ESXi host using root credentials.

Use the following commands to enable SNMP. Replace CommunityString with your desired community string.

# esxcli system snmp set --communities <CommunityString>
# esxcli system snmp set --enable true
# esxcli network firewall ruleset set --ruleset-id snmp --allowed-all true
# esxcli network firewall ruleset set --ruleset-id snmp --enabled true
# /etc/init.d/snmpd restart

Enable SNMP on VMware ESXi 6.x

SSH to your ESXi host using root credentials.

Use the following commands to enable SNMP. Replace CommunityString with your desired community string.

# esxcli system snmp set -r
# esxcli system snmp set -c <CommunityString>
# esxcli system snmp set -p 161
# esxcli system snmp set -L "City, State, Country"
# esxcli system snmp set -C [email protected]
# esxcli system snmp set -e yes

That’s it.

Test Your VMware ESXi SNMPd Service with Snmpwalk

The simplest way to test your snmpd service is to walk it with snmpwalk on your linux server.

# snmpwalk -v 1 -c CommunityString esxihost1.cloudkb.net

Refer the following screen to check the SNMP service and ports on vcenter security profile.






Build Applications with Docker Compose Examples

Docker Compose is an orchestration tool for Docker that allows you to define a set of containers and their interdependencies in the form of a YAML file. You can then use Docker Compose to bring up part or the whole of your application stack, as well as track application output, etc. Build applications with docker compose and use it on your continues delivery.

If you have started working with Docker and are building container images for your application services, you most likely have noticed that after a while you may end up writing long `docker run` commands. These commands while very intuitive can become cumbersome to write, especially if you are developing a multi-container application and spinning up containers quickly.

docker compose example

Docker Compose also allows you to manage your application as a single entity rather than dealing with individual containers.

Install Docker Compose

You can install Docker Compose on macOS, Windows and 64-bit Linux OS.

Uset this command to install on your linux OS, download Docker Compose, replacing $dockerComposeVersion with the specific versions.

# curl -L https://github.com/docker/compose/releases/download/$dockerComposeVersion/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

Example to download Docker Compose in linux with docker 1.13

# curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose
# docker-compose --version
docker-compose version 1.13.0, build 1719ceb


Install using pip

If you install using pip, use this command but make sure python system packages that conflict with docker-compose dependencies.

# pip install docker-compose

Install inside a container

Simple bash script wrapper will install it.

# curl -L --fail https://github.com/docker/compose/releases/download/1.13.0/run.sh > /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose

Docker compose sample deployment

After you installed docker compose successfully, create a YAML file which will contain the docker image and environment details.

Create a docker-compose.yml file with your WordPress blog and MySQL container with persistence data using volume mount.

version: '2'

image: mysql:5.7
- db_data:/var/lib/mysql
restart: always
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress_pa33

- db
image: wordpress:latest
- "8000:80"
restart: always


That’s it. Now, run this command from your project directory.

# docker-compose up -d

Once pull all images and start containers, wait for few seconds to initialize the database, etc and open http://MACHINE_IP:8000 in a browser.

Docker Compose example commands

You can start the containers with the up command in daemon mode (by adding -d as a param) or by using the start command:

# docker-compose start

Stopping containers

# docker-compose stop

Remove containers

To stop and remove all the containers use the down command

# docker-compose down

or the rm command if the containers are stopped already.

# docker-compose rm --all




Docker commands with example

Use these Docker commands with an example for your reference.

Container – Docker Containers are what docker is built on. They encapsulate an application and all of its libraries and dependencies, so it can be run anywhere Docker is installed.

Image – A Docker Image is a file that is essentially a snapshot of a container. You can create a container by running a Docker Image.

Layer – a set of read-only files to provision the system. Think of a layer as a read only snapshot of the filesystem.

Registry / Hub is the central place where all publicly published images live. You can search it, upload your images there and when you pull a docker image, it comes the repository/hub.  You can also create private docker registry in your own cloud.

Docker machine is a VM within which you can run Docker containers. On Linux you can run docker containers natively, but on OSX and Windows you need a layer of abstraction. A docker machine will spin a very lightweight virtual machine that integrates with the docker command line utilities really well.

Docker compose is a utility to run multiple containers as a system of containers. It will take care of making them aware of each other and ensure they’re properly connected to each other. This means you can run your application in one container and your database in a different container, and your analytics application in a different container, and so on. This is the ultimate isolation and it means that your applications are independent and are run in development in a very similar way to how the system might work in production.

docker commands with example


Docker Cheat Sheet examples

Create and start container, run command

docker run -it --name <container_name> <image> -d

Start, stop and restart the container

docker [start|stop|restart] <container_name> or <container-id>

Use docker attach to attach to a running container using the container’s ID or name, either to view its ongoing output or to control it interactively.

docker attach <container_name>

Kill all running containers

docker kill $(docker ps -q)

Delete dangling images the ones that are not tagged properly and are hanging around.

docker rmi $(docker images -q -f dangling=true)

Remove all stopped containers, this will actually try to remove all the containers, but will fail to do so with the running ones, so only stopped containers will be gone after that.

docker rm $(docker ps -a -q)

Interacting with a container

Run a command in the container

docker exec -it <container_name> command.sh

Show the container logs (use -f option)

docker logs <option> <container_name>

Create an image from a running container

docker commit -m "commit message" -a "author" <container_name> username/image_name:tag

Copy files from the container to the host

docker cp <container_name>:/home/foo.txt <path>

Copy files to the container from host.

docker cp foo.txt <container_name>:/home

or if you want copy all large files, use below command

tar -cv * | docker exec -i <container_name> tar x -C <destination-folder-inside-container>

Mount the directory in host to a Container.

docker run -v /opt/test:/home/test <image> -d

Docker port mapping example
80 – host_port
8080 – container_port

docker run -d -p 80:8080 --name test_container <image>

Docker port mapping to specific IP

docker run -d -p --name test_container <image>

Set an environment variable in docker container

docker run -d -p -e VIRTUAL_HOST=domain.com --name test_container <image>

List the running containers. With -a option, it shows running and stopped Containers.

docker ps

Show container information like IP address.

docker inspect <container_name>

See the top process in container

docker top <container_name>

Docker Images command line

Create an image with Dockerfile.

echo -e "FROM centos:7\nRUN yum install -y openssh-server\nRUN systemctl enable sshd.service\nCMD ["/bin/bash"]" > Dockerfile
docker build -t <image> .

Login to the docker image

docker run -it <image> bash

Login to the docker container

docker exec -it <container_name> bash

Pull docker images (example is for the default centos image, you can specify the custom image name)

docker pull centos

Push docker images

Login docker hub ( docker login )

docker push gopkris2000/example

Delete a docker image

docker rmi gopkris2000/example

List all the images ( use -a to list all )

docker images

To show docker image information

docker inspect gopkris2000/example

To show command history of an image

docker history gopkris2000/example

Remove all untagged /none images

docker rmi $(docker images -a|awk '/none/ { print $3 }')