Nagios on Ubuntu 16.04
Installation Environment
- Virtual Machine (VM Virtualbox / VMWARE)
- HDD - 20 GB
- RAM - 4 GB
- Network Mode - Bridge
- UBUNTU - 16.04.4
- IP address - Static / Dynamic
- Hostname - www.example.com
Nagios Installation Steps:
- Install a fresh Ubuntu OS (16.04.4) in the VM.
- Update and upgrade existing packages.
- Install packages and dependencies for nagios core as shown below:
root@www:/home/bolcorp# apt install apache2 libapache2-mod-php7.0 php7.0 wget unzip zip autoconf gcc libc6 make apache2-utils libgd-dev
- Create user for nagios and modify it’s group. We need to configure it as shown below:
root@www:/home/bolcorp# useradd nagios
root@www:/home/bolcorp# usermod -a -G nagios www-data
- Now we will download and unzip nagios package as follows.
root@www:/home/bolcorp#
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
root@www:/home/bolcorp# tar xvzf nagios-4.3.4.tar.gz
root@www:/home/bolcorp# cd nagios-4.3.4/
root@www:/home/bolcorp/nagios-4.3.4# ls
base daemon-init.in Makefile sample-config cgi docs Makefile.in subst Changelog doxy.conf make-tarball subst.in
common functions mkpackage t config.guess html module tap config.log include nagios.spec test config.status indent-all.sh nagios.sysconfig THANKS config.sub indent.sh openrc-init t-tap configure INSTALLING openrc-init.in update-version
configure.ac install-sh pkginfo UPGRADING contrib LEGAL pkginfo.in worker CONTRIBUTING.md lib README xdata
daemon-init LICENSE README.asciidoc
- Now configure the nagios as follows:
root@www:/home/bolcorp/nagios-4.3.4#
./configure --with-httpd-conf=/etc/apache2/sites-enabled
root@www:/home/bolcorp/nagios-4.3.4# make all
root@www:/home/bolcorp/nagios-4.3.4# make install
root@www:/home/bolcorp/nagios-4.3.4# make install-init
root@www:/home/bolcorp/nagios-4.3.4# make install-commandmode
root@www:/home/bolcorp/nagios-4.3.4# systemctl enable nagios.service
root@www:/home/bolcorp/nagios-4.3.4# make install-config
root@www:/home/bolcorp/nagios-4.3.4# make install-webconf
- We will create a username and password for GUI login in nagios.
root@www:/home/bolcorp/nagios-4.3.4#
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
- Now restart all services.
root@www:/home/bolcorp/nagios-4.3.4# a2enmod cgi
root@www:/home/bolcorp/nagios-4.3.4# systemctl restart apache2
root@www:/home/bolcorp/nagios-4.3.4# systemctl start nagios
root@www:/home/bolcorp/nagios-4.3.4# systemctl enable nagios
- Now, we check the nagios in the browser:
http://192.168.100.243/nagios
- Now, we will install some additional plugins for the nagios, as follows:
root@www:/home/bolcorp#
apt install libmcrypt-dev make libssl-dev bc gawk dc build-essential snmp libnet-snmp-perl gettext libldap2-dev smbclient fping libmysqlclient-dev qmail-tools libpqxx3-dev libdbi-dev
root@www:/home/bolcorp# wget https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
root@www:/home/bolcorp# tar xvfz release-2.2.1.tar.gz
root@www:/home/bolcorp# cd nagios-plugins-release-2.2.1/
root@www:/home/bolcorp/nagios-plugins-release-2.2.1# ./tools/setup
root@www:/home/bolcorp/nagios-plugins-release-2.2.1# ./configure root@www:/home/bolcorp/nagios-plugins-release-2.2.1# make
root@www:/home/bolcorp/nagios-plugins-release-2.2.1# make install
root@www:/home/bolcorp/nagios-plugins-release-2.2.1#
ls /usr/local/nagios/libexec/
check_apt check_icmp check_nntps check_spop check_breeze check_ide_smart check_nt check_ssh check_by_ssh check_ifoperstatus check_ntp check_ssmtp check_clamd check_ifstatus check_ntp_peer check_swap check_cluster check_imap check_ntp_time check_tcp check_dbi check_ircd check_nwstat check_time check_dhcp check_jabber check_oracle check_udp
check_dig check_ldap check_overcr check_ups check_disk check_ldaps check_pgsql check_uptime check_disk_smb check_load check_ping check_users check_dns check_log check_pop check_wave check_dummy check_mailq check_procs negate
check_file_age check_mrtg check_real urlize check_flexlm check_mrtgtraf check_rpc utils.pm check_fping check_mysql check_sensors utils.sh check_ftp check_mysql_query check_simap
check_hpjd check_nagios check_smtp
check_http check_nntp check_snmp
- Now restart all service again.
root@www:/home/bolcorp/nagios-plugins-release-2.2.1# a2enmod ssl
root@www:/home/bolcorp/nagios-plugins-release-2.2.1# a2ensite default-ssl.conf
root@www:/home/bolcorp/nagios-plugins-release-2.2.1# systemctl restart apache2
- Check the nagios server address in the web browser.
http:// <nagios_server_ip_address>
Use user name & password to login to the panel.
User: nagiosadmin
Pass: <as set before>
- Now we will add devices and poll and discover their data in the nagios server dashboard panel, as follows:
root@www:/home/bolcorp#
head /usr/local/nagios/etc/objects/localhost.cfg -n 34 > /usr/local/nagios/etc/objects/google.cfg
sed -i "s/localhost/Google DNS/g" /usr/local/nagios/etc/objects/google.cfg
sed -i "s/127.0.0.1 / 8.8.8.8/g" /usr/local/nagios/etc/objects/google.cfg
echo "cfg_file=/usr/local/nagios/etc/objects/google.cfg" >> /usr/local/nagios/etc/nagios.cfg
service nagios restart
Explanation:
[Line#1] finds the localhost.cfg file in the mentioned location and copies its first 34 lines and put it in the google.cfg file. You can name it as per your convenience.
[LIne#2] locates the google.cfg file and replace it’s locale host with Google DNS.
[Line#3] locates the google.cfg file and replace it’s locale_host ip with 8.8.8.8 (Google DNS). We can use FQDN also.
sed -i "s/127.0.0.1/www.google.com/g" /usr/local/nagios/etc/objects/google.cfg
[Line#4] locate and copy the google.cfg in to nagios.cfg
[Line#5] restart the nagios service.
References:
https://support.nagios.com/forum/viewtopic.php?f=7&t=37546
https://assets.nagios.com/downloads/nagiosxi/docs/Installing-Nagios-XI-Manually-on-Linux.pdf
Comments
Post a Comment