The previous section describes the installation process for the Nagios monitoring service in a Linux environment, and this section details how to use some of the configuration files for the Nagios services that have already been installed and how to monitor local related services. If you want to complete monitoring of a host Nagios as the main program is essential, but only as long as Nagios is not complete, the following brief introduction of Nagios's main configuration file and the monitoring of the local host
Nagios monitoring look at that role configuration:
Monitor and monitor the receipt collection (c/S architecture), monitoring and user (b/s architecture) between the data presentation
Nagios main program, plug-in package, Nrpe and other related plugins
One, the configuration file check
1.1 Viewing Nagios home directory related features
[[Email protected]]# ll/usr/local/nagios/bin #Nagios执行程序所在目录etc #nagios配置文件坐在目录, initial installation only a few *.cfg files I l Ibexec #监控所用命令, need to install the Nagios-plugins plug-in will have, detection command, not installed is empty sbin #Nagios的Cgi文件所在目录, external command required file storage directory share #Nagios前端页面var #日志文件, PID files, etc.
1.2 Checking the configuration file for errors
[Email protected] ~]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg ..... ..... ....... ......................... Checking Obsessive Compulsive Processor commands ... Checking Misc Settings ... Total Warnings:0total errors:0
Configuration file no exception, warning 0, error 0
1.3 Specifies that the configuration file is started as a daemon
[Email protected] ~]#/usr/local/nagios/bin/nagios-d/usr/local/nagios/etc/nagios.cfg
1.4 nagios.conf Main Configuration content
[[Email protected] ~]# cat /usr/local/nagios/etc/nagios.cfg | grep -e -v "^#|^$" log_file=/usr/local/nagios/var/nagios.log #日志位置cfg_file =/usr/local/nagios/etc/objects/commands.cfg #命令文件位置cfg_file =/usr/local/nagios/etc/objects/contacts.cfg #定义联系人cfg_file =/usr/local/nagios/etc/objects/timeperiods.cfg #定义时间段cfg_file =/usr/local/nagios/etc/objects/templates.cfg #定义模板 (Contact host template) cfg_file=/usr/local/ nagios/etc/objects/linehost.cfg #监控远程主机相关配置 (monitor the configuration file added by the remote host) cfg_file=/usr/ local/nagios/etc/objects/localhost.cfg #监控本机相关配置object_cache_file =/usr/local/ nagios/var/objects.cache #precached_object_file =/usr/local/nagios/var/ Objects.precacheresource_file=/usr/local/nagios/etc/resource.cfg #资源变量配置文件, including $user1$ Variable (one path) status_file=/usr/local/nagios/var/status.dat status_update_interval=10 #状态更新时间, Unit snagios_user=nagios # Specifies that the daemon runs the user nagios_group=nagios #指定进程运行用户组check_external_commands =1 #命令检查command_check_interval =-1command_file=/usr/local/nagios/var/rw/nagios.cmdexternal_command_ Buffer_slots=4096lock_file=/usr/local/nagios/var/nagios.locktemp_file=/usr/local/nagios/var/nagios.tmptemp_ path=/tmpevent_broker_options=-1log_rotation_method=d #日志滚动, Default day log_archive_path=/usr/local/nagios/var/archives sleep_time=0.25service_check_timeout=60 #服务器检查超时时间host _check_timeout=30event_handler_timeout=30 notification_timeout=30ocsp_timeout=5perfdata_timeout=5
[[email protected] ~]# ls /usr/local/nagios/etc/cgi.cfg #cgi配置文件, priority higher than nagios.cfg[[email protected] ~]# cat /usr/local/nagios/etc/cgi.cfg | grep -E -v ' ^ #|^$ ' main_config_file=/usr/local/nagios/etc/nagios.cfg #指定Nagios的配置文件位置 physical_html_path=/usr/local/nagios/share #指定web访问的物理路径url_html_path =/nagios # Add Nagios after URL to access SHOW_CONTEXT_HELP=0 &Nbsp; #use_pending_states =1use_authentication=1 #使用认证功能use_ssl_authentication =0 authorized_for_system_information= nagiosadmin,admin #认证用户 .......
Ii. the health status of Nagios monitoring services
2.1 Monitoring local NFS service status
[[email protected] ~]# cd /usr/local/nagios/etc/objects/[[email protected] Objects]# cp localhost.cfg localhost.cfg.bak Add the following at the end of the file define service{ use local-service ; name of service template to use host_name localhost service_description nfs check _command check_tcp!2049 notifications_enabled 0 } Configure NAGIOS.CFG Master profile [[email Protected] objects]# vim /usr/local/nagios/etc/nagios.cfg cfg_file=/usr/local/nagios /etc/objects/localhost.cfg
Installing and starting Server for NFS
[Email protected] objects]# mkdir/nfs[[email protected] objects]# Vim/etc/exports/nfs * (rw) [[Email protected] objects] #/etc/init.d/nfs Restart verify Nfs[[email protected] objects]# showmount-e 192.168.31.101Export list for 192.168.31.101:/ NFS *
Check if localhost is enabled properly, check the Nagios configuration file, or restart the Nagios service if error-free
[Email protected] objects]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg [email protected] objects]# Service Nagios Restart
Verify
[[Email protected] objects]# Service NFS Stop[[email protected] objects]# service NFS Restart
2.2 Nagios remote monitoring of MySQL database status
Installing the MySQL server
[[email protected] ~]# yum-y install MySQL mysql-server mysql-devel
[Email protected] ~]# service mysqld restart
[Email protected] ~]# chkconfig mysqld on
To create a test database
Mysql> CREATE DATABASE nagiostest;mysql> grant Select on nagiostest.* to [email protected] "localhost";mysql> flu SH privileges;
Test
[Email protected] objects]#/usr/local/nagios/libexec/check_mysql-h 127.0.0.1-u nagiostest-d nagiostestuptime:438 Th Reads:2 questions:11 Slow queries:0 opens:15 Flush tables:1 Open tables:8 queries per second avg:0.25| connections=4c;;; open_files=16;;; open_tables=8;;; qcache_free_memory=0;;; qcache_hits=0c;;; qcache_inserts=0c;;; qcache_lowmem_prunes=0c;;; qcache_not_cached=0c;;; qcache_queries_in_cache=0;;; queries=11c;;; questions=11c;;; table_locks_waited=0c;;; threads_connected=2;;; threads_running=1;;; uptime=438c;;; [Email protected] objects]#
Command added (the added command_name must exist under the/usr/local/nagios/libexec/folder)
[Email protected] objects]# vim commands.cfg define command{command_name check_mysql command_line $USER 1$/check_mysql-h $HOSTADDRESS $ u nagiostest-d nagiostest}[[email protected] objects]#/usr/local/nagios/bin/nag Ios-v/usr/local/nagios/etc/nagios.cfg
Restart Nagios service without error and warning
Testing: Shutting down the MSYQLD service
[[Email protected] libexec]# service mysqld stop
2.3 Monitoring remote host MySQL services and other services
[[email protected] objects]# vim .. /nagios.cfg New Configuration Monitoring configuration file and service cfg_file=/usr/local/nagios/etc/objects/remodehost.cfgcfg_file=/usr/local/nagios/ etc/objects/services.cfgdefine host{ use linux-server host_name node2.cn alias MySQL-Serve address 192.168.31.102 icon_image server.gif statusmap_image server.gd2 2d_coords 500,200&nbsP;       3D_COORDS       500,200,100}
Add monitored services, which can be configured by referencing the LOCALHOST.CFG configuration file-related service configuration
[[email protected] objects]# vim services.cfg define service{ use local-service host_name node2.cn service_groups MysqlGroup service_description MySqlSev check_command check_mysql}define service{ use local-service ; Name of service template to use host_name node2.cn service_description ping check_command check_ping!100.0,20%!500.0,60% }define service{ use local-service ; Name of service template to use host_name node2.cn service_ Description root partition check_command check_local_disk!20%!10%!/ } ............define servicegroup{ servicegroup_name Mysqlgroup alias MySQLServer members node2.cn, Mysqlsev}
Check for configuration files without errors and warnings restart the service
[Email protected] objects]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg [email protected] objects]# Service Nagios Restart
Viewing the web-side monitoring host through a browser
This article is from "Little Chong" blog, please make sure to keep this source http://maoxiaoxiong.blog.51cto.com/11705634/1980786
Monitoring--nagios How to monitor the local host and local service