让 Nagios 使用您的新插件非常容易。您应该对三个文件进行更改并重新启动 Nagios — 仅此而已。
第一个文件是 /etc/nagios/command-plugins.cfg(如果您知道此文件的路径或 ubuntu 中的类似文件的路径,请留下评论)。假设插件文件放在/usr/lib/nagios/plugins/目录下:
command[check_hello_world]=/usr/lib/nagios/plugins/check_helloworld.py -m 'some message'
下拉一个目录到/etc/nagios/objects/commands.cfg(对于ubuntu用户应该在那个目录/etc/nagios-plugins/config/中创建cfg文件强>):
define command {
command_name check_hello_world
command_line $USER1$/check_hello_world.py -m 'some message'
}
保存文件并打开 /etc/nagios/objects/localhost.cfg(在 /etc/nagios3/nagios.cfg 中的服务定义文件的 ubuntu 路径中,默认情况下 cfg_dir=/etc/nagios3/conf.d。因此,要在 ubuntu 中定义新服务,用户应在该目录中创建 cfg 文件,例如 hello.cfg)。找到此部分:
#
# SERVICE DEFINITIONS
#
并添加新条目:
define service {
use local-service ; Name of service template to use
host_name localhost
service_description Check using the hello world plugin (always returns OK)
check_command check_hello_world
}
剩下的就是重新启动 Nagios 并验证插件是否正常工作。通过发出以下命令重新启动 Nagios:
/etc/init.d/nagios restart
http://www.linux-mag.com/id/7706/
ubuntuforums.org - Thread: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS