vim templates.cfg //添加小太阳模版,镶嵌在nagios页面上
##### 添加pnp4nagios的模板 #######
define host {
name host-pnp
action_url /pnp4nagios/graph?host=$
hostname$&srv=_HOST_
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
遇到的问题:
一、访问nagios页面,点击图表显示图标,报错如下:
Kohana requires PHP 5.2 or newer.
说明我们安装的php版本过低,需要升级php
二、访问nagios页面,点击图表显示图标,报错如下:
解决办法:(与yum升级php相似)
找到php比较新的yum源,创建新的源,将原有的yum源先屏蔽掉,使用新源。
mv CentOS-Base.repo CentOS-Base.repo.old
vim updatephp.repo
添加如下内容
[abrmblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
yum update php -y
yum install php*-gd
步骤4,安装nrpe和 OMSA,以及用nrpe检测OMSA
下载安装nrpe:
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
tar xzvf nrpe-2.13.tar.gz
cd nrpe-2.13
/configure && make all && make install-plugin && make install-daemon && make install-daemon-config
ll /usr/local/nagios/
chown -R nagios:nagios /usr/local/nagios
添加nrpe检测OMSA配置文件:
mkdir -p /usr/local/nagios/etc/objects/Dell_OMSA
cd /usr/local/nagios/etc/objects/Dell_OMSA/
vim dell_service_linux.cfg
其中添加内容:
define service {
host_name web112
service_description check_omsa
use generic-service
check_command check_nrpe!check_omsa
_ser_info dell omsa
check_interval 10
notification_options c,r
}
vim /usr/local/nagios/etc/objects/localhost.cfg
添加如下内容:
################ 自定义主机 ##################
define host{
use linux-server,host-pnp
host_name web112
alias pnp4nagios
address 192.168.144.112
}
vi /usr/local/nagios/etc/nagios.cfg
添加如下语句:
cfg_file=/usr/local/nagios/etc/objects/Dell_OMSA/dell_service_linux.cfg
vi /usr/local/nagios/etc/nrpe.cfg
添加如下语句:
command[check_omsa]=/usr/local/nagios/libexec/check_openmanage -b ctrl_fw=ALL/ctrl_driver=ALL -p
下载安装OMSA检测插件:
cd /root/softwares/
wget http://folk.uio.no/trondham/software/files/check_openmanage-3.7.3.tar.gz
tar xzvf check_openmanage-3.7.3.tar.gz
cp check_openmanage /usr/local/nagios/libexec/
ll /usr/local/nagios/libexec/check_openmanage
chown -R nagios:nagios /usr/local/nagios/
ll /usr/local/nagios/libexec/check_openmanage
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
/usr/local/nagios/libexec/check_nrpe -H localhost
/etc/init.d/nagios restart
/etc/init.d/npcd restart
被监控机器安装OMSA:
mkdir -p /usr/local/omsa
cd /usr/local/omsa
wget http://ftp.us.dell.com/sysman/OM_5.5.0_ManNode_A00.tar.gz
vim /etc/redhat-release //在行末添加Tikanga
CentOS release 5.6 (Final)Tikanga
sh linux/supportscripts/srvadmin-install.sh -x
linux/supportscripts/srvadmin-services.sh start
By default, OMSA web application runs on Port 1311 . Login to OMSA from web using the URL: https://{omsa-server-ip-address}:1311 using root as shown below. Please note that you can login only using HTTPS.
步骤5,邮件报警功能设置
vim /usr/local/nagios/etc/objects/contacts.cfg
在最后添加如下内容:
复制代码 代码示例:
############# system administrators #############
define contact{
contact_name ****
use generic-contact
alias administrator01
email 接受报警的邮箱01,例如:123456789@qq.com
}
define contact{
contact_name ****
use generic-contact
alias administrator02
email 接受报警的邮箱02
}
define contact{
contact_name ****
use generic-contact
alias administrator03
email 接受报警的邮箱03
}
define contact{
contact_name ****
use generic-contact
alias administrator04
email 接受报警的邮箱04
}
############# group of system administrators ###########
define contactgroup{
contactgroup_name system-admins
alias Nagios Administrators
members 刚才定义的contact_name,成员与成员之间用逗号分割
}
vim /usr/local/nagios/etc/objects/templates.cfg
将contact_groups 选项的admins修改为system-admins
或通过sed命令直接替换:
sed 's/admins/system-admins/g' /usr/local/nagios/etc/objects/templates.cfg
要成功发送邮件,还要开启smtp服务,需要启用sendmail或者相似应用。
本文使用系统的sendmail。
/etc/init.d/sendmail start
发送测试邮件:
echo 'Hello,nagios.I'm your administrator!!!' | mail -s 'mail test' *******@qq.com
如果邮件发送不成功,请检查tcp25端口是否在监听,并且查看防火墙设置是否放行25端口。
至此,nagios的监控功能初步完成。之后需要做的就是把被监控节点一个一个的加进来了。
也可以写个shell或perl脚本,批量添加主机进来。