Nagios+Nconf 部署

Nagios croe 源码安装

安装基本环境,软件包:

For RHEL/CentOS users:

yum install -y wget httpd php gcc glibc glibc-common gdgd-devel make net-snmp openssl-devel (避免 check_http.c:312:error:’ssl_version’undeclard 错误)

For Ubuntu users:

sudo apt-get install build-essential apache2 php5-gdlibgd2-xpm libgd2-xpm-dev

libapache2-mod-php5 libcurl4-openssl-dev(避免 check_http.c:312:error:’ssl_version’undeclard 错误)

官网下载稳定版TAR包

Adding the NagiosUser and Group

Next add theappropriate user and group for the Nagios process to run:

useradd nagios

groupadd nagcmd

usermod -a -Gnagcmd nagios

For RHEL/CentOSusers:

./configure–with-command-group=nagcmd

For Ubuntu users:

./configure–with-nagios-group=nagios –with-command-group=nagcmd

All systems:

make all

make install

make install-init

makeinstall-config

makeinstall-commandmode

makeinstall-webconf

cp -Rcontrib/eventhandlers/ /usr/local/nagios/libexec/

chown -Rnagios:nagios /usr/local/nagios/libexec/eventhandlers

/usr/local/nagios/bin/nagios-v /usr/local/nagios/etc/nagios.cfg

/etc/init.d/nagiosstart

For RHEL/CentOSusers:

/etc/init.d/httpdstart

Create a DefaultUser for Web Access.

Add a default userfor Web Interface Access:

htpasswd –c/usr/local/nagios/etc/htpasswd.users nagiosadmin

Nagios PluginInstallation

cd/tmp/nagios-plugins-1.4.15

./configure–with-nagios-user=nagios –with-nagios-group=nagios

make

make install

安装 nconf web管理配置nagios

安装mysql 数据库

Apt-get installmysql-server-5.5 php5-mysq;

创建数据库

Create databasenconf

创建用户并授权设置密码

GRANTSELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON nconf.* to ‘nconf’@’localhost’identified by ‘nconfadmin’;

导入nconf 自带数据库表

Mysql –u root –pnconf < INSTALL/create_datebase.sql

把解压的nconf 放在 /var/www/ 目录下 (apache默认网站文件目录,可设置其他)

http://192.168.1.20/nconf

开始设置 nconf参数

完毕。

PS:这里可以写个shell简单脚本,来完成nconf配置文件替换的工作,内容如下:

#!/bin/bash

export PATH

cp -p/var/www/nconf/output/NagiosConfig.tgz /usr/local/nagios/etc/

rm -r/usr/local/nagios/etc/Default_collector /usr/local/nagios/etc/global

cd/usr/local/nagios/etc/

tar -xvf/usr/local/nagios/etc/NagiosConfig.tgz

/etc/init.d/nagiosrestart

根据自己的实际目录更改此配置。

发表评论