Nagios

From Omnia
Revision as of 23:02, 24 January 2017 by Kenneth (talk | contribs) (→‎/run/lxcfs/controllers is not accessible)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Nagios

Nagios - http://nagios.org/

Documentation

Pronunciation

Nagios pronunciation « Nagios Community:

"People are always asking me what the proper pronunciation of Nagios is. Here goes... By egalstad (Ethan Galstad)" (flash audio)
nog - e - ohs

Quick Install

Install epel repo, rpmforge

Install EPEL

or

Install DAG (rpmforge) repository: (only needed for CentOS 5)

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Install Nagios:

yum install nagios nagios-plugins

If you use the EPEL repo, you will need to install individual plugins, or 'nagios-plugins-all'.

# yum install nagios-plugins-all
yum install nagios-plugins-ssh nagios-plugins-http nagios-plugins-ping nagios-plugins-tcp
yum install nagios-plugins-load nagios-plugins-users nagios-plugins-swap nagios-plugins-procs nagios-plugins-disk

Documentation

Nagios documentation and quick start can be found here:

/usr/share/nagios/docs/
/usr/share/nagios/docs/quickstart.html
http://nagios.sourceforge.net/docs

Online documentation:

Object Definitions (Services, Hosts, Etc) for Nagios v3:

Object Definitions (Services, Hosts, Etc) for Nagios v2

To view documentation locally:

ln -s /usr/share/nagios /var/www/html/nagios-docs
http://[host]/nagios-docs/
# quick start guide
http://[host]/nagios-docs/quickstart.html

Default Password

/etc/nagios/passwd

nagiosadmin:nagiosadmin    # nagiosadmin:RbdO4ou4PNyMg

To change it:

htpasswd /etc/nagios/passwd nagiosadmin

Performance Tuning

Tuning Nagios For Maximum Performance:

"So you've finally got Nagios up and running and you want to know how you can tweak it a bit... Here are a few things to look at for optimizing Nagios. Let me know if you think of any others..."

Quick Configuration

Change contact email address:

/etc/nagios/objects/contacts.cfg

define contact{
        contact_name                    nagiosadmin
        # change email
        email                           nagios@k.ttak.org
...
}

# add contact
define contact{
  contact_name  kenneth
  use           generic-contact
  alias         Kenneth Burgener
  email         nagios@k.ttak.org
}

define contactgroup{
  contactgroup_name       admins
  alias                   Nagios Administrators
  #members                 nagiosadmin,admin,kenneth,mark
  # add kenneth
  members                 nagiosadmin,kenneth
}

Create an authentication file:

# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
htpasswd /etc/nagios/passwd admin
htpasswd /etc/nagios/passwd kenneth

Note: if you choose a user name other than 'nagiosadmin' make sure to add privileges to the cgi.cfg:

/etc/nagios/cgi.cfg

  authorized_for_system_information=nagiosadmin,admin
  authorized_for_configuration_information=nagiosadmin,admin
  ...
# or
#sed -i 's/nagiosadmin^/nagiosadmin,admin/g' /etc/nagios/cgi.cfg
sed -i 's/nagiosadmin/nagiosadmin,admin/g' /etc/nagios/cgi.cfg

NOTE: "You may use an asterisk (*) to authorize any user who has authenticated to the web server."

sed -i 's/nagiosadmin^/*/g' /etc/nagios/cgi.cfg

Restart apache:

service httpd restart

Verify nagios configuration files:

nagios -v /etc/nagios/nagios.cfg

Restart nagios:

service nagios restart

View nagios:

http://[HOST]/nagios/

The default configuration has a few monitoring points for the localhost.

Host and Services v2

/servers/

contacts.cfg:

##
## CONTACTS
## 
define contact {
	contact_name			kenneth
	alias				Kenneth Burgener
	email				kenneth.burgener@oeey.com
	service_notification_period	24x7
	host_notification_period	24x7
	service_notification_options	w,u,c,r
	host_notification_options	d,r
	service_notification_commands	notify-by-email
	host_notification_commands	host-notify-by-email
	;service_notification_commands	notify-service-by-email	; defined in commands.cfg
	;host_notification_commands	notify-host-by-email	; defined in commands.cfg
}

internet.cfg:

##
## INTERNET
##

define contactgroup {
	contactgroup_name	contactgroup-internet
	alias			Internet Contact Group
	members			kenneth
}

define host {
	name			host-internet
	host_name		internet
	alias			Internet Connection
	address			www.google.com

	notification_enabled	1			; host notifications are enabled
	event_handler_enabled	1			; event handler is enabled

	; If a service fails, check if host is alive...
	check_command		check-host-alive	; check host status command
	check_period		24x7			; when checks can be made
	max_check_attempts	5			; max check attempts verification

	; host failure notification settings...
	notification_interval	1440			; minutes between down email notifications
	notification_period	24x7			; when notifications can be sent
	notification_options	d,u,r			; notify of down, up and recover states

	; contacts		-		; (or use contact_groups)
	contact_groups		contactgroup-internet	; contacts to notify
	}

define service {
	name			service-internet	; template name
	service_description	service-internet	; service description
	host_name		internet

	;; check_command	-
	initial_state		u		; initially start in unknown state (not required)

	check_interval		5		; normal check interval
	check_period		24x7		; when to check service

	retry_interval		2		; state change retry interval
	max_check_attempts	5		; number of times to use retry_interval

	notification_interval	360		; notify every 6 hours
	notification_period	24x7		; when can notifications be sent
	notification_options	w,c,r		; notify on warning, critical and recovery states (not required)

	; contacts		-		; (or use contact_groups)
	contact_groups		contactgroup-internet

	service_description	Check PING
	check_command		check_ping!100.0,20%!500.0,60%
	}


test.cfg:


##
## TEMPLATES AND GROUPS
##

; Contact Group
define contactgroup {
	contactgroup_name	contactgroup-test
	alias			Test Contact Group
	members			admin
}

; Template Host
define host {
	name			host-test		; template name

	parents			internet		; don't check if parent is down

	notification_enabled	1			; host notifications are enabled
	event_handler_enabled	1			; event handler is enabled

	; If a service fails, check if host is alive...
	check_command		check-host-alive	; check host status command
	check_period		24x7			; when checks can be made
	max_check_attempts	5			; max check attempts verification

	; host failure notification settings...
	notification_interval	1440			; minutes between down email notifications
	notification_period	24x7			; when notifications can be sent
	notification_options	d,u,r			; notify of down, up and recover states

	; contacts		-		; (or use contact_groups)
	contact_groups		contactgroup-test	; contacts to notify

	register		0			; this is a template
	}

; Template service
define service {
	name			service-test	; template name
	service_description	service-test-template	; service description

	;; check_command	-
	initial_state		u		; initially start in unknown state (not required)

	check_interval		5		; normal check interval
	check_period		24x7		; when to check service

	retry_interval		2		; state change retry interval
	max_check_attempts	5		; number of times to use retry_interval

	notification_interval	360		; notify every 6 hours
	notification_period	24x7		; when can notifications be sent
	notification_options	w,c,r		; notify on warning, critical and recovery states (not required)

	; contacts		-		; (or use contact_groups)
	contact_groups		contactgroup-test

	register		0
	}


define hostgroup {
	hostgroup_name		hostgroup-test
	alias			test Project Servers
	members			cs01,cs02,cs03,cs04,cs05,cs06,cs07,cs08,cs09,cs10,cs11,cs12
	}

##
## HOSTS
##

define host {
	use			host-test
	host_name		cs01
	alias			test System #01
	address			216.119.200.1
	}

define host {
	use			host-test
	host_name		cs02
	alias			test System #02
	address			216.119.200.2
	}

##
## SERVICES
##

define service {
	use			service-test
	host_name		cs01
	service_description	Check PING
	check_command		check_ping!100.0,20%!500.0,60%
	}

define service {
	use			service-test
	host_name		cs02
	service_description	Check VNC
	check_command		check_tcp!5900!1
	}

Host and Services v3

##
## CONTACTS
##

define contact {
	contact_name			kenneth
	alias				Kenneth Burgener
	email				kburgener@oeey.com
	service_notification_period	24x7
	host_notification_period	24x7
	service_notification_options	w,u,c,r
	host_notification_options	d,r
	service_notification_commands	notify-service-by-email
	host_notification_commands	notify-host-by-email
	}


