Nagios Server

From Nonecks Docs

Jump to: navigation, search

HOWTO instal Nagios:

  1. sudo apt-get install apache2
  2. sudo apt-get install build-essential
  3. sudo apt-get install libgd2-xpm-dev
  4. /usr/sbin/useradd -m nagios
  5. passwd nagios
  6. /usr/sbin/groupadd nagios
  7. /usr/sbin/usermod -G nagios nagios
  8. /usr/sbin/groupadd nagcmd
  9. /usr/sbin/usermod -a -G nagcmd nagios
  10. /usr/sbin/usermod -a -G nagcmd www-data
  11. cd /tmp
  12. wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz
  13. wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
  14. cd /tmp
  15. tar xzf nagios-3.0.6.tar.gz
  16. cd nagios-3.0.6
  17. ./configure --with-command-group=nagcmd
  18. make all
  19. make install
  20. make install-init
  21. make install-config
  22. make install-commandmode
  1. Don’t start Nagios yet - there’s still more that needs to be done...

vi /usr/local/nagios/etc/objects/contacts.cfg

  1. change email with your valid administrator contact
define contact{
contact_name nagiosadmin ; Short name of$
use generic-contact ; Inherit defau$
alias Nagios Admin ; Full name of $

email ma2d_te@yahoo.com ; <<***** CHANG$
}
  1. make install-webconf
  2. htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  3. /etc/init.d/apache2 reload
  4. cd ~/downloads
  5. tar xzf nagios-plugins-1.4.11.tar.gz
  6. cd nagios-plugins-1.4.11
  7. ./configure --with-nagios-user=nagios --with-nagios-group=nagios
  8. make
  9. make install
  10. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  11. /etc/init.d/nagios start
  12. apt-get install mailx

vi /etc/apache2/conf.d/nagios.conf

# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
# Last Modified: 11-26-2005
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file. Customize the paths, etc. as
# needed to fit your system.

ScriptAlias /xl/cgi-bin "/usr/local/nagios/sbin"

# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user

Alias /xl "/usr/local/nagios/share"

# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
#  Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user

vi /usr/local/nagios/etc/objects/templates.cfg

# Define a template for NodeB that we can reuse
define host{
name generic-nodeb ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, switches are monitored round the clock
check_interval 5 ; Switches are checked every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each switch 10 times (max)
check_command check-host-alive ; Default command to check if routers are "alive"
notification_period 24x7 ; Send notifications at any time
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}

vi /usr/local/nagios/etc/nagios.cfg

# Definitions for monitoring a router/switch
cfg_file=/usr/local/nagios/etc/objects/switch.cfg

vi /usr/local/nagios/etc/objects/switch.cfg

###############################################################################
# SWITCH.CFG - SAMPLE CONFIG FILE FOR MONITORING A SWITCH
#
# Last Modified: 10-03-2007
#
# NOTES: This config file assumes that you are using the sample configuration
#	 files that get installed with the Nagios quickstart guide.
#
###############################################################################
###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################
# Define the switch that we'll be monitoring
define host{
use		generic-switch		; Inherit default values from a template
host_name	Linksys1		; The name we're giving to this switch
alias		Top Left - 10.0.1.21	; A longer name associated with the switch
address		10.0.1.21		; IP address of the switch
hostgroups	switches		; Host groups this switch is associated with
}
###
define host{
use		generic-switch		; Inherit default values from a template
host_name	Linksys2		; The name we're giving to this switch
alias		Top Left - 10.0.1.22	; A longer name associated with the switch
address		10.0.1.22		; IP address of the switch
hostgroups	switches		; Host groups this switch is associated with
}
###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################
# Create a new hostgroup for switches
define hostgroup{
hostgroup_name	switches		; The name of the hostgroup
alias		Network Switches	; Long name of the group
}
###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################
# Create a service to PING to switch
define service{
use			generic-service	; Inherit values from a template
host_name		Linksys1	; The name of the host the service is associated with
service_description	PING		; The service description
check_command		check_ping!200.0,20%!600.0,60%	; The command used to monitor the service
normal_check_interval	5		; Check the service every 5 minutes under normal conditions
retry_check_interval	1		; Re-check the service every minute until its final/hard state is determined
}
###
define service{
use			generic-service	; Inherit values from a template
host_name		Linksys2	; The name of the host the service is associated with
service_description	PING		; The service description
check_command		check_ping!200.0,20%!600.0,60%	; The command used to monitor the service
normal_check_interval	5		; Check the service every 5 minutes under normal conditions
retry_check_interval	1		; Re-check the service every minute until its final/hard state is determined
}
# Monitor uptime via SNMP
define service{
use			generic-service	; Inherit values from a template
host_name		Linksys1	
service_description	Uptime	
check_command		check_snmp!-C AuctivaMRTG -o sysUpTime.0
}
###
define service{
use			generic-service	; Inherit values from a template
host_name		Linksys2	
service_description	Uptime	
check_command		check_snmp!-C AuctivaMRTG -o sysUpTime.0
}
# Monitor Port 1 status via SNMP
define service{
use			generic-service	; Inherit values from a template
host_name		Linksys1
service_description	Port 1 Link Status
check_command		check_snmp!-C AuctivaMRTG -o ifOperStatus.1 -r 1 -m RFC1213-MIB
}
###
define service{
use			generic-service	; Inherit values from a template
host_name		Linksys1
service_description	Port 2 Link Status
check_command		check_snmp!-C AuctivaMRTG -o ifOperStatus.2 -r 1 -m RFC1213-MIB
}
###
define service{
use			generic-service	; Inherit values from a template
host_name		Linksys2
service_description	Port 1 Link Status
check_command		check_snmp!-C AuctivaMRTG -o ifOperStatus.1 -r 1 -m RFC1213-MIB
}
# Monitor bandwidth via MRTG logs
define service{
use			generic-service	; Inherit values from a template
host_name		Linksys1
service_description	Port 1 Bandwidth Usage
check_command		check_local_mrtgtraf!/var/lib/mrtg/10.0.1.21.log!AVG!1000000,1000000!5000000,5000000!10
}
####
define service{
use			generic-service	; Inherit values from a template
host_name		Linksys2
service_description	Port 1 Bandwidth Usage
check_command		check_local_mrtgtraf!/var/lib/mrtg/10.0.1.22.log!AVG!1000000,1000000!5000000,5000000!10
}
  1. Now Edit Windows conf files

vi /usr/local/nagios/etc/objects/windows.cfg