免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3463 | 回复: 0
打印 上一主题 下一主题

Nagios Plugin for Cacti [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-01 09:38 |只看该作者 |倒序浏览

NPC Quick Start Guide
¶

Table of Contents
Purpose

Requirements

PHP

Installing NPC

Configuring Nagios

Installing/Configuring NDO2DB


Purpose
¶
The purpose of this guide is to outline the minimum steps necessary to get NPC installed and running.
Requirements
¶
Below are the minimum requirements:

NPC has been tested with the above application versions. PHP 5.2 is required do to the use of PDO and JSON. PHP 5.1 with PDO and JSON modules installed "may" work but will not be supported.
PHP
¶
The default memory limit for PHP probably will not be enough to run NPC. Edit /etc/php.ini and update the memory_limit option. Set it to at least 32M.
memory_limit = 32M
Note on RHES/CentOS PHP 5.1.x: I have successfully tested NPC on PHP 5.1.6. This required that the json module be installed (JSON is included in PHP 5.2). I could not find a pre-built php-json module for RHES/CentOS with PHP 5.1.x. I found a source rpm
here
. I rebuilt the rpm for php 5.1.6 with the following command. Prior to rebuilding I had to install a few extra components with yum. In my case I had to do a:
'yum install php-devel autoconf automake libtool'.
Then rebuild the source RPM with the following command:
rpmbuild --rebuild php-json-4.3.2_1.2.1-1.aurore.src.rpm
Installing NPC
¶
You must have Cacti installed with the
plugin architecture
version 2.0 or higher before installing NPC.
Grab the latest version of NPC from the downloads section and do the following steps:

  • Untar/zip npc into /plugins/
  • login to cacti as an admin.
  • Install the plugin in Cacti

    • Go to Console -> Plugin Management -> Uninstalled
    • Click the Install link under the npc section
    • Next, click the Installed tab
    • To enable NPC click the Enable link under the npc section

  • You can find the NPC plugin options under the Cacti Settings section

Note: If you do not see the Plugin Management link then go to user management and enable it.
Note: Users that had a version of npc less than 2.0.0a-151 can remove the following line from /include/global.php
$plugins[] = 'npc';
Click the NPC tab. The 1st load of NPC may be slow as all the javascript for the interface is loaded and cached.
Without NDO2DB feeding Nagios data into NPC the dashboard (and other screens) will be empty and should look like
this
.
Next, there are a few NPC settings to add/update. click the Console tab -> Settings (under Configuration heading) -> NPC tab.

  • Remote Commands

    • Check the checkbox to enable remote commands. At the moment this is system wide so all users that can access NPC will be able to execute commands.


  • Nagios Command File Path

    • Add the path to the nagios command file. It will be something like /usr/local/nagios/var/rw/nagios.cmd


  • Nagios URL

    • The URL to the Nagios web interface is used to get access to the status map and reporting CGI's. You can also access the Nagios UI by clicking the "Nagios" link in the left hand "Navigation" pane in NPC.


  • Set the date and time format to your liking.

Configuring Nagios
¶
Refer to the Nagios documentation for installation. Some parts of NPC like reporting and the status map use the Nagios interface by wrapping the Nagios CGI's in an Iframe. Be sure to have the Nagios web UI working if you want to use the reporting and status map features.
The following parameters are found in the Nagios configuration file nagios.cfg
The power of NPC is greatly enhanced by the ability to issue commands to the Nagios process. To enable external commands in Nagios set:
check_external_commands=1
Check external commands as often as possible.
command_check_interval=-1
Broker all events.
event_broker_options=-1
The path to the event broker module and config file which you will install next. This example assumes Nagios is installed in /usr/local/nagios. Adjust the path to suit your installation.
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
If you want to use performance data from Nagios plugins to create graphs in cacti then set the following parameter.
process_performance_data=1
Setting host_perfdata_command and service_perfdata_command is not necessary. The performance data will be written to the NPC database where it can be polled by cacti using the perfdata.php script included with NPC.
Installing/Configuring NDO2DB
¶
NOD2DB is part of the NDOUTILS package. Nagios hands events off to NDO2DB via the event broker. NDO2DB handles the actual inserts of Nagios data into the NPC tables.
Instructions for compiling, installing, and configuring NDO2DB are included in the README file of the ndoutils package. The README has four sections. Skip the section on initializing the database.

  • Follow the 'COMPILING INSTRUCTIONS' section of the README.
  • Skip the 'INITIALIZING THE SQL DATABASE' section of the README
  • Follow the 'INSTALLING THE NDOMOD BROKER MODULE' section of the README
  • Follow the 'INSTALLING THE NDO2DB DAEMON' section of the README

Edit /usr/local/nagios/etc/ndo2db.cfg and add/update the following parameters:
db_servertype=mysql
db_host=localhost (the host/ip where cacti database is running)
db_port=3306
db_name=cacti (Your cacti database name)
db_prefix=npc_
db_user= (Your cacti database user)
db_pass= (Your cacti user password)
The user/pass you assign needs select, insert, update, delete on all the npc_ tables.
ndo2db can communicates with the Nagios ndo2db.o module via unix socket or TCP. Use whatever works for you (I use the TCP mode) but you need to set it the same in both the ndo2db.cfg and ndomod.cfg.
NOTE: The config_output_options parameter in ndomod.cfg must be set to 2 (config_output_options=2).
Here are working ndo2db.cfg and ndomod.cfg configs. As noted above the database parameters need to be changed for your database.
ndo2db.cfg
ndo2db_user=nagios
ndo2db_group=nagios
socket_type=tcp
socket_name=/usr/local/nagios/var/ndo.sock
tcp_port=5668
db_servertype=mysql
db_host=localhost
db_port=3306
db_name=DATABSE_NAME
db_user=DATABASE_USER
db_pass=DATABASE_PASSWORD
db_prefix=npc_
max_timedevents_age=1440
max_systemcommands_age=10080
max_servicechecks_age=10080
max_hostchecks_age=10080
max_eventhandlers_age=44640
debug_level=1
debug_verbosity=1
debug_file=/usr/local/nagios/var/ndo2db.debug
max_debug_file_size=1000000
ndomod.cfg
instance_name=default
output_type=tcpsocket
output=127.0.0.1
tcp_port=5668
output_buffer_items=5000
buffer_file=/usr/local/nagios/var/ndomod.tmp
file_rotation_interval=14400
file_rotation_timeout=60
reconnect_interval=15
reconnect_warning_interval=15
data_processing_options=-1
config_output_options=2
NOTE: I had some problems with the ndo2db process dying (regularly) on Fedora Core 7. To get around that I setup the process to respawn via init. If you have trouble with the daemon dying you can add the following line to /etc/inittab. Only do this if ndo2db frequently dies unexpectedly on you.
ndo:345:respawn:/usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
After editing inittab issue the following command:
telinit Q
You may see messages like the following in your syslog when using init to respawn ndo2db:
Apr 19 11:11:55 acid init: Id "ndo" respawning too fast: disabled for 5 minutes
Besides muddying up my logs there is no harm and so far this is the only way I have been able to keep ndo2db running.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/15315/showart_2107883.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP