免费注册 查看新帖 |

Chinaunix

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

Nagios3.x全攻略(更新中) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-03 14:30 |只看该作者 |倒序浏览
Nagios3.x全攻略——(一)Nagios安装
平台CentOS

首先检查机器环境,安装Nagios需要以下环境

Apache
GCC compiler
GD development libraries


如果没有可以运行

yum install httpd
yum install gcc
yum install glibc glibc-common
yum install gd gd-devel

(本人未测试)

1)添加用户(非常重要,否则你可能会遇到权限问题)

/usr/sbin/useradd -m nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nagios
/usr/sbin/usermod -G nagcmd apache(此组为运行apache的组)


2)下载Nagios及其插件

cd /usr/local/src
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.2.tar.gz
wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
(请替换软件版本号为最新)

3)编译并安装Nagios

./configure --with-command-group=nagcmd
(默认安装目录为/usr/local/nagios)
make all

make install
make install-init
make install-config
make install-commandmode


这时请不要启动Nagios,接下来有很多工作要做……

4)定制配置文件

vi /usr/local/nagios/etc/objects/contacts.cfg
添加你自己的电子邮件地址,请注意本机DNS设置是否正常

5)配置WEB接口
在apache conf.d目录中安装Nagios web配置文件
make install-webconf

创建nagiosadmin帐号,添加密码
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

重新加载Apache配置文件
service httpd graceful

6)编译安装nagios plus

cd /usr/local/src
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11


编译安装Nagios plug
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

7)启动Nagios

使Nagio开机自启动
chkconfig --add nagios
chkconfig nagios on


检查Nagios配置文件
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

如果没有报错
启动Nagios

service nagios start

9)登录web管理界面

http://localhost/nagios/

输入nagiosadmin 用户名,密码

[table=98%,#ffffff]
Nagios3.x全攻略——(二)NRPE安装
[table=98%]
Nagios使用NRPE插件监控远程Linux主机
a)远程主机安装
i.创建用户
/usr/sbin/useradd nagios

ii.安装nagios plus
cd /usr/local/src
tar xzf nagios-plugins-1.4.6.tar.gz
cd nagios-plugins-1.4.6
./configure
make
make install
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec
iii.安装NRPE
cd /usr/local/src
./configure
make all

make install-plugin
make install-daemon
make install-daemon-config

iv.启动NRPE
vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,Monitoring Host ip
加入监控主机的IP地址,中间用逗号分隔
运行NRPE daemon
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
v.测试NRPE daemon
netstat -ln |grep 5666
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN
如果显示以上信息,it's OK!如果没有,请检查系统日志文件
/usr/local/nagios/libexec/check_nrpe -H localhost
如果正常,则显示
NRPE v2.8
vi.修改防火墙规则,开放tcp 5666端口
b)监控主机安装
i.安装check_nrpe plugin
cd /usr/local/src
./configure
make all
make install-plugin

ii.测试远程主机
/usr/local/nagios/libexec/check_nrpe -H remote host ip
如果正常,则显示
NRPE v2.8
否则请检查
-本机防火墙规则
-远程主机nrpe daemon是否工作正常
-远程主机防火墙规则

Nagios3.x全攻略——(三)NSClient++安装
Nagios使用NSClient++监控远程Windows主机
1.下载NSClient++
2.解压下载文件到C:\NSClient++
3.在CMD命令行下进入C:\NSClient++目录执行
nsclient++ /install
4.在服务中确定NSClient++可以与桌面交互
5.编辑nsc.ini
FileLogger.dll
CheckSystem.dll
CheckDisk.dll
NSClientListener.dll
;NRPEListener.dll
;SysTray.dll
CheckEventLog.dll
CheckHelpers.dll
;CheckWMI.dll

[NSClient]
;# ALLOWED HOST ADDRESSES
;  This is a comma-delimited list of IP address of hosts that are allowed to talk to NSClient deamon.
;  If you leave this blank the global version will be used instead.
allowed_hosts=your nagios monitoring server's IP


;  This is the port the NSClientListener.dll will listen to.
port=12489

6进入CMD命令行,启动NSClient++
nsclient++ /start
netstat -an
如果看到以下信息说明成功
TCP    0.0.0.0:12489            0.0.0.0:0              LISTENING