##
## SERVER HEADERS
##

; Contact Group
define contactgroup {
	contactgroup_name	contactgroup-lab
	alias			lab Contact Group
	members			admin
	}

; Template Host
define host {
	name			lab-host
	;; host_name		-
	;; alias		-
	; use			generic-host
	max_check_attempts	1
	; check_period
	; notification_interval	#
	; notification_period	timeperiod
	;
	; contacts		-		; (or use contact_groups)
	contact_groups		contactgroup-lab
	register		0
	}

; Template service
define service {
	name			lab-service
	service_description	lab-service-template

	;; check_command	-
	initial_state		u		; initially start in unknown state (not required)

	check_interval		5		; normal check interval
	check_period		24x7		; when to check service

	retry_interval		2		; state change retry interval
	max_check_attempts	5		; number of times to use retry_interval

	notification_interval	360		; notify every 6 hours
	notification_period	24x7		; when can notifications be sent
	notification_options	w,c,r		; notify on warning, critical and recovery states (not required)
	; contacts		-		; (or use contact_groups)
	contact_groups		contactgroup-lab
	register		0
	}


define hostgroup {
	hostgroup_name		lab-group
	alias			Lab Servers
	members			cs01,cs02
	}



##
## HOSTS
##

define host {
	use			lab-host
	host_name		cs01
	alias			lab System #01
	address			216.119.200.1
	}

define host {
	use			lab-host
	host_name		cs01
	alias			lab System #01
	address			cs01
	}



##
## SERVICES
##

define service {
	use			lab-service
	host_name		cs01,cs02
	service_description	Check PING
	check_command		check_ping!100.0,20%!500.0,60%
	}

define service {
	use			lab-service
	host_name		cs02
	service_description	Check VNC
	check_command		check_tcp!5900!1
	}

define service {
	use			lab-service
	host_name		cs02
	service_description	Check HTTP
	check_command		check_http
	}

Verify Configuration Files

To check and test and verify the configuration files: (lint testing)

nagios -v /etc/nagios/nagios.cfg

Other Related Projects

NagVis in Action

NagVis is a visualization addon for the well known network managment system Nagios.

Manual 4.x Installation

Install dependencies:

yum install httpd php gcc make glibc glibc-common gd gd-devel wget openssl-devel
# missing: glibc glibc-common
apt-get install apache2 php5 gcc make php5-gd libgd2-xpm libgd2-xpm-dev wget libssl-dev

Get Nagios and Plugins (Download Nagios)

mkdir -p ~/.src ; cd ~/.src
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.1.tar.gz
wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

Build and Install Nagios:

sudo /usr/sbin/adduser nagios

cd ~/.src
tar -zvxf nagios-4.0.1.tar.gz
cd nagios-4.0.1
./configure --prefix=/opt/nagios
make clean    # remove previous build artifcats
make all      # compile only

# sudo make install    # includes: install-base install-cgis install-html install-exfoliation install-basic
# sudo make install install-init install-commandmode install-config install-webconf  # finish off missing components
sudo make fullinstall    # includes: install install-init install-commandmode install-webconf
sudo make install-config    # includes: sample config, not required, but recommended

# option other frontend installs:
sudo make install-exfoliation install-classicui

For convenience:

sudo ln -s /opt/nagios/etc /etc/nagios

---

Install options after 'make all'

*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

  make install
     - This installs the main program, CGIs, and HTML files

  make install-init
     - This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs *SAMPLE* config files in /opt/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     - This installs the Apache config file for the Nagios
       web interface

  make install-exfoliation
     - This installs the Exfoliation theme for the Nagios
       web interface

  make install-classicui
     - This installs the classic theme for the Nagios
       web interface

---

Compile and Install the Nagios Plugins:

cd ~/.src
tar -zvxf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/opt/nagios
make
sudo make install

Plugins are installed to: /opt/nagios/libexec

---

Install and Configure the Web Interface:

# sudo make install-webconf    # part of 'make fullinstall'
# NOTE: adds: /etc/httpd/conf.d/nagios.conf
sed -i 's/nagiosadmin/admin/' /opt/nagios/etc/cgi.cfg  # rename nagiosadmin to admin
sed -i 's/nagiosadmin/admin/' /opt/nagios/etc/objects/contacts.cfg  # rename nagiosadmin to admin
#sudo htpasswd -c /opt/nagios/etc/htpasswd.users admin  # give admin a password
sudo htpasswd -bc /opt/nagios/etc/htpasswd.users admin password12

sudo /sbin/service httpd restart
sudo service apache2 restart

General sample config cleanup:

mkdir /opt/nagios/etc/servers
sed -i 's%#cfg_dir=/opt/nagios/etc/servers%cfg_dir=/opt/nagios/etc/servers%' /opt/nagios/etc/nagios.cfg

mkdir /opt/nagios/etc/bak
mv /opt/nagios/etc/objects/{printer.cfg,switch.cfg,windows.cfg,localhost.cfg}  /opt/nagios/etc/bak
sed -i 's%cfg_file=/opt/nagios/etc/objects/localhost.cfg%#cfg_file=/opt/nagios/etc/objects/localhost.cfg%' /opt/nagios/etc/nagios.cfg
# Note: if you don't add some hosts and services, you will get a "no service/hosts defined" error

EMAIL=kenneth@t0e.org   # CHANGEME
sed -i "s/nagios@localhost/$EMAIL/" /opt/nagios/etc/objects/contacts.cfg

servers/test.cfg:

cat > /opt/nagios/etc/servers/test.cfg <<"EOF"

; Contact Group
define contactgroup {
        contactgroup_name       contactgroup-test
        alias                   test Contact Group
        ;members                admin
        }

; Template Host
define host {
        name                    test-host
        max_check_attempts      1
        contact_groups          contactgroup-test
        register                0
        }

; Template service
define service {
        name                    test-service
        service_description     test-service-template

        ;; check_command        -
        initial_state           u               ; initially start in unknown state (not required)

        check_interval          5               ; normal check interval
        check_period            24x7            ; when to check service

        retry_interval          2               ; state change retry interval
        max_check_attempts      5               ; number of times to use retry_interval

        notification_interval   1440            ; notify once a day
        notification_period     24x7            ; when can notifications be sent
        notification_options    w,c,r           ; notify on warning, critical and recovery states (not required)
        ; contacts              -               ; (or use contact_groups)
        contact_groups          contactgroup-test
        register                0
        }


define hostgroup {
        hostgroup_name          test-group
        alias                   Lab Servers
        #members                jira
        }


##
## HOSTS
##

define host {
       use                     test-host
       host_name               test1
       alias                   test1
       address                 test1.webconnectmd.com
       }


##
## SERVICES
##

define service {
       use                     test-service
       host_name               test1
       service_description     Check PING
       check_command           check_ping!100.0,20%!500.0,60%
       }

#define service {
#       use                     test-service
#       host_name               test1
#       service_description     Check HTTP
#       check_command           check_http
#       }

define service {
       use                     test-service
       host_name               test1
       service_description     Check SSH
       check_command           check_ssh
       }

#define service {
#       use                     test-service
#       host_name               test1
#       service_description     Check DB
#       check_command           check_by_ssh!/opt/nagios/check_db
#       }

##
## COMMANDS
##

# 'check_pop' command definition
define command{
        command_name            check_by_ssh
        command_line            $USER1$/check_by_ssh -H $HOSTADDRESS$ $ARG1$
        }

EOF

Verify configuration:

/opt/nagios/bin/nagios -v /opt/nagios/etc/nagios.cfg

Start Nagios:

sudo /sbin/chkconfig --add nagios
sudo /sbin/chkconfig nagios on
sudo /sbin/service nagios start
# console:  /opt/nagios/bin/nagios  /opt/nagios/etc/nagios.cfg
# daemon:   /opt/nagios/bin/nagios -d /opt/nagios/etc/nagios.cfg

Login to the Web Interface:

# user: admin
# password: <set with the htpasswd command above>
http://localhost/nagios

Congratulations you now have a working Nagios installation that will monitor your local box.

References:

ubuntu init.d fix

# if you need a fresh copy
cp ~/.src/nagios-4.0.1/daemon-init /etc/init.d/nagios

startup - Nagios 4: Can’t open /etc/rc.d/init.d/functions - Stack Overflow [1]

apt-get install daemon
sudo sed -i 's/^\.\ \/etc\/rc.d\/init.d\/functions$/\.\ \/lib\/lsb\/init-functions/g' /etc/init.d/nagios
sudo sed -i 's/status\ /status_of_proc\ /g' /etc/init.d/nagios
sudo sed -i 's/daemon\ --user=\$user\ \$exec\ -ud\ \$config/daemon\ --user=\$user\ --\ \$exec\ -d\ \$config/g' /etc/init.d/nagios
sudo sed -i 's/\/var\/lock\/subsys\/\$prog/\/var\/lock\/\$prog/g' /etc/init.d/nagios
sudo service nagios start

My additional fixes:

sudo sed -i 's#/sbin/service#/usr/sbin/service#g' /etc/init.d/nagios
sudo sed -i 's/-n \$"/-n "/g' /etc/init.d/nagios
sudo sed -i 's#if test "$checkconfig" == "false"; then#if test "$checkconfig" = "false"; then#g' /etc/init.d/nagios
sudo sed -i 's#$nice runuser -s /bin/bash - $user -c#$nice su - $user -c#g' /etc/init.d/nagios
sudo sed -i 's#killproc -p ${pidfile} -d 10 $exec#killproc -p ${pidfile} $exec#g' /etc/init.d/nagios
sudo sed -i 's#: "#..."#g' /etc/init.d/nagios
sudo sed -i 's/# Short-Description/# Default-Start:\t2\n# Default-Stop:\n# Short-Description/g' /etc/init.d/nagios

Give permission to run commands:

chown /opt/nagios/var/rw nagios:www-data nagios.cmd
update-rc.d nagios defaults
service nagios restart

Manual 3.x Installation

Install dependencies:

yum install httpd php gcc make glibc glibc-common gd gd-devel wget openssl-devel
# httpd php
# gcc make
# glibc glibc-common
# gd gd-devel
# wget

Get Nagios and Plugins (Download Nagios)

mkdir -p ~/.src ; cd ~/.src
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.3.1.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz

Build and Install Nagios:

sudo /usr/sbin/adduser nagios

cd ~/.src
tar -zvxf nagios-3.3.1.tar.gz
cd nagios
./configure --prefix=/opt/nagios
make clean    # remove previous build artifcats
make all    # compile only

# sudo make install    # includes: install-base install-cgis install-html install-exfoliation install-basic
# sudo make install install-init install-commandmode install-config install-webconf  # finish off missing components
sudo make fullinstall    # includes: install install-init install-commandmode install-webconf
sudo make install-config    # includes: sample config, not required, but recommended

# option other installs:
sudo make install-exfoliation install-classicui

NOTE: See patch for 3.3.1 below...

Install options after 'make all'

*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

  make install
     - This installs the main program, CGIs, and HTML files

  make install-init
     - This installs the init script in /etc/rc.d/init.d

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-config
     - This installs *SAMPLE* config files in /opt/nagios/etc
       You'll have to modify these sample files before you can
       use Nagios.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     - This installs the Apache config file for the Nagios
       web interface

  make install-exfoliation
     - This installs the Exfoliation theme for the Nagios
       web interface

  make install-classicui
     - This installs the classic theme for the Nagios
       web interface

Compile and Install the Nagios Plugins:

cd ~/.src
tar -zvxf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/opt/nagios
make
sudo make install

Install and Configure the Web Interface:

# sudo make install-webconf    # part of 'make fullinstall'
# NOTE: adds: /etc/httpd/conf.d/nagios.conf
sed -i 's/nagiosadmin/admin/' /opt/nagios/etc/cgi.cfg  # rename nagiosadmin to admin
sed -i 's/nagiosadmin/admin/' /opt/nagios/etc/objects/contacts.cfg  # rename nagiosadmin to admin
sudo htpasswd -c /opt/nagios/etc/htpasswd.users admin  # give admin a password

sudo /sbin/service httpd restart

General sample config cleanup:

mkdir /opt/nagios/etc/servers
sed -i 's%#cfg_dir=/opt/nagios/etc/servers%cfg_dir=/opt/nagios/etc/servers%' /opt/nagios/etc/nagios.cfg

mkdir /opt/nagios/etc/bak
mv /opt/nagios/etc/objects/{printer.cfg,switch.cfg,windows.cfg,localhost.cfg}  /opt/nagios/etc/bak
sed -i 's%cfg_file=/opt/nagios/etc/objects/localhost.cfg%#cfg_file=/opt/nagios/etc/objects/localhost.cfg%' /opt/nagios/etc/nagios.cfg
# Note: if you don't add some hosts and services, you will get a "no service/hosts defined" error

EMAIL=kenneth@t0e.org   # CHANGEME
sed -i "s/nagios@localhost/$EMAIL/" /opt/nagios/etc/objects/contacts.cfg

Start Nagios:

sudo /sbin/chkconfig --add nagios
sudo /sbin/chkconfig nagios on
sudo /sbin/service nagios start

Login to the Web Interface:

# user: admin
# password: <set with the htpasswd command above>
http://localhost/nagios

Congratulations you now have a working Nagios installation that will monitor your local box.

References:

Patch 3.3.1

Patch for 3.3.1: (run before configure)

cat > nagios-3.3.1.patch
--- html/Makefile.in.orig       2011-09-06 15:01:37.488688413 -0400
+++ html/Makefile.in    2011-09-06 15:01:47.397049354 -0400
@@ -75,7 +75,7 @@
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/images/logos; done
	for file in includes/*.*; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/includes; done
-	for file in includes/rss/*; \
+	-for file in includes/rss/*; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/includes/rss; done
	for file in includes/rss/extlib/*; \
	do $(INSTALL) -m 664 $(INSTALL_OPTS) $$file $(DESTDIR)$(HTMLDIR)/includes/rss/extlib; done
patch -p0 < nagios-3.3.1.patch

Add another admin user

To add an admin user for the Web Interface:

sudo htpasswd /opt/nagios/etc/htpasswd.users newadmin

Add new user to the configuration file /opt/nagios/etc/cgi.cfg:

authorized_for_system_information=admin,newadmin
authorized_for_configuration_information=admin,newadmin
authorized_for_system_commands=admin,newadmin
authorized_for_all_services=admin,newadmin
authorized_for_all_hosts=admin,newadmin
authorized_for_all_service_commands=admin,newadmin
authorized_for_all_host_commands=admin,newadmin
# Or quick method (and works for each additional as well)
sed -i 's/=admin/=admin,newadmin/' /opt/nagios/etc/cgi.cfg

Remove web basic authentication

Read Only Access

/etc/httpd/conf.d/nagios.conf:

# MAKE CHANGE TO BOTH OF THESE SECTIONS...
<Directory "/opt/nagios/sbin">
<Directory "/opt/nagios/share">

#   AuthName "Nagios Access"
#   AuthType Basic
#   AuthUserFile /opt/nagios/etc/htpasswd.users
#   Require valid-user

/opt/nagios/etc/cgi.cfg:

use_authentication=0

NOTE: You will not be able to use the External Command Interface with authentication =0

External Command Interface
Sorry Dave, I can't let you do that...
It seems that you have chosen to not use the authentication functionality of the CGIs.
I don't want to be personally responsible for what may happen as a result of allowing unauthorized users to issue commands to Nagios,so you'll have to disable this safeguard if you are really stubborn and want to invite trouble.
Read the section on CGI authentication in the HTML documentation to learn how you can enable authentication and why you should want to.

References:

Allow External Command Interface

/etc/httpd/conf.d/nagios.conf:

# MAKE CHANGE TO BOTH OF THESE SECTIONS...
<Directory "/opt/nagios/sbin">
<Directory "/opt/nagios/share">

#   AuthName "Nagios Access"
#   AuthType Basic
#   AuthUserFile /opt/nagios/etc/htpasswd.users
#   Require valid-user

/opt/nagios/etc/cgi.cfg:

use_authentication=1
default_user_name=admin

Give the 'admin' user rights everywhere in cgi.cfg.

Give permission to nagios.cmd (parent folder, as .cmd file gets rewritten each restart):

 chmod g+s /opt/nagios/var/rw
 chown :nagios /opt/nagios/var/rw
 service nagios restart

Manual Installation #1 - archive

Nagios Quickstart Installation Guides

Install dependencies:

yum install httpd
yum install gcc
yum install glibc glibc-common
yum install gd gd-devel

Create nagios user and group:

sudo /usr/sbin/useradd nagios
sudo /usr/sbin/groupadd nagcmd
sudo /usr/sbin/usermod -G nagcmd nagios
sudo /usr/sbin/usermod -G nagcmd apache

Create build directory:

mkdir ~/nagios
cd ~/nagios

Get Nagios (Download Nagios)

wget http://superb-west.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.1.tar.gz

Get Plugins (Download Nagios)

wget http://superb-east.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz

Build Nagios:

tar -zvxf nagios-3.0.1.tar.gz
cd nagios-3.0.1
./configure --with-command-group=nagcmd
make all

Install Nagios:

sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode

Configure Nagios (/usr/local/nagios/etc):

# Set the nagiosadmin email address
sudo vi /usr/local/nagios/etc/objects/contacts.cfg

Install and Configure the Web Interface:

sudo make install-webconf
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo /sbin/service httpd restart

Compile and Install the Nagios Plugins:

cd ~/nagios
tar -zvxf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install

Start Nagios:

sudo /sbin/chkconfig --add nagios
sudo /sbin/chkconfig nagios on
sudo /sbin/service nagios start

Login to the Web Interface:

# user: nagiosadmin
# password: <set with the htpasswd command above>
http://localhost/nagios

Check the "Service Detail" tab for services being monitored on this server.

To add an admin user for the Web Interface:

sudo htpasswd /usr/local/nagios/etc/htpasswd.users admin

Add admin user to the configuration file /usr/local/nagios/etc/cgi.cfg:

authorized_for_system_information=nagiosadmin,admin
authorized_for_configuration_information=nagiosadmin,admin
authorized_for_system_commands=nagiosadmin,admin
authorized_for_all_services=nagiosadmin,admin
authorized_for_all_hosts=nagiosadmin,admin
authorized_for_all_service_commands=nagiosadmin,admin
authorized_for_all_host_commands=nagiosadmin,admin

Congratulations you now have a working Nagios installation that will monitor your local box.

Manual Installation #2 - archive

yum install gd gd-devel php-gd

Libiconv:

## http://www.gnu.org/s/libiconv/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar -zvxf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure
make
make install
export LD_LIBRARY_PATH=/usr/local/lib

GD:

## GD http://www.boutell.com/gd/
## COULD NOT GET WORKING RIGHT
yum install gcc automake libpng libjpeg zlib freetype libtool \
  freetype-devel fontconfig-devel libjpeg-devel libpng-devel xorg-x11-devel 
mkdir -p ~/src ; cd ~/src
hg clone https://bitbucket.org/pierrejoye/gd-libgd
## docs/INSTALL
cd gd-libgd/src
cp -r ../config ../test .
./bootstrap.sh
./configure --prefix=/opt/gd
make install

Install Nagios:

yum install gcc httpd php
mkdir -p ~/src ; cd ~/src
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
tar -zvxf nagios-3.2.3.tar.gz
cd nagios-3.2.3
./configure --prefix=/opt/nagios
make all
adduser nagios
make install install-init install-commandmode install-config install-webconf

Install Nagios Plugins:

mkdir -p ~/src ; cd ~/src
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
tar -zvxf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/opt/nagios
make
make install
  • The requested URL /nagios/cgi-bin/statusmap.cgi was not found on this server.
  • The requested URL /nagios/cgi-bin/trends.cgi was not found on this server.
  • The requested URL /nagios/cgi-bin/histogram.cgi was not found on this server.

Pronunciation

Nagios FAQ F0003 - How "Nagios" is pronounced - http://support.nagios.com/knowledgebase/faqs/index.php?id=52&faq_id=3:

"I pronounce Nagios as:
nah-ghee-ose
At least I think that's how I pronounce it (damn phonetic spelling)... The "Na" sounds like "Nah", "gi" sounds like the first part of "geese", and "os" sounds like the last part of "verbose". You can pronounce it however the heck you'd like.
Alternative pronounciations vary. One that I liked is "nachos". Mmmmmm.... nachos. "


Nagios FAQ F0002 - What does Nagios mean - http://support.nagios.com/knowledgebase/faqs/index.php?id=52&faq_id=2:

The official meaning is that N.A.G.I.O.S. is a recursive acronym which stands for "Nagios Ain't Gonna Insist On Sainthood". It's a spoof on the software's previous name of "NetSaint", which I decided to abandon after it caused me much emotional distress.
An alternative meaning suggested by Sam Tilders is...
Notices
Any
Glitch
In
Our
System
A few people have suggested that "Nagios" might be derived from the Greek word "hagios" which means "sacred" or "holy" (i.e. saintly). If you decide you want to go with that interpretation, you'll have to live with this delicious twist... "hagios" also means "accursed" or "execrable" according to the Liddell-Scott-Jones Greek Lexicon. So let me get this straight - you're saying that you you think Nagios is a bastardized upgrade of NetSaint? Eh? :-)


Nagios pronunciation « Nagios Community:

"People are always asking me what the proper pronunciation of Nagios is. Here goes... By egalstad (Ethan Galstad)" (flash audio)

Tricks for Object Definitions

Time-Saving Tricks For Object Definitions - http://nagios.sourceforge.net/docs/nagioscore/3/en/objecttricks.html

  • This documentation attempts to explain how you can exploit the (somewhat) hidden features of template-based object definitions to save your sanity. How so, you ask? Several types of objects allow you to specify multiple host names and/or hostgroup names in definitions, allowing you to "copy" the object defintion to multiple hosts or services. I'll cover each type of object that supports these features seperately.

UTOSC 2012 Nagios Install

site: http://tinyurl.com/naginstall

My modifications: https://docs.google.com/document/d/1xSZJrc_On3YcH9ulp8PSBMLAARXTKwNjS4VtbeL_dnw/edit

TO READ

Nagios Central Monitoring - http://beginlinux.com/blog/2010/03/nagios-central-monitoring/

Issues

Nagios is currently not checking for external commands

When trying to manually reschedule a check:

Sorry, but Nagios is currently not checking for external commands, so your command will not be committed!
Read the documentation for information on how to enable external commands

/etc/nagios3/nagios.cfg:

check_external_commands=1
#command_check_interval=15s
command_check_interval=-1
command_file=/var/lib/nagios3/rw/nagios.cmd

Add www-data to nagios group in /etc/group

nagios:x:120:www-data

restart apache2:

service apache2 restart
service nagios3 restart

Ref: http://technosophos.com/2010/01/13/nagios-fixing-error-could-not-stat-command-file-debian.html

---

Note:

Error: Could not stat() command file '/var/lib/nagios3/rw/nagios.cmd

This is because of the bug in Debian, which is described here http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=571801.

Solution:

/etc/init.d/nagios3 stop
dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
/etc/init.d/nagios3 start 

Ref: http://www.projectenvision.com/blog/4/Sorry-but-Nagios-is-currently-not-checking-for-external-commands

Invalid option - SSL is not available

When trying to run check_http with the '-S' for SSL option:

Invalid option - SSL is not available

Cause:

  • OpenSSL was not available when the Nagios plugins were compiled.

Solution:

  • Install openssl-devel package and recompile the Nagios plugins.

References:

/run/lxcfs/controllers is not accessible

Ubuntu

Error:

 	DISK CRITICAL - /run/lxcfs/controllers is not accessible: Permission denied 
/etc/nagios-plugins/config/disk.cfg
  check_all_disks
    command_line ... -A --exclude-type=tracefs --exclude-type=cgroup --exclude_device=/run/lxcfs/controllers

test:

 sudo -u nagios /usr/lib/nagios/plugins/check_disk -w '20%' -c '10%' -e
 sudo -u nagios /usr/lib/nagios/plugins/check_disk -w '20%' -c '10%' -e -A --exclude-type=tracefs --exclude-type=cgroup --exclude_device=/run/lxcfs/controllers

https://bugs.launchpad.net/ubuntu/+source/nagios-plugins/+bug/1516451

keywords