Nagios installation
Install Ubuntu with LAMP & postfix & Build essentials.
sudo apt-get install build-essential libgd2-xpm-dev apache2-utils unzip
Nagios User Setup
useradd -m -s /bin/bash nagiospasswd nagios
usermod -G nagios nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
Download And Unzip Nagios And Nagios Plugins
mkdir downloadscd /downloads
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.2.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
tar -zxf nagios-4.4.2.tar.gz
tar -zxf nagios-plugins-2.2.1.tar.gz
Install Nagios
cd /downloads/nagios-4.4.2
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
make install-classicui
Nagios Password
This is the password you will need to look at the nagios pages. If you install Nagios to a different directory please change this command to where the Nagios etc. folder will be.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Enter your password when prompted. Phoenix0
Now we will restart Apache to make sure all of the changes take effect:
/etc/init.d/apache2 restart
Nagios Plugins
cd /downloads/nagios-plugins-2.2.1.tar.gz/
make all
make install
make install-init
make install-commandmode
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Open your favorite editor and open /usr/local/nagios/etc/objects/contacts.cfg . (change to J's email)
Once you have saved your changes to the contacts.cfg we need to verify that there are no errors in the configuration of Nagios.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Now we are going to start nagios:
service nagios start
/etc/init.d/nagios start
postconf -e 'relayhost=yourmailserver.com'
postconf -e 'smtp_sasl_auth_enabled = yes'
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
postconf -e 'smtp_sasl_security_options ='
echo "mail.gmail.com emailusername:scanning@xxxxx.org:Password84" > /etc/postfix/sasl_passwd
Now we will need to change the password file attributes so only root has access to read it.
chown root:root /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
Now we are going to set the map that will change your outbound messages from nagios to your email server username/email address.
echo "nagios scanning@xxxxxx.org" /etc/postfix/canonical
echo "canonical_maps = hash:/etc/postfix/canonical" >> /etc/postfix/main.cf
postmap /etc/postfix/canonical (failed)
/etc/init.d/postfix restart
Now that this all has been completed you can restart your system.
Once your system has come back up you will be able to login to the website and look at your first Nagios installation.
http://yourserver/nagios/
Changing nagios startup screen to tactical view
Now we need to make Nagios start at bootup:
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Change Default Email Address For Nagios Admin
Open your favorite editor and open /usr/local/nagios/etc/objects/contacts.cfg . (change to J's email)
Once you have saved your changes to the contacts.cfg we need to verify that there are no errors in the configuration of Nagios.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Now we are going to start nagios:
service nagios start
/etc/init.d/nagios start
Postfix Configuration For A Smarthost Relay
postconf -e 'relayhost=yourmailserver.com'
postconf -e 'smtp_sasl_auth_enabled = yes'
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
postconf -e 'smtp_sasl_security_options ='
echo "mail.gmail.com emailusername:scanning@xxxxx.org:Password84" > /etc/postfix/sasl_passwd
Now we will need to change the password file attributes so only root has access to read it.
chown root:root /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
Now we are going to set the map that will change your outbound messages from nagios to your email server username/email address.
echo "nagios scanning@xxxxxx.org" /etc/postfix/canonical
echo "canonical_maps = hash:/etc/postfix/canonical" >> /etc/postfix/main.cf
postmap /etc/postfix/canonical (failed)
/etc/init.d/postfix restart
Now that this all has been completed you can restart your system.
Once your system has come back up you will be able to login to the website and look at your first Nagios installation.
http://yourserver/nagios/
Changing nagios startup screen to tactical view
cd /usr/local/nagios/share
vi index.php
<replace line 2:
$url = 'main.php';
with
$url = '/nagios/cgi-bin/tac.cgi';
<save file>
vi index.php
<replace line 2:
$url = 'main.php';
with
$url = '/nagios/cgi-bin/tac.cgi';
<save file>
Adding an IP range
hen, Edit file /etc/apache2/sites-enabled/nagios.conf,
sudo nano /etc/apache2/sites-enabled/nagios.conf
And edit the following lines if you want to access nagios administrative console from a particular IP series.
Here, I want to allow nagios administrative access from 192.168.1.0/24 series only. So, I edited this file as shown below.
[...] ## Comment the following lines ## # Order allow,deny # Allow from all ## Uncomment and Change lines as shown below ## Order deny,allow Deny from all Allow from 127.0.0.1 192.168.1.0/24 [...]
source: http://www.howtoforge.com/nagios-installation-on-ubuntu-10.04-lucid-lynx-p3
source: https://support.nagios.com/forum/viewtopic.php?f=7&t=29198
source: https://www.unixmen.com/how-to-install-nagios-core-4-1-1-in-ubuntu-15-10/
No comments:
Post a Comment