[ 本帖最后由 emcc-83 于 2008-11-6 12:09 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-11-04 10:59 |只看该作者
LZ,PNP或NagiosGrapher出图,nagios分布式监控。不知道是否分享一下,这类的详细文档比较少。谢谢!

论坛徽章:
0
3 [报告]
发表于 2008-11-04 13:44 |只看该作者

回复 #2 friend-sen 的帖子

呵呵 不好意思  我没有这方面的文档

论坛徽章:
0
4 [报告]
发表于 2008-11-04 15:49 |只看该作者
mark一下

论坛徽章:
0
5 [报告]
发表于 2008-11-05 18:39 |只看该作者
原帖由 friend-sen 于 2008-11-4 10:59 发表
LZ,PNP或NagiosGrapher出图,nagios分布式监控。不知道是否分享一下,这类的详细文档比较少。谢谢!



http://www.itnms.net/discuz/thread-550-1-1.html

看下这个吧,对于3这个是很容易搞定的

论坛徽章:
0
6 [报告]
发表于 2008-11-21 14:34 |只看该作者
我在客户端服务器上安装nagios-plugin的时候居然编译报错了。
请教一下,我装nagios-3.0.2.tar.gz的时候没有出现问题,但是装nagios-plugins的时候,发现如下问题:
configure没有问题,但是make的时候出现:
check_mysql.c:51:19: mysql.h: 没有那个文件或目录
check_mysql.c:52:20: errmsg.h: 没有那个文件或目录
check_mysql.c:58: error: `MYSQL_PORT' undeclared here (not in a function)
check_mysql.c: In function `main':
check_mysql.c:73: error: `MYSQL' undeclared (first use in this function)
check_mysql.c:73: error: (Each undeclared identifier is reported only once
check_mysql.c:73: error: for each function it appears in.)
check_mysql.c:73: error: syntax error before "mysql"
check_mysql.c:74: error: `MYSQL_RES' undeclared (first use in this function)
check_mysql.c:74: error: `res' undeclared (first use in this function)
check_mysql.c:75: error: `MYSQL_ROW' undeclared (first use in this function)
check_mysql.c:75: error: syntax error before "row"
check_mysql.c:91: error: `mysql' undeclared (first use in this function)
check_mysql.c:93: error: `MYSQL_READ_DEFAULT_GROUP' undeclared (first use in this function)
check_mysql.c:97: error: `CR_UNKNOWN_HOST' undeclared (first use in this function)
check_mysql.c:99: error: `CR_VERSION_ERROR' undeclared (first use in this function)
check_mysql.c:101: error: `CR_OUT_OF_MEMORY' undeclared (first use in this function)
check_mysql.c:103: error: `CR_IPSOCK_ERROR' undeclared (first use in this function)
check_mysql.c:105: error: `CR_SOCKET_CREATE_ERROR' undeclared (first use in this function)
check_mysql.c:112: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
check_mysql.c:112: warning: passing arg 2 of `memcpy' makes pointer from integer without a cast
check_mysql.c:112: warning: passing arg 1 of `__strdup' makes pointer from integer without a cast
check_mysql.c:116: error: `CR_SERVER_GONE_ERROR' undeclared (first use in this function)
check_mysql.c:118: error: `CR_SERVER_LOST' undeclared (first use in this function)
check_mysql.c:120: error: `CR_UNKNOWN_ERROR' undeclared (first use in this function)
check_mysql.c:127: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
check_mysql.c:127: warning: passing arg 2 of `memcpy' makes pointer from integer without a cast
check_mysql.c:127: warning: passing arg 1 of `__strdup' makes pointer from integer without a cast
check_mysql.c:134: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
check_mysql.c:134: warning: passing arg 2 of `memcpy' makes pointer from integer without a cast
check_mysql.c:134: warning: passing arg 1 of `__strdup' makes pointer from integer without a cast
check_mysql.c:146: error: `row' undeclared (first use in this function)
check_mysql.c:147: warning: passing arg 1 of `strlen' makes pointer from integer without a cast
check_mysql.c:147: warning: passing arg 2 of `memcpy' makes pointer from integer without a cast
check_mysql.c:147: warning: passing arg 1 of `__strdup' makes pointer from integer without a cast
check_mysql.c:165: error: `MYSQL_FIELD' undeclared (first use in this function)
check_mysql.c:165: error: `fields' undeclared (first use in this function)
make[2]: *** [check_mysql-check_mysql.o] 错误 1
make[2]: Leaving directory `/home/soft/nagios-plugins-1.4.11/plugins'
make[1]: *** [all-recursive] 错误1
make[1]: Leaving directory `/home/soft/nagios-plugins-1.4.11'
make: *** [all] 错误 2
请教会是什么问题导致呢?

论坛徽章:
0
7 [报告]
发表于 2008-11-21 14:35 |只看该作者
顶一下

论坛徽章:
0
8 [报告]
发表于 2008-11-21 14:37 |只看该作者
目前我在虚拟机上能安装,与虚拟机相比,实际运行环境中原本安装了rpm的mysql,虚拟机中没有。我后来直接安装了mysql的tar,把原有的rpm换走了,实际环境中换的mysql源代码包与虚拟机中所用的mysql也是一样的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP