User:Anatbaz/sandbox

Install an ec2 machine
"PasswordAuthentication yes"
 * 1) Using the AWS Management Console I created two new ubuntu instances:
 * 2) 52.27.117.61,user:ubuntu,password:trusteer, this instance was used for the remote installation of nagios.
 * 3) 52.27.172.118,user:ubuntu,password:trusteer, this instance was used for the nagios server and client checks.
 * 4) I created a unique security group with the aws management console and allowed port 22 tcp and port 80 tcp only for my computer's ip and Trusteer's ip.
 * 5) connected both machines with the private keys that were supplied by amazon, and added to /etc/ssh/sshd.config the line that allows me to connect to my machine with a password only and restarted the sshd service.

Install Nagios 3.x on the machine
name: install nrpe from repo apt: pkg=nagios-nrpe-server state=present
 * 1) On my first machine I installed the ansible software by using the commands
 * 2) sudo apt-get install software-properties-common
 * 3) sudo apt-add-repository ppa:ansible/ansible
 * 4) sudo apt-get update
 * 5) sudo apt-get install ansible
 * 6) I downloaded the relevant ansible playbook that installs nagios on a remote server. That is only the base playbook- later on I will document the changes I committed on that playbook.
 * 7) sudo wget "http://downloads.sourceforge.net/project/nelmon/release/nelmon-20150209.zip?r=&ts=1437579934&use_mirror=garr"
 * 8) I added nagios machine's IP to the /etc/ansible/hosts
 * 9) I edited the playbook group_vars in order to install 3.5.1.
 * 10) I edited the roles/nagios and changed to home directory on which the nagios and its plugins will be compiled. In addition, because I experienced some issues with the nrpe compiling I decided to write a task which will install NRPE from the repository.
 * 1) I edited roles/apache and changed the name of the service to apache2 so it will be compatible with ubuntu.
 * 2) I added a task to restart apache after the nagios compiling is done (so nagios will be able to start running).
 * 3) I ran the playbook by the command
 * 4) ansible-playbook site.yml -u ubuntu -s --ask-pass
 * 5) The playbook installed nagios-server daemon and nrpe client and plugins.

Write a Nagios plugin
and added:
 * 1) First I transferred all the example files to the machine with using WinSCP.
 * 2) I wrote a bash script to do the requested task. The script:
 * 1) I saved the script /usr/lib/nagios/plugins/test.sh and changed its permissions chmod +x test.sh.
 * 2) I deleted to original /etc/nagios/nrpe.cfg and replaced it with this file:
 * 1) I edited /usr/local/nagios/etc/objects/commands.cfg and added the following line:
 * 1) In order to test the plugin I applied it on local host. I edited sudo nano /usr/local/nagios/etc/objects/localhost.cfg
 * 1) I restarted nrpe  sudo service nagios-nrpe-server restart. I had some problems with that command so I decided to run the daemon manually with the command /usr/sbin/nrpe  -c /etc/nagios/nrpe.cfg -d.
 * 2) I restarted nagios sudo service nagios restart.
 * 3) In order to see that my script is working I ran the command /usr/local/nagios/libexec/check_nrpe -H localhost -c test_bash
 * 4) I tested the plugin with creating 200 files (using touch). The plugin alerted CRITICAL, and after 5 minutes it became OK.