Você está na página 1de 5

Introduction

setup a monitoring solution using Icinga. Icinga should monitor the Apache Web Server and the
Mysql Database server and send logs to Amazon S3 dynamically using Bash Scripting.

Prerequisites
Require root access to an Ubuntu 14.04 server with terraform and ansible

Install Icinga
Run the following command to add the Icinga PPA to your package manager:
sudo add-apt-repository ppa:formorer/icinga

Then update your apt package database:


sudo apt update

Now install Icinga and MySQL with apt:


sudo apt install icinga icinga-doc icinga-idoutils mysql-server libdbdmysql mysql-client

Now you will be presented with a series of prompts regarding your Icinga installation.
Here is a list of the prompts, and how you should answer them:

MySQL Configuration: Enter a new MySQL root user password

PostFix Configuration: Select "Internet Site"

PostFix Configuration: Enter your Fully Qualified Domain Name


(example.com, for example)

Configuring icinga-cgi: Enter "icingaadmin" user's password (login to


access Icinga).

Configuring icinga-common: Enter "No" to enabling external


commands

Configuring icinga-idoutils: Enter "Yes" to configuring database for


icinga-idoutils with dbconfig-common

Configuring icinga-idoutils: Select "mysql" as the database type

Configuring icinga-idoutils: Enter MySQL root password (that you just


assigned above)

Configuring icinga-idoutils: Enter a new icinga-idoutils database user


password
Icinga is now installed, but we still need to configure a few things before we can start it.
Note that Apache HTTP server and Postfix were installed as part of that process.
Add Apache user (www-data) to nagios group:
sudo usermod -a -G nagios www-data

Enable the ido2db daemon to start on boot up, which stores Icinga events and configurations in
the database. Edit Icinga default configuration:
sudo vi /etc/default/icinga

Change the value of IDO2DB to yes, so it looks like the following:


IDO2DB=yes
Save and quit. Now start the ido2db service:
sudo service ido2db start

Now Icinga is configured and ready to be started:


sudo service icinga restart

Accessing the Icinga User Interface


Go to http://yourhost/icinga, and log in using the icingaadmin login that you set up
during the Icinga installation.
You should see that Icinga is monitoring one host, localhost (your Icinga server), and
seven services, like this:

The top row shows that the single monitored host is "Up", and the bottom row shows
that there are seven "OK" monitored services.

Monitoring Publicly Available Services


Create a file with the name of your host, with this command (substitute yourhost with
your own hostname):
sudo vi /etc/icinga/objects/yourhost.cfg

Now add the following, replacing the values of host_name with your own hostname (in
both places),alias with a description of the host, and address with the value of your
host's public IP address:
define host {
use

generic-host

host_name

web-1

alias

A Web Server

address

203.143.xxx.xxx

}
define service {
use

generic-service

host_name

web-1

service_description

HTTP

check_command

check_http

Now save and quit. Reload your Icinga configuration to put any changes into effect:
sudo service icinga reload

Install Docker

Verify that you have curl installed


which curl

If curl isnt installed, install it after updating your manager:


sudo apt-get update
sudo apt-get install curl

Get the latest Docker package.


curl -fsSL https://get.docker.com/ | sh

Verify docker is installed correctly.


docker help

Create MYSQL and Apache2 Dockerfile


Create mysql Dockerfile
touch Dockerfile

Plese refer the apache and mysql Dockerfile

Run mysql and apache2 dockers


docker run -p 8080:80 -p 4443:443 -d apache2
docker run -p 4406:3306 d mysql

You can see running dockers as below

Docker ps

Automations
You can write playbook in order to automate deployment task, all required files are
attached with the document
ansible-playbook -i hosts -vv run-ansible.yml

Você também pode gostar