q9989 发表于 2019-1-17 09:59:21

ubuntu7.10 server nagios3.03

  今天刚装的ubuntu server7.10 去nagios看到有新版本,就决定装一下`第一次在ubuntu里面装`便把他记录下来,nagios很强大的,可以与很多软件整合的,以后这篇文章慢慢修改!在这里谢谢http://nagios-cn.sourceforge.net/的作者,让很多菜鸟飞起了!废话不多说!开始操作
1。首先到
  www.nagios.org下载


  nagios-3.0.3.tar.gz


  nagios-plugins-1.4.12.tar.gz


  2。安装所需要的库


  apt-get install apache2 php5-gd build-essential libgd2-xpm-dev php5 mysql-server libmysqlclient15-dev libssl-dev perl


  3.useradd nagios


  passwd nagios


  groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd www-data



  4。tar zxvf nagios-3.0.3.tar.gz


  cd nagios-3.0.3


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


  make all


  make install
make install-init
make install-config
make install-commandmode
vi /usr/local/nagios/etc/objects/contacts.cfg
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/etc/init.d/apache2 reload


  5.tar zxvf nagios-plugins-1.4.12.tar.gz


  cd nagios-plugins-1.4.12


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


  make
make install


  ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start
apt-get install mailx

6.打开IE访问http://localhost/nagios

   安装nrpe-2.12.


  在安装之前,先发一张图来说明它的设计概括图:

http://deidara.blog.运维网.com/attachment/200807/200807181216350255125.jpg
1. 被监控端安装
apt-get install xinetd
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
vim /etc/xinetd.d/nrpe
修改 only_from = 127.0.0.1
vim /etc/services
再最后添加
nrpe       5666/tcp          #NRPE
重启 xinetd 服务
/etc/init.d/xinetd restart
查看服务是否启动
netstat -an | grep nrpe
tcp   0   0 *:nrpe *:* LISTEN
执行/usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12
返回版本信息说明OK!
vim /usr/local/nagios/etc/nrpe.cfg
可以添加你需要监控的服务!
2。安装nagios服务端
tar zxvf nrpe-2.12
cd nrpe-2.12
./configure
make all
make install-plugin
/usr/local/nagios/libexec/check_nrpe -H 192.168.0.1
返回版本信息
NRPE v2.12
vim /usr/local/nagios/etc/objects/commands.cfg
在最后添加
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
然后就可以在service.cfg里面添加 check_nrpe!check_load了。
                            安装PNP+RRDTOOL   
安装PNP是一个很小的开源包,他基于PHP和PERL,利用rrdtool将Nagios采集的数据绘制成图表。如果你要安装PNP,那么准备工作有如下3项:
1、整合Apache和PHP(本文使用版本:Apache 2.2.3PHP 5.1.6)
2、安装rrdtools (本文使用版本:RRDTools 1.2.23)
3、安装Perl (本文使用版本: Perl5 )
因为我是ubuntu系统所以我就用懒人安装。全是apt-get 安装的牛人可以编译源代码安装
要介绍PNP工作原理,首先要说明一下Nagios提供的数据接口,也就是PNP的数据来源。在前面的文章中,我提到过,在定义host或service中都有一个定义项,名为process_perf_data,其值可以定义为0或1,其作用是是否启用Nagios的数据输出功能。如果你将此项赋值为1,那么Nagios就会将收集的数据写入到某个文件中,以备提取。所以,如果你想让Nagios将数据输出的话,首先要将Nagios的主配置文件nagios.cfg中相关的配置修改:
process_performance_data= 1
service_perfdata_command=process-service-perfdata
如果想要对某个监控对象做数据图表,则需要在所对应的service定义:
process_perf_data 1
这样,Nagios就会调用相应的命令来输出数据了。Nagios的command定义中默认有一项“process-service-perfdata”,该命令声明了Nagios输出哪些值到输出的文件中。不过其定义相对简单,PNP提供了一个perl脚本,更详尽的定义了一个输出数据的方法。如果要使用PNP的话,我们需要在command的定义中,将“process-service-perfdata”命令对应的执行命令行的内容替换成该脚本:
define command{

command_name process-service-perfdata

command_line /usr/local/nagios/libexec/process_perfdata.pl

}
这样设置了之后,Nagios就会利用PNP提供的脚本进行相关的工作了。
设置完后,我们还没有process_perfdata.pl脚本。开始安装pnp包。
./configure --with-rrdtool=/usr/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata/
make all
make install
make install-config
然后进到 /usr/local/nagios/etc/pnp
mv rra.cfg-sample rra.cfg
mv process_perfdata.cfg-sample process_perfdata.cfg
mv npcd.cfg-sample npcd.cfg
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果没有什么错误,就从起一下nagios
/etc/init.d/nagios restart
验证下成果,在浏览器输入:
http://IP/nagios/pnp/
如果出现http://deidara.blog.运维网.com/attachment/200807/200807181216356047546.jpg
说明你在service.cfg里面还没有设置监控主机`
好了先写这么多,等以后加载什么插件继续添加。




页: [1]
查看完整版本: ubuntu7.10 server nagios3.03