Knowing what's going on inside your databases is priceless. And configuring Nagios on a automated basis is better.
Using [Ansible] (http://docs.ansible.com/) playbooks you can easily achieve this. Let's setup Nagios with NRPE monitoring
The ultimate goal is to install and configure the [PERCONA monitoring plugins for Nagios] (http://www.percona.com/doc/percona-monitoring-plugins/1.1/nagios). The Percona monitoring plugins (or PMP) is a group of scripts created by MySQL experts, with good documentation, support for the newest versions of MySQL and InnoDB, great integration with other Percona software, such as Percona Server and Percona Toolkit. And the best: Easy to install and configure!
Ansible in a nutshell
- Python (2.4 or greater)
- Python modules:
- python-simplejson (if using python 2.4)
- python-mysqldb (For MySQL specific tasks)
- OpenSSH
The most easy way is using [Homebrew] (http://brew.sh/). Install Brew and then:
brew install ansible
If you're lucky, you have ansible on apt:
apt-get install ansible
However, most likely is that Ansible package have an old version (1.5) so it will be better to install from source
Using yum
yum install ansible
Ansible can be installed by cloning the git repo. All the info can be found on the Documentation for [installing from source] (http://docs.ansible.com/intro_installation.html#running-from-source)
Since we're using Vagrant, fire up the VMs is as easy as run:
vagrant up
Since i don't like to write the user password e-v-e-r-y time a playbook is executed, i just create a user on all the VMs that will use:
- My ssh public key (Actually, it will use any key that resides in the path "~/.ssh/id_rsa.pub")
- My username, which is "daniel"
- And i give sudo with no password to that user. Less risky options available but not in this repository :)
ansible-playbook plays/set-keys.yml --ask-pass -e "username=daniel"
This step will ask for a SSH password. All the Vagrant boxes uses the user vagrant and the password: vagrant
This machine will be the monitoring box. Things installed:
- Nagios core (compiled)
- Nagios plugins (compiled)
- Nagios NRPE plugin
- ...And all the friends that Nagios need to run happy (Apache, php, etc...)
Also, it sets the user and password required to open the Dashboard url. In this case, user/password are: nagiosadmin/nagiosadmin
ansible-playbook plays/install-nagios-server.yml
We need something to be subject of monitoring! In this step, the Percona repository is installed and also the Percona Server will be set up
ansible-playbook plays/basic-mysql.yml
All the monitored nodes needs to run the NRPE server and the Nagios plugins. It's just a couple of packages available in the repo. Additionaly, the Percona Nagios Plugins are installed. This guys will perform the MySQL monitoring magic
ansible-playbook plays/install-nrpe-nodes.yml
This step is the reason for all this trouble. This playbook tells the Nagios server the hosts that needs to check and the services on thoses hosts to monitor.
ansible-playbook plays/configure-services.yml
We can run all the above steps... or we can have a single YAML file that includes all the steps and just call that one ( + set-keys.yml):
ansible-playbook plays/set-keys.yml --ask-pass -e "username=daniel"
ansible-playbook main.yml