Nagios Debian7: Difference between revisions

From VoIPmonitor.org
Jump to navigation Jump to search
(Created page with "Download and compile latest nagios from http://sourceforge.net/projects/nagios/files/: cd /usr/src wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.8/...")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:
  apt-get install -y apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev libssl-dev
  apt-get install -y apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev libssl-dev
  cd nagios-4.0.8
  cd nagios-4.0.8
  ./configure --exec-prefix=/usr/local/nagios/ --prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagios
  ./configure --exec-prefix=/usr/local/nagios/ --prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd
   
   
  groupadd -g 9000 nagios
  groupadd -g 9000 nagios
Line 32: Line 32:


Change startup options for nagios
Change startup options for nagios
vim /etc/init.d/nagios  //add following lines
vim /etc/init.d/nagios  //add following lines after # Short-Description ... line
  Default-start: 2 3 4 5
  # Default-start: 2 3 4 5
  Default-Stop:
  # Default-Stop:
 
Run commands
Run commands
  chmod +x /etc/init.d/nagios
  chmod +x /etc/init.d/nagios
Line 44: Line 45:
Install mail client
Install mail client
  apt-get install -y sendmail-bin sendmail heirloom-mailx
  apt-get install -y sendmail-bin sendmail heirloom-mailx
At end of /etc/mail/sendmail.mc switch Masq.options to be before DefaultMailerOpt to nbe in right order like this:
At end of /etc/mail/sendmail.mc switch Masq.options with DefaultMailerOpt to be in right order like this:
  ....
  ....
  dnl # Masquerading options
  dnl # Masquerading options
Line 69: Line 70:


vim /etc/apache2/sites-available/default //replace existing data with:
vim /etc/apache2/sites-available/default //replace existing data with:
<VirtualHost *:443>
<VirtualHost *:443>
     ServerAdmin webmaster@localhost
     ServerAdmin webmaster@localhost
     ServerName my.nagiosserver.crt
     ServerName my.nagiosserver.crt
     DocumentRoot /var/www/my.nagiosserver
     DocumentRoot /var/www/my.nagiosserver
 
     <Directory />
     <Directory />
         Options FollowSymLinks
         Options FollowSymLinks
         AllowOverride None
         AllowOverride None
     </Directory>
     </Directory>
 
     <Directory /var/www/my.nagiosserver>
     <Directory /var/www/my.nagiosserver>
         Options -Indexes FollowSymLinks MultiViews
         Options -Indexes FollowSymLinks MultiViews
Line 85: Line 86:
         allow from all
         allow from all
     </Directory>
     </Directory>
 
     SSLEngine On
     SSLEngine On
     SSLCertificateFile /etc/apache2/ssl/my.nagiosserver.crt
     SSLCertificateFile /etc/apache2/ssl/my.nagiosserver.crt
     SSLCertificateKeyFile /etc/apache2/ssl/my.nagiosserver.key
     SSLCertificateKeyFile /etc/apache2/ssl/my.nagiosserver.key
</VirtualHost>
</VirtualHost>
 
