##Debian 6 安装server# apt-get install nagios*一路设置好各种密码,成功后访问 http://ip/nagios3 既可,默认用户*nagiosadmin*##Centos 安装clientrpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpmyum -y install nagios nagios-plugins-all nrpechkconfig nrpe on编辑配置文件 `nano /etc/nagios/nrpe.cfg`将其中的`allowed_hosts`改为自己的值:allowed_hosts=192.168.1.2 #server地址重启nrpe:service nrpe restart##配置Server端检测一下是否能连接到client:/usr/lib/nagios/plugins/check_nrpe -H 192.168.2.11进入`/etc/nagios3/conf.d`目录,新建并编辑`my_nagios2.cfg`:define host{use generic-hosthost_name mylinuxalias mylinuxaddress 192.168.1.mylinux}define service{use generic-servicehost_name mylinuxservice_description HTTP-Servercheck_command check_http}# Define a service to check the disk space of the root partition# on the local machine. Warning if < 20% free, critical if# < 10% free space on partition.define service{use generic-service ; Name of service template to usehost_name mylinuxservice_description Disk Spacecheck_command check_all_disks!20%!10%}# Define a service to check the number of currently logged in# users on the local machine. Warning if > 20 users, critical# if > 50 users.define service{use generic-service ; Name of service template to usehost_name mylinuxservice_description Current Userscheck_command check_users!20!50}# Define a service to check the number of currently running procs# on the local machine. Warning if > 250 processes, critical if# > 400 processes.define service{use generic-service ; Name of service template to usehost_name mylinuxservice_description Total Processescheck_command check_procs!250!400}# Define a service to check the load on the local machine. define service{use generic-service ; Name of service template to usehost_name mylinuxservice_description Current Loadcheck_command check_load!5.0!4.0!3.0!10.0!6.0!4.0}重启服务:service nagios3 restart##添加Mysql监控插件在server下载插件:cd /usr/lib/nagios/pluginswget https://raw.github.com/tart/tart-monitoring/master/checkMySQLProcesslist.shchmod a+x checkMySQLProcesslist.sh向command配置`/etc/nagios3/commands.cfg`中添加:define command{command_name checkMySQLProcesslistcommand_line /usr/lib/nagios/plugins/checkMySQLProcesslist.sh -u $ARG1$ -p $ARG2$ -s 60 -w 20 -c 50}向client配置`/etc/nagios3/conf.d/my_nagios2.cfg`中添加:define service{use generic-service host_name localhostservice_description Mysql Process List check_command checkMySQLProcesslist!用户名!密码}然后重启服务:service nagios3 restart##other> Nagios的插件编写很简单,同上mysql的插件,照葫芦画瓢就行,添加其他client节点,只要安装好相应系统的nrpe和nagios的插件,然后在server段添加一个配置文件就行。