显示如下:
 define host{
host_name 172.16.75.231
alias windows-75-231
address 172.16.75.231
check_command check-host-alive
max_check_attempts 5
check_period 24x7
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options d,u,r
action_url /nagios/pnp/index.php?host=$HOSTNAME//添加太阳图标
process_perf_data 1 //添加太阳图标
icon_p_w_picpath /usr/local/nagios/share/p_w_picpaths/logos/win.jpg
icon_p_w_picpath_alt /usr/local/nagios/share/p_w_picpaths/logos/windows.jpg
vrml_p_w_picpath /usr/local/nagios/share/p_w_picpaths/logos/4u.jpg
statusmap_p_w_picpath /usr/local/nagios/share/p_w_picpaths/logos/win.jpg
2d_coords 40,50   //2d坐标
#3d_coords 40,50,47
}
首先配置这台主机
Define host{
主机名,主别名,主机的Ip地址.监控的时间段和警告信息
最后2项是pnp绘图需要的变量。
}
这个是相同文件下的服务。这里监控的是3389。其他的服务类似配置.如果selinux处于开启状态,请关闭,或者处于兼容状态,否则无法打开网页.
直此:nagios安装完毕。现在通过http://ip/nagios可以打开监控的页面了。现在可以看到对于主机本身的监控和172.16.75.231这台主机的监控.但是只能显示文字信息,我们需要绘图功能,这个需要用到pnnrrdttol 2个软件
二:绘图工具的安装
1:安装相应的支持包
#yum install cairo pango libart_lgpl libart_lgpl-devel zlib zlib-devel freetype freetype-devel  
2:安装rrdtool
#./configure
#make
#make install
3:做一些配置
#vi /usr/local/nagios/etc/nagios.cfg
process_performance_data=1  
host_perfdata_command=host-service-perfdata   
service_perfdata_command=process-service-perfdata 
上面三项处于允许状态,取消前面的”;”.
commands.cfg做如下配置。注释掉process-service-prefdata这个命令的command_line,写上新的command_line.
# 'process-service-perfdata' command definition
define command{
 command_name process-service-perfdata
 #command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out
command_line /usr/local/nagios/libexec/process_perfdata.pl
 }
4:安装pnp
#./configure –with-rrdtool=/usr/local/rrdtool-1.0.50/bin/rrdtool
#make all
#make install
5:配置被监控端的文件
加入action_url process_perf_data2个变量。
在使用该绘图功能的时候,一定要配置apache支持php功能。
 
6:重启httpd服务器和nagios服务.
三:飞信报警功能
1:安装飞信所需要的的libACE库文件
2:安装飞信软件
#tar –zxvf feition20091117-linux.tar.gz –C /usr/local
#mv /usr/local/fx /usr/local/fetion
3:加入执行权限更换属组
#Chmod  +x fetion
#chown –R nagios.nagcmd fetion
4:复制安装libACE下的lib目录中的文件到/usr/lib
 [root@nagios library32]# ls
libACE.so.5.4.7  libACE_SSL.so.5.4.7  libcrypto.so.0.9.8  libssl.so.0.9.8
[root@nagios library32]# cp *.* /lib/
[root@nagios library32]# cp *.* /usr/lib/
5: 加入飞信.so文件到系统链接库
#vi /etc/ld.so.conf.d/fetion.conf
加入 /usr/local/fetion
#ldconfig
6:配置commands.cfg文件
define command{
command_name host-notify-by-fetion
command_line /usr/local/fetion/fetion --hide --mobile=150xxxxxxx2 --pwd=xxx --to=$CONTACTPAGER$ --msg-utf8="HOST $HOSTSTATE$ Alert for $HOSTNAME$!on '$LONGDATETIME$'" $CONTACTPAGER$
}
define command{
command_name service-notify-by-fetion
command_line /usr/local/fetion/fetion --hide --mobile=150xxxxx2 --pwd=xxxxx --to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$
}
加入上面2command,关于fetion的。
7:配置contacts.cfg
define contact{
        contact_name                    nagiosadmin  ; Short name of user
 use    generic-contact  ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin  ; Full name of user
        email    zjj17xx1@xxxxxx.com
;,rtong@xxxxxt.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email,service-notify-by-fetion
host_notification_commands notify-host-by-email,host-notify-by-fetion
contactgroups sagroup
;pager 1386xxxxxx
注意pager变量是一个手机号。注意注释的fetion
8:重启httpdnagios服务。
 
nagios安装基本结束。