Skip to content

Instantly share code, notes, and snippets.

@sv99
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sv99/fbb254af595c17d41c20 to your computer and use it in GitHub Desktop.
Save sv99/fbb254af595c17d41c20 to your computer and use it in GitHub Desktop.

=========================================== nagios from source with vagrant and ansible

Main perposes - automation building and configuration nagios box based on SOC mini computers (RPi or BBB). Vagrant used for debug and test configuration.

Vagrant

vagrant up
vagrant provision
vagrant ssh

Same problems in ansible provision configuration. Sudo - need set only in yml, not in Vagrant file.

Configuration files and directory

conf dir contain configs files, this files copied on the target machine

  • nagios-plugins - additional plugins to /usr/local/nagios/libexec
  • ssh - key nagios user to /usr/local/nagios/.ssh, used nagios process for connecting to the management host
  • www - index.html - redirector to /nagios/ and phpinfo.php, replacemnt for default www pages
  • localhost - nagios config to /usr/local/nagios/etc

Place files in this directory - copy this files to the target.

Nagios configuration make + m4

My Nagios configuration use make for maintaining.

m4 used for generating working config files. *.m4 - replase *.cfg files with same name. Using prepared templates we have most services single line defined.

m4 directory contain common templates from this files cfg files not generated

Regenerate config and restart nagios

make

Test config

make test

Backup config - produce ../localhost-xx.tar.gz with timestamp

make backup

m4/nagios.m4 - base file for using in templates

first line in template

include(`nagios.m4')dnl

Ansible

Ansible playlist based on http://networklore.com/ansible-install-nagios/

Not use split configuration. Three yml:

  1. lighttpd_php.yml
  2. nagios1.yml - install nagios from source
  3. nagios_cfg.yml - provision my working config on installed nagios

nagios_cfg.yml - overload working config, may using for update config

Standalone ansible playlist may using for maintaning working configuration on the nagios server device. For independent startup need inventory file - nagios_inventory

echo monitorbb ansible_ssh_user=debian > nagios_inventory
ansible_playlist -i nagios_inventory --list-host nagios_cfg.yml
ansible_playlist -i nagios_inventory nagios1.yml

BeagleBoneBlack debian

Install date: 21.08.2014

Flasher from http://elinux.org/BeagleBoardDebian

diskutil list
diskutil umount disk2s1
sudo dd if=./BBB-eMMC-flasher-debian-7.6-console-armhf-2014-08-13-2gb.img of=/dev/rdisk2 bs=1m

10 min - writing flash

Insert flash - BOOT button + power on - after start flash off button. Lid run ~ 5 min. Write end all lid.

debian: temppwd

apt-get update
apt-get upgrade
apt-get install ntp
apt-get install locales
dpk-reconfigure locales
dpk-reconfigure tzdata
# -> beaglebone <-
passwd
vi /etc/hostname

Reboot. Copy ssh key for nonpassword accessfor ansible and management

ssh-copy-id -i ~/.ssh/id_rsa debian@monitorbb

Bootstrap nagios configuration:

apt-get install python
ansible_playlist -i nagios_inventory nagios1.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment