These are supplement notes I had taken down a while back doing an install of nagios and n2rrd on a Fedora-7 box and recently came very handy when doing the install in a redhat (RHEL-3) box as well:
Nagios Install:
# yum install nagios nagios-plugins nagios-plugins-http nagios-plugins-icmp nagios-plugins-ping
On RHEL3, I used (dags rpms) rpmforge. Here is my yum.conf for rpmforge:
[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el3/en /$basearch/dag
Notes: I settled for icmp instead of ping, as it is a lot faster. However, icmp required setting setuid for "/usr/lib/nagios/plugins/check
_icmp" for it to work. Also, had to rebuild nagios-plugins from source as root in order for the plugin to be installed.
-
Edit "etc/httpd/conf.d/nagios" and add the IPs and users to allow access.
Here is what it looks like:
Reload httpd. Edit "/etc/nagios/nagios.cfg":ScriptAlias /nagios/cgi-bin "/usr/lib/nagios/cgi"
;
<Directory "/usr/lib/nagios/cgi">
SSLRequireSSL
Options ExecCGI
AllowOverride None
Order deny,allow
Deny from all
Allow from xxx.xxx.xxx.xxx
AuthUserFile /var/www/.htpasswd
AuthGroupFile /var/www/.htgroup
AuthName "Protected"
AuthType Basic
<Limit GET>
require group administrator
</Limit>
satisfy all
</Directory>
Alias /nagios "/usr/share/nagios"<br /><Directory "/usr/share/nagios"& gt;
SSLRequireSSL
Options None
AllowOverride None
Order deny,allow
Deny from all
Allow from xxx.xxx.xxx.xxx
AuthUserFile /var/www/.htpasswd
AuthGroupFile /var/www/.htgroup
AuthName "Protected"
AuthType Basic
<Limit GET>
require group administrator
</Limit>
satisfy all
</Directory>
Below are the main setting to look for:
# cfg_file=/etc/nagios/localhost .cfg
cfg_file=/etc/nagios/contact groups.cfg
cfg_file=/etc/nagios/contact s.cfg
#cfg_file=/etc/nagios/depend encies.cfg
#cfg_file=/etc/nagios/escala tions.cfg
cfg_file=/etc/nagios/hostgro ups.cfg
cfg_file=/etc/nagios/hosts.c fg
cfg_file=/etc/nagios/service s.cfg
cfg_file=/etc/nagios/timeper iods.cfg
cfg_file=/etc/nagios/service extinfo.cfg
process_performance_data=1r />host_perfdata_command=proces s-host-perfdata-n2rrd
service_perfdata_command=pro cess-service-perfdata-n2rrd
/>enable_flap_detection=1
Here is what the config file looks like:
# egrep -v "#|^$" /etc/nagios/nagios.cfg
log_file=/var/log/nagios/nag ios.log
cfg_file=/etc/nagios/command s.cfg
cfg_file=/etc/nagios/contact groups.cfg
cfg_file=/etc/nagios/contact s.cfg
cfg_file=/etc/nagios/hostgro ups.cfg
cfg_file=/etc/nagios/hosts.c fg
cfg_file=/etc/nagios/service s.cfg
cfg_file=/etc/nagios/timeper iods.cfg
cfg_file=/etc/nagios/service extinfo.cfg
object_cache_file=/var/log/n agios/objects.cache
resource_file=/etc/nagios/re source.cfg
status_file=/var/log/nagios/ status.dat
nagios_user=nagios
nagios_group=nagios
check_external_commands=0
/>command_check_interval=-1
/>command_file=/var/log/nagios /rw/nagios.cmd
external_command_buffer_slot s=4096
comment_file=/var/log/nagios /comments.dat
downtime_file=/var/log/nagio s/downtime.dat
lock_file=/var/run/nagios.pi d
temp_file=/var/log/nagios/na gios.tmp
event_broker_options=-1
log_rotation_method=d
log_archive_path=/var/log/na gios/archives
use_syslog=1
log_notifications=1
log_service_retries=1
log_host_retries=1
log_event_handlers=1
log_initial_states=0
log_external_commands=1
log_passive_checks=1
service_inter_check_delay_me thod=s
max_service_check_spread=30< br />service_interleave_factor=s< br />host_inter_check_delay_metho d=s
max_host_check_spread=30
max_concurrent_checks=0
service_reaper_frequency=10< br />check_result_buffer_slots=40 96
auto_reschedule_checks=0
auto_rescheduling_interval=3 0
auto_rescheduling_window=180
sleep_time=0.25
service_check_timeout=60
host_check_timeout=30
event_handler_timeout=30
notification_timeout=30
ocsp_timeout=5
perfdata_timeout=5
retain_state_information=1r />state_retention_file=/var/lo g/nagios/retention.dat
retention_update_interval=60
use_retained_program_state=1
use_retained_scheduling_info =0
interval_length=60
use_aggressive_host_checking =0
execute_service_checks=1
accept_passive_service_check s=1
execute_host_checks=1
accept_passive_host_checks=1
enable_notifications=1
enable_event_handlers=1
process_performance_data=1r />host_perfdata_command=proces s-host-perfdata
service_perfdata_command=pro cess-service-perfdata
obsess_over_services=0
check_for_orphaned_services= 1
check_service_freshness=1
/>service_freshness_check_inte rval=60
check_host_freshness=0
host_freshness_check_interva l=60
aggregate_status_updates=1r />status_update_interval=15
/>enable_flap_detection=1
low_service_flap_threshold=5 .0
high_service_flap_threshold= 20.0
low_host_flap_threshold=5.0< br />high_host_flap_threshold=20. 0
date_format=us
p1_file=/usr/bin/p1.pl
illegal_object_name_chars=`~ !$%^&*|'"<> ;?,()=
illegal_macro_output_chars=` ~$&|'"<>r />use_regexp_matching=0
use_true_regexp_matching=0r />admin_email=nagios
admin_pager=pagenagios
daemon_dumps_core=0
Basically, hosts.cfg describes the hosts you want to monitor, services.cfg describes the services you want to monitor on each host, commands.cfg is the check commands used by services.cfg to check the services. If you want to check a service you probably have to add a command to do so. contacts.cfg is the people who will be contacted in case of a problem, contactgroups.cfg is the groups of people, hostgroups.cfg is the groups of hosts. nagios.cfg is the master config file.
To add a new machine you will need to edit hosts.cfg (add the machine), hostgroups.cfg (put it in a hostgroup), services.cfg (add the services to be checked on the machine).
To add a new administrator, you will need to edit contacts.cfg (add the new person) and contactgroups.cfg (put them in a contact group or create one).
Create the corresponding users with htpasswd command, also setup group.# htpasswd -c /var/www/.htpasswd <nagiosadmin>
# cat <<EOF > /var/www/.htgroup
> administrator: <nagiosadmin>
> EOF
# egrep -v "#|^$" /etc/nagios/cgi.cfg
main_config_file=/etc/nagios /nagios.cfg
physical_html_path=/usr/shar e/nagios
url_html_path=/nagios
show_context_help=0
use_authentication=1
authorized_for_system_inform ation=<nagiosadmin>
authorized_for_configuration _information=<nagiosadmin&g t;
authorized_for_system_comman ds=<nagiosadmin>
authorized_for_all_services= <nagiosadmin>
authorized_for_all_hosts=< ;nagiosadmin>
authorized_for_all_service_c ommands=<nagiosadmin>
/>authorized_for_all_host_comm ands=<nagiosadmin>
default_statusmap_layout=5r />default_statuswrl_layout=4r />ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$
refresh_rate=90
n2rrd install:
-
See install notes at: n2rrd.diglinks.com
Run below commands to install, create required directories and setup the right directory permissions:
# yum install rrdtool rrdtool-perl
# wget http://n2rrd.diglinks.com/down load/n2rrd-1.3.1.tar.gz
# tar -xvzf n2rrd-1.3.1.tar.gz
# cd n2rrd-1.3.1
# sh ./install.sh
# for fdist in `find /etc/n2rrd -name dist-*`; do fnew=`echo $fdist | sed 's/dist-//'`; mv $fdist $fnew; done
# mkdir /var/www/html/n2rrd
# chown apache /var/www/html/n2rrd
# mkdir /var/log/nagios/rra
# chown nagios:nagios /var/log/nagios/rra
# cp rrd2graph.cgi /var/www/cgi-bin/
# egrep -v "#|^$" /etc/n2rrd/n2rrd.conf
CONF_DIR = /etc/n2rrd
RRA_DIR = /var/log/nagios/rra
TEMPLATES_DIR = templates
SERVICE_NAME_MAPS = templates/maps/service_name_ma ps
LOGFILE &nb sp; = /var/log/nagios/rra/n2rrd.log< br />DOCUMENT_ROOT = /var/www/html
CACHE_DIR = n2rrd
TMPDIR=/tmp
RRDTOOL = /usr/bin/rrdtool
RRD_PATH_HIDDEN=1
NAGIOS_HOST_URL=0
CGIBIN = cgi-bin
NAGIOS_CGIBIN = nagios/cgi-bin
THUMB_DISPLAY = Daily
THUMB_DISPLAY_COLUMNS = 3
THUMB_HEIGHT = 100
THUMB_WIDTH = 200
ZOOM_JS = js/zoom.js
SAVE_NAGIOS_ENVIRONMENT_VARS = 1
Create templates if not already existing for the particular service. Edit "/etc/n2rrd/templates/maps/ser#### n2rrd ####
# Host Performance processing command
define command{
command_name process-host-perfdata-n2rrd
/> command_line /usr/local/bin/n2rrd.pl -d -c /etc/n2rrd/n2rrd.conf -e $SERVICEEXECUTIONTIME$ \
-l $SERVICELATENCY$ -T $LASTHOSTCHECK$ -H $HOSTNAME$ -s "check_ping" -o "$HOSTOUTPUT$"
}
# Service Performance processing command
define command{
command_name process-service-perfdata-n2rrd
command_line /usr/local/bin/n2rrd.pl -d -c /etc/n2rrd/n2rrd.conf -e $SERVICEEXECUTIONTIME$ \
-l $SERVICELATENCY$ -T $LASTSERVICECHECK$ -H $HOSTNAME$ -s "$SERVICEDESC$" -o "$SERVICEPERFDATA$"<br />}
HTTP: http
ICMP: icmp
# nagios -v /etc/nagios/nagios.cfg
# /etc/init.d/nagios start
Notes:
If building rpm package for nagios-plugins, build as root so it will build the root plugins - eg. check_icmp which is much faster that using check_ping
Install vrml plugin to view 3D model.# chmod u+s /var/lib/nagios/plugins/check_
icmp To install freewrl In ubuntu:
$ sudo apt-get install lesstif2
- sandip's blog
- Login or register to post comments
Comments
Very nice tutorial. You can also check some more details in the link given below.
http://howtosetup.in/component /content/article/2-subversion/ 9-how-to-setup-nagios-.html