mkdir /var/www/my.nagiosserver
cp -r /usr/src/nagios-4.0.8/html/* /var/www/my.nagiosserver


cp /usr/lib/nagios/plugins/ /usr/local/nagios/libexec/
service apache2 restart
chown -R nagios:nagios /usr/local/nagios/libexec/


////
create nagios-www (web pages)
chown www-data -R /etc/nagios3/conf.d/
mkdir /var/www/my.nagiosserver
apt-get install sudo
cp -r /usr/src/nagios-4.0.8/html/* /var/www/my.nagiosserver
vim /etc/sudoers
  cp /usr/lib/nagios/plugins/ /usr/local/nagios/libexec/
  add "www-data ALL=(nagios) NOPASSWD: ALL"
chown -R nagios:nagios /usr/local/nagios/libexec/
chown www-data -R /var/lib/nagios3/spool/checkresults
//////


chown -R nagios:www-data /usr/local/nagios/bin/nagios
To create privileges for www-data to restart nagios (to reload config from voipmonitor gui)////
chown -R www-data /usr/local/nagios/var/spool/checkresults
chown www-data -R /var/lib/nagios3/spool/checkresults
 
chown -R nagios:www-data /usr/local/nagios/bin/nagios
chown www-data:nagioscmd /usr/local/nagios/var/rw/nagios.cmd
chown -R www-data /usr/local/nagios/var/spool/checkresults
 
chown www-data:nagioscmd /usr/local/nagios/var/rw/nagios.cmd
/etc/sudoers
apt-get install sudo
vim /etc/sudoers //add line www-data after root .. line
  root    ALL=(ALL:ALL) ALL
  root    ALL=(ALL:ALL) ALL
www-data ALL=(ALL) NOPASSWD: /usr/bin/killall, /usr/local/nagios/bin/nagios
www-data ALL=(ALL) NOPASSWD: /usr/bin/killall, /usr/local/nagios/bin/nagios
# Allow members of group sudo to execute any command
%sudo  ALL=(ALL:ALL) ALL
  ...
  ...
vim /etc/kiler.sh
sudo -u nagios /usr/bin/killall -HUP nagios
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
service apache2 restart


in GUI
in GUI

Latest revision as of 12:17, 23 October 2014

Download and compile latest nagios from http://sourceforge.net/projects/nagios/files/:

cd /usr/src
wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.8/nagios-4.0.8.tar.gz/download -O nagios-4.0.8.tar.gz
tar -xzf nagios-4.0.8.tar.gz
apt-get install -y apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev libssl-dev
cd nagios-4.0.8
./configure --exec-prefix=/usr/local/nagios/ --prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd

groupadd -g 9000 nagios
groupadd -g 9001 nagcmd
useradd -u 9000 -g nagios -G nagcmd -d /usr/local/nagios -c 'Nagios Admin' nagios
adduser www-data nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin


Download and compile latest nagios plugins from: http://www.nagios.org/download/plugins

cd /usr/src
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
tar -xzf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3/
./configure --with-nagios-user=nagios --with-nagios-group=nagios  --with-openssl=/usr/bin/openssl --enable-perl-modules --enable-libtap
make
make install

Change startup options for nagios vim /etc/init.d/nagios //add following lines after # Short-Description ... line

# Default-start: 2 3 4 5
# Default-Stop:

Run commands

chmod +x /etc/init.d/nagios
update-rc.d nagios defaults

Install nagios dependences

apt-get install -y nagios-nrpe-plugin

Install mail client

apt-get install -y sendmail-bin sendmail heirloom-mailx

At end of /etc/mail/sendmail.mc switch Masq.options with DefaultMailerOpt to be in right order like this:

....
dnl # Masquerading options
FEATURE(`always_add_domain')dnl
MASQUERADE_AS(`vm-debian')dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl
dnl # Default Mailer setup
MAILER_DEFINITIONS
MAILER(`local')dnl 
MAILER(`smtp')dnl

And regenerate:

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf


HTTPS enable SSL for nagios:

mkdir /etc/apache2/ssl
cd /etc/apache2/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout my.nagiosserver.key -out my.nagiosserver.crt
a2enmod ssl

vim /etc/apache2/conf.d/nagios.conf

uncomment all SSLRequireSSL

vim /etc/apache2/sites-available/default //replace existing data with:

<VirtualHost *:443>
   ServerAdmin webmaster@localhost
   ServerName my.nagiosserver.crt
   DocumentRoot /var/www/my.nagiosserver

   <Directory />
       Options FollowSymLinks
       AllowOverride None
   </Directory>

   <Directory /var/www/my.nagiosserver>
       Options -Indexes FollowSymLinks MultiViews
       AllowOverride All
       Order allow,deny
       allow from all
   </Directory>

    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/my.nagiosserver.crt
    SSLCertificateKeyFile /etc/apache2/ssl/my.nagiosserver.key
</VirtualHost>
service apache2 restart

create nagios-www (web pages)

mkdir /var/www/my.nagiosserver
cp -r /usr/src/nagios-4.0.8/html/* /var/www/my.nagiosserver
cp /usr/lib/nagios/plugins/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/

To create privileges for www-data to restart nagios (to reload config from voipmonitor gui)////

chown www-data -R /var/lib/nagios3/spool/checkresults
chown -R nagios:www-data /usr/local/nagios/bin/nagios
chown -R www-data /usr/local/nagios/var/spool/checkresults
chown www-data:nagioscmd /usr/local/nagios/var/rw/nagios.cmd
apt-get install sudo

vim /etc/sudoers //add line www-data after root .. line

root    ALL=(ALL:ALL) ALL
www-data ALL=(ALL) NOPASSWD: /usr/bin/killall, /usr/local/nagios/bin/nagios
...

in GUI Settings->Systemconfiguration->:

Enable nagios: TRUE
Nagios user: nagios
Path to nagios binary: /usr/local/nagios/bin/nagios
Path to nagios.cfg: /usr/local/nagios/etc/objects/nagios.cfg
Path to vm.cfg: /usr/local/nagios/etc/objects/vm.cfg 
Path to status.dat: /var/cache/nagios3/status.dat
Command which reload config: /usr/bin/killall -HUP nagios
run sudo before reload command: TRUE


source: http://midactstech.blogspot.cz/2013/09/how-to-install-nagios-on-debian-wheezy.html