友链
导航
These are the good times in your life,
so put on a smile and it'll be alright
友链
导航
与其他监控系统的比较:
URL: http://demo.zabbix.jp アカウント: guest-ja パスワード: zabbix
first_notification_delay
: Yes, it will be suppressed. $ nagios -v nagios.cfg
server.modules += ( "mod_alias", mod_auth", "mod_cgi", "mod_setenv" ) alias.url += ( "/cgi-bin/nagios3" => "/usr/lib/cgi-bin/nagios3", "/nagios3/stylesheets" => "/etc/nagios3/stylesheets", "/nagios3" => "/usr/share/nagios3/htdocs" ) $HTTP["url"] =~ "^/cgi-bin" { cgi.assign = ( "" => "" ) # nagios 将 cgi 已做成 binary, 所以 assign 给自己 } $HTTP["url"] =~ "nagios3" { auth.backend = "htpasswd" auth.backend.htpasswd.userfile = "/etc/nagios3/htpasswd.users" auth.require = ( "" => ( "method" => "basic", "realm" => "nagios3", "require" => "user=nagiosadmin" ) ) }
主配置文件
log_file=/var/log/nagios3/nagios.log
, 日志记录位置, 必须在第一项配置resource_file=/etc/nagios3/resource.cfg
, $USERx$ macros 文件位置, x=1~32, $USER1$ 默认为 path to the pluginscfg_file
和 cfg_dir
, 其他配置文件地址, 推荐的配置步骤如下:cfg_file
和 cfg_dir
;# mkdir {timeperiods,contacts,commands,hosts,services,ext} # ln -s /etc/nagios-plugins/config/ commands/nagios-plugins # mv commands.cfg commands/default.cfg cfg_dir=/etc/nagios3/commands # mv conf.d/timeperiods_nagios2.cfg timeperiods/default.cfg cfg_dir=/etc/nagios3/timeperiods # mv conf.d/contacts_nagios2.cfg contacts/default.cfg cfg_dir=/etc/nagios3/contacts # mv conf.d/*host* hosts/ cfg_dir=/etc/nagios3/hosts # mv conf.d/*service* services/ cfg_dir=/etc/nagios3/services # mv conf.d/extinfo_nagios2.cfg ext/ cfg_dir=/etc/nagios3/ext
define service { use generic-service host_name foo.bar.com service_description HTTP WITH PORT check_command check_http!-p 8080 }
$ /usr/lib/nagios/plugins/check_http -I 111.222.111.222 -p 8080 HTTP OK: HTTP/1.0 302 Found - 203 bytes in 0.031 second response time |time=0.030661s;;;0.000000 size=203B;;;0
define command{ command_name check_http_accept_external_opts command_line /usr/lib/nagios/plugins/check_http -H '$HOSTADDRESS$' -I '$HOSTADDRESS$' $ARG1$ ; $ARG1$ 允许添加任意参数 } # 或写新的特殊 command define command{ command_name check_http_with_port command_line /usr/lib/nagios/plugins/check_http -H '$HOSTADDRESS$' -I '$HOSTADDRESS$' -p $ARG1$ ; $ARG1$ 作为 -p|--port 的参数 }
check_external_commands=1 interval_length=60 accept_passive_service_checks=1 accept_passive_host_checks=1
配置 hosts 和 services 要利用好 hostgroup:
define hostgroup { hostgroup_name all alias All Servers members * } define hostgroup { hostgroup_name http-servers alias HTTP servers members localhost } define service { hostgroup_name http-servers service_description HTTP check_command check_http use generic-service notification_interval 0 ; set > 0 if you want to be renotified }
Notifications may be sent out in one of the following situations:
当在 nagios.cfg 设置 enable_flap_detection=1
后, nagios 就会检测 flapping.
Nagios 会记录最近 21 次的检查结果, 计算(21 次检查状态实际变化数 / 20, 即 21 次检查中最多可出现 20 次状态变化 ) * 100% = flapping 的比率
nagios.cfg 中可设置 flapping 界限:
low_service_flap_threshold=5.0 high_service_flap_threshold=20.0 low_host_flap_threshold=5.0 high_host_flap_threshold=20.0
flapping 比率超过界限便会认为是 flapping.
Our Nagios setup is now complete and is ready to be started! We took the road from source code into a working application. We have also configured it so that it monitors the machine it is running on from scratch, and it took very little time and effort to do so.
Our Nagios installation now uses three directories—/opt/nagios for binaries, /etc/ nagios for configuration, and /var/nagios for storing data. All object definitions are stored in a categorized way as the subdirectories /etc/nagios. This allows much easier management of Nagios objects.
We have configured the server that Nagios is running on, to be monitored. You might want to add more servers just to see how they works.
We told Nagios to monitor only the SSH server. But in all proability, you will also want to monitor other things such as a web server or email.
Chapter 4, Overview of Nagios Plugins, will help when it comes to setting up various types of checks. Make sure to read the /etc/nagios/commands/default.cfg file to see what commands Nagios already came configured with. Sometimes, it will also be needed to set up your own check commands—either custom scripts, or using Nagios plugins in a different way from the default command set.
You would also want to set up other users if you are working as part of a larger team. It will definitely help everyone in your team if you tell Nagios who is taking care of which parts of the infrastructure!
All that should be a good start for making sure everything works fine in your company. Of course, configuring Nagios for your needs might take a lot of time, but starting with monitoring just the essentials is a good thing. You will learn how it works and increase the number of monitorables over time.
The next step is to set up the web interface so that you will be able to see things from your favorite browser or even put on your desktop. The next chapter provides the essential information on how to install, configure, and use it.