Nagios is powerful, but it's free version lacks an easy and intuitive UI to help you configure the system. Although it does have quite a learning curve, you will still be able to get a hold of it if you learn it step by step patiently.
Installation
# install prerequisites packages
sudo -i
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 libgd2-xpm-dev
# create nagios user and group
useradd nagios
groupadd nagcmd
usermod -a -G nagios,nagcmd www-data
# download nagios source (you may check which is the latest release here: (https://www.nagios.org/downloads/nagios-core/)
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
# extract the source, e.g. tar xzf nagios-4.3.4.tar.gz
# cd to source dir and compile
./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd-conf=/etc/apache2/sites-enabled
*** Configuration summary for nagios 4.3.4 2017-08-24 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: /run/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/init.d
Apache conf.d directory: /etc/apache2/sites-enabled
Mail program: /bin/mail
Host OS: linux-gnu
IOBroker Method: epoll
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
# enable apache2 rewrite and cgi module
a2enmod rewrite
a2enmod cgi
# create password to restrict access to nagios web
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
systemctl restart apache2.service
# copy event handler scripts to nagios dir (this is not a necessary step)
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
# in case you are curious, what is event handler? It is basically a script that are run when host or service change states. For example, when a http service is detected DOWN, you may want to call a script automatically to restart service, or to reboot a machine. Or just to create a trouble ticket in helpdesk system to notify front-line colleagues.
# install Nagios plugins
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
make
make install
# when something you want to monitor cannot be done by the standard plugins, search the community first, which may save you a lot of time. (https://exchange.nagios.org/directory/Plugins/)
# Now, let's start Apache and Nagios
systemctl start apache2
systemctl enable nagios
systemctl start nagios
# Open a browser and point to http://your_ip/nagios, that's it!
You may see now in "Hosts" and "Services", there is only a localhost and a few local services. Yes, it's monitoring the Ubuntu host itself... Next, let's start monitoring something more interesting...
沒有留言:
張貼留言