-----------------------------------主要软件应用-------------------------
FreeBSD apache22 php5 php5-extension Ngios Nagios-plugin Nrpe NSCclient++
-----------------------------------------系统安装-------------------------
1.
FreeBSD采用最小化安装
2.
更新ports
# portsnap fetch
#portsnap extract
---------------------------------------------软件安装------------------------
1.
Nagios
# cd /usr/ports//net-mgmt/nagios/
# make instal clean
//此过程会询问建立用户和组nagios
2.
Nagios-plugin
# cd /usr//net-mgmt/nagios-plugin/
# make install
3.
NRpe 下载地址为:
http://www.nagios.org/download/addons
//如果所要监控的服务器中有linux,不要直接使用ports 安装,因为ports安装过后,其格式为check_nrpe2, 但是linux 采用源码安装的为check_nrpe. 从而导致两者之间不能通信
# cd /usr/local
# tar zxvf nrpe-2.12.tar.gz
# cd nrpe-2.12
# ./configure
# make
# make install
网页服务器的安装请参考前人的文章
------------------------------------------------配置文件-------------------------
1.
查看/var/spool/nagios/下有没如下文件或文件夹,没则建立
drwxrwxr-x 2 nagios nagios 3072 Apr 23 00:00 archives
drwxrwxr-x 2 nagios nagios 512 Apr 23 13:53 checkresults
-rw-r--r-- 1 nagios nagios 1416 Feb 2 15:15 dead.letter
-rw-r--r-- 1 nagios nagios 0 Jan 27 11:30 nagios.debug
-rw-r--r-- 1 nagios nagios 4 Apr 21 16:45 nagios.lock
-rw-r--r-- 1 nagios nagios 19371 Apr 23 13:45 nagios.log
-rw-r--r-- 1 nagios nagios 0 Jan 26 14:31 object.cache
-rw-r--r-- 1 nagios nagios 0 Jan 26 14:31 object.precache
-rw-r--r-- 1 nagios nagios 125106 Apr 21 16:45 objects.cache
-rw------- 1 nagios nagios 203289 Apr 23 13:45 retention.dat
drwxrwxr-x 2 nagios nagios 512 Apr 21 16:45 rw
-rw-rw-r-- 1 nagios nagios 202933 Apr 23 13:53 status.dat
-rw-r--r-- 1 nagios nagios 0 Apr 21 16:45 status.sav
2.
# ee /usr/local/etc/nagios/nagios.cfg //添加如下两行
cfg_file=/usr/local/etc/nagios/objects/linux.cfg
cfg_file=/usr/local/etc/nagios/objects/windows.cfg
3.
# cd /usr/local/etc/nagios/object/
# ee linux.cfg
```````````````````````````````````````````````````````````````````````````````````````````
define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias linux Servers ; Long name of the group
members vici01,vici02,vici04
}
###################### Server CPU Check ######################
define service{
use generic-service
host_name vici01,vici02,vici04
service_description CPU Load
check_command
check_nrpe!check_load
}
###################### / Driver Space ########################
define service{
use generic-service ; Name of service template to use
host_name vici01,vici02,vici04
service_description / Drive Space
check_command
check_nrpe!check_/
}
###################### Ping Check #######################
define service{
use generic-service
host_name vici01,vici02,vici04
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
###################### mysql Check #######################
define service{
use generic-service
host_name vici01
service_description Mysql
check_command
check_mysql
}
#################### Host define config#################
define host{
use linux-server
host_name vici01
alias vicidial01 Server
address 192.168.2.xx
}
define host{
use linux-server
host_name vici02
alias vicidial02 Server
address 192.168.2.xx
}
define host{
use linux-server
host_name vici04
alias vicidial04 Server
address 192.168.1.xx
}
`````````````````````````````````````````````````````````````````````````````````````````````````
4.
# ee windows.cfg
```````````````````````````````````````````````````````````````````````````````````````````````
define hostgroup{
hostgroup_name windows-servers ; The name of the hostgroup
alias windows Servers ; Long name of the group
members axisoft-symatec,axiadsvr01
}
###################### Server Uptime Check ######################
define service{
use generic-service ; Name of service template to use
host_name axisoft-symatec,axiadsvr01 service_description Uptime
check_command
check_nt!UPTIME
}
##################### Server CPU Check #########################
define service{
use generic-service ; Name of service template to use
host_name axisoft-symatec,axiadsvr01 service_description CPU Load
check_command
check_nt!CPULOAD!-l 5,80,90
}
##################### Server Memory Check ######################
define service{
use generic-service ; Name of service template to use
host_name axisoft-symatec,axiadsvr01 service_description Memory Usage
check_command
check_nt!MEMUSE!-w 80 -c 90
}
###################### C Driver Space ########################
define service{
use generic-service ; Name of service template to use
host_name axisoft-symatec,axiadsvr01 service_description C:\ Drive Space
check_command
check_nt!USEDDISKSPACE!-l c -w 98 -c 99
}
################## D Driver Check #########################
define service{
use generic-service ; Name of service template to use
host_name axisoft-symatec,axiadsvr01
service_description D:\ Drive Space
check_command
check_nt!USEDDISKSPACE!-l d -w 98 -c 99
}
################ E Driver Check ###########################
define service{
use generic-service ; Name of service template to use
host_name axisoft-symatec,axiadsvr01 service_description E:\ Drive Space
check_command
check_nt!USEDDISKSPACE!-l e -w 98 -c 99
}
###################### F Driver Check ########################
define service{
use generic-service ; Name of service template to use
host_name axiadsvr01
service_description F:\ Drive Space
check_command
check_nt!USEDDISKSPACE!-l f -w 98 -c 99
}
###################### Ping Check #######################
define service{
use generic-service ; Name of service template to use
host_name axisoft-symatec,axiadsvr01
service_description PING
check_command
check_ping!100.0,20%!500.0,60%
}
######################## Host define config#################
define host{
use windows-server
host_name axisoft-symatec
alias endpoint
address 192.168.2.xx
}
define host{
use windows-server
host_name axiadsvr01
alias AD Server
address 192.168.2.xx
}
``````````````````````````````````````````````````````````````````````````````````````````````````
4.
# ee /usr/local/nagios/nrpe.cfg
log_facility=daemon
pid_file=/var/spool/nagios/nrpe.pid
server_port=5666
nrpe_user=nagios
nrpe_group=nagios
allowed_hosts=127.0.0.1 192.168.xx.xx
dont_blame_nrpe=0
debug=0
command_timeout=60
connection_timeout=300
command[check_users]=/usr/local/libexec/nagios/check_users -w 5 -c 10
command[check_load]=/usr/local/libexec/nagios/check_load -w 15,10,5 -c 30,25,20
command[check_/]=/usr/local/libexec/nagios/check_disk -w 10% -c 5% -p /
command[check_var]=/usr/local/libexec/nagios/check_disk -w 10% -c 5% -p /var
command[check_tmp]=/usr/local/libexec/nagios/check_disk -w 10% -c 5% -p /tmp
command[check_usr]=/usr/local/libexec/nagios/check_disk -w 10% -c 5% -p /usr
command[check_home]=/usr/local/libexec/nagios/check_disk -w 10% -c 5% -p /home
command[check_zombie_procs]=/usr/local/libexec/nagios/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/libexec/nagios/check_procs -w 150 -c 200
`````````````````````````````````````````````````````````````````````````````````````````````````
5.
# ee /usr/local/etc/apache22/Include/nagios.cfg
````````````````````````````````````````````````````````````````````````````````````````
ScriptAlias /nagios/cgi-bin "/usr/local/www/nagios/cgi-bin"
<Directory "/usr/local/www/nagios/cgi-bin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/etc/nagios/htpasswd.users
Require valid-user
</Directory>
Alias /nagios "/usr/local/www/nagios"
<Directory "/usr/local/www/nagios">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/etc/nagios/htpasswd.users
Require valid-user
</Directory>
至此,服务器端已完成,客户端待续```````````
![](../p_w_upload/201004/201004231272010970900.jpg)
linux 下的客户端安装,请参照如下附件:
转载于:https://blog.51cto.com/gnnjw/303429