nagios图形显示的配置





在服务端安装相关软件

#1、图形显示管理的依赖库

yum install cairo pango zlib zlib-devel freetype freetype-devel gd gd-devel -y





#2、rrdtools的依赖

tar xf libart_lgpl-2.3.17.tar.gz

cd libart_lgpl-2.3.17

./configure

make

make install

/bin/cp -r /usr/local/include/libart-2.0 /usr/include

cd ../





#3、rrdtools轮询的数据库,专门画图

tar xf rrdtool-1.2.14.tar.gz 

cd rrdtool-1.2.14

./configure --prefix=/usr/local/rrdtool  --disable-python  --disable-tcl

#WARNING: The RRDs Perl Modules are not found on your System

#Using RRDs will speedup things in larger Installtions.

#configure后出现上面的提示可以不用理会。

make

make install

cd ../

ls -l /usr/local/rrdtool/bin





报错:

configure: error: Please fix the library issues listed above and try again.

解决:

yum -y install pango*

yum install -y libart_lgpl-devel





#4、PNP收集数据告诉rrdtools画图,PHP负责展示

tar zxf pnp-0.4.14.tar.gz

cd pnp-0.4.14

./configure \

--with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata/

#################

#  WARNING: The RRDs Perl Modules are not found on your System

#           Using RRDs will speedup things in larger Installtions.

#####################

make all

make install

make install-config

make install-init

ll /usr/local/nagios/libexec/ |grep process

问题:configure报错(一般不会发生)

checking for linker flags for loadable modules... -shared

checking for Perl Module Time::HiRes... no

configure: error: Perl Module Time::HiRes not available

解决:

yum install perl-Time-HiRes -y





配置出图



1.vim /usr/local/nagios/etc/nagios.cfg +833

    833 process_performance_data=1<==========

    834 

    835 

    836 

    837 # HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS

    838 # These commands are run after every host and service check is

    839 # performed.  These commands are executed only if the

    840 # enable_performance_data option (above) is set to 1.  The command

    841 # argument is the short name of a command definition that you

    842 # define in your host configuration file.  Read the HTML docs for

    843 # more information on performance data.

    844 

    845 host_perfdata_command=process-host-perfdata<==========

    846 service_perfdata_command=process-service-perfdata<==========





2.执行编辑命令 vim /usr/local/nagios/etc/objects/commands.cfg +227,修改commands.cfg配置文件。

#修改commands.cfg 配置文件,约227-238行

#默认配置为(如果没有直接添加即可)

#-----------------------------------------------------------------   

# 'process-host-perfdata' command definition

define command{

        command_name    process-host-perfdata

        command_line    /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out

        }

# '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

        }

修改成如下配置

# 'process-host-perfdata' command definition

define command{

        command_name    process-host-perfdata

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

        }





# 'process-service-perfdata' command definition

define command{

        command_name    process-service-perfdata

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

        } 

也可以用nagios变量$USER1$替代/usr/local/nagios/libexec/路径

执行检查语法命令/etc/init.d/nagios checkconfig 

Total Warnings: 0

Total Errors:   0

根据提示,配置通过。重新加载/etc/init.d/nagios reload





3、主机出图的配置,模板或主机配置里hosts.cfg或者vim templates.cfg

action_url            /nagios/pnp/index.php?host=$HOSTNAME$

单独对hosts.cfg的配置

对 templates.cfg 的配置

4、服务出图,模板或服务配置里service.cfg、templates.cfg注意,service中的use generic-service 要和 templates中的name generic-service名称要一致

action_url            /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$

对service.cfg的配置

对templates.cfg的配置

snmp协议(cacti),客户端安装或开启SNMP

nrpe(nlient++)

网络设备(路由器,交换机),开启SNMP





自定义插件:监控密码文件是否改变





测试

# md5sum /etc/passwd

c8273759e929d37c56dbae0478bd4d3b  /etc/passwd

[root@node3 ~]# md5sum /etc/passwd >/etc/jack.md5

[root@node3 ~]# md5sum -c /etc/jack.md5

/etc/passwd: OK





①在客户端添加自定义脚本

cd /usr/local/nagios/libexec

cat check_passwd





#!/bin/bash

char=`md5sum -c /etc/jack.md5 2>/dev/null|grep "OK"|wc -l`

if [ $char -eq 1 ];then

echo "passwd is ok"

exit 0

else

echo "passwd is changed"

exit 2

fi





# chmod +x check_passwd 

[root@node3 libexec]# ll check_passwd 

-rwxr-xr-x 1 root root 166 Jul 22 21:33 check_passwd

②在客户端增加命令,并重启nrpe服务使之生效

vim /usr/local/nagios/etc/nrpe.cfg

添加check_passwd定义命令

command[check_passwd]=/usr/local/nagios/libexec/check_passwd

③在服务端测试

/usr/local/nagios/libexec/check_nrpe -H 192.168.8.41 -c check_passwd





添加服务脚本

define service{

        use generic-service

        host_name node3.chinasoft.com

        service_description   check_passwd

        check_command   check_nrpe!check_passwd

}





检测语法并重新加载service nagios checkconfig,service nagios reload

④改变性测试在客户端执行添加用户命令 useradd jack

服务端执行

/libexec/check_nrpe -H 192.168.8.41 -c check_passwd

passwd is changed

最新文章

  1. [LeetCode] Repeated Substring Pattern 重复子字符串模式
  2. 初学Python遇到的问题一二
  3. Python之路----------内置函数
  4. pip常见操作收录
  5. iOS 微信分享
  6. 卸载安装失败的sqlserver2008 R2
  7. JS设置获取cookies
  8. 【翻译自mos文章】改变数据库用户sysman(该用户是DB Control Repository 的schema)password的方法
  9. linux系统性能监控常用命令
  10. 积累的VC编程小技巧之滚动条
  11. 支付宝电脑支付沙箱配置(JAVA)
  12. Centos6.8安装redis(一)
  13. easyui---easyloader.js
  14. 《opencv学习》 之 几何变换
  15. 【手记】解决启动SQL Server Management Studio 17时报Cannot find one or more components...的问题
  16. poj 1849 Two 树形dp
  17. 【转载】OGRE 2.1 Windows 编译
  18. Okhttp实用封装
  19. es学习-映射管理
  20. java--多线程之后台线程

热门文章

  1. 【bzoj3039】玉蟾宫 悬线法
  2. mockery expectation 覆盖
  3. springboot配置多环境
  4. k8s 常用命令汇集
  5. 20190311 Windows上ZooKeeper伪集群的实现
  6. 原生ajax中get和post请求
  7. VS新建项目工具箱图标丢失问题
  8. 有关Java内存溢出及内存消耗的小知识
  9. 解决IntelliJ IDEA无法读取配置*.properties文件的问题
  10. u-boot移植(十三)---代码修改---裁剪及环境变量 二