vim/usr/local/icinga/etc/ido2db.cfg 查看四行配置
db_servertype=mysql
db_port=3306
db_user=icinga
db_pass=icinga
cdicinga-cn-1.12.2
makecgis
makeinstall-cgis
makeinstall-html
makeinstall-webconf
设置登录icinga密码设置密码为HanZheng.123
htpasswd-c/usr/local/icinga/etc/htpasswd.usersicingaadmin
servicehttpdrestart
编译安装nagios-cn-plugins-2.0.3.tar.xz
tarxvfnagios-cn-plugins-2.0.3.tar.xz
cdnagios-cn-plugins-2.0.3
./configure--prefix=/usr/local/icinga--with-cgiurl=/icinga/cgi-bin--with-nagios-user=icinga--with-nagios-group=icinga
make
make install
编译安装icinga-nrpe-2.14.tar.gz
tarxvficinga-nrpe-2.14.tar.gz
cd icinga-nrpe-2.14
./configure
make
makeinstall
makeinstall-plugin
makeinstall-init
makeinstall-xinetd
makeinstall-daemon-config
关闭selinux
vim/etc/sysconfig/selinux
SELINUX=disabled
setenforce0 立即生效
sed-i's/SELINUX=enforcing/SELINUX=disabled/'/etc/selinux/config
启动相应服务
/etc/rc.d/init.d/ido2dbrestart
/etc/rc.d/init.d/icingarestart
chkconfig--level35ido2db on
chkconfig--level35icingaon
chkconfighttpdon
chkconfigmysqld on
运行命令检测配置
/usr/local/icinga/bin/icinga-v/usr/local/icinga/etc/icinga.cfg
登入web界面测试 http:
//192.168.31.48/icinga 用户名icingaadmin密码HanZheng.123设置的密码
进入界面
添加主机
打开网页后,发现只能看到监控localhost,所以需要监控其他host。
没有webUI可以完成这个功能。
需要到icingaserver上操作。
vi/usr/local/icinga/etc/objects/linux.cfg
添加主机IP
definehost{
use linux-server ;Inheritdefaultvaluesfromatemplate
host_name WN ;Thenamewe'regivingtothishost
alias staticfilerserver ;Alongernameassociatedwiththehost
address 192.168.31.158 ;IPaddressofthehost
contact_groups admins ;Hostgroupsthishostisassociatedwith
}
definehost{
use linux-server ;Inheritdefaultvaluesfromatemplate
host_name XI ;Thenamewe'regivingtothishost
alias hanzheng ;Alongernameassociatedwiththehost
address 192.168.31.172 ;IPaddressofthehost
contact_groups admins ;Hostgroupsthishostisassociatedwith
icon_image vendors/redhat.gif
statusmap_image vendors/redhat.gd2
}
definehost{
use linux-server ;Inheritdefaultvaluesfromatemplate
host_name hz ;Thenamewe'regivingtothishost
alias xq ;Alongernameassociatedwiththehost
address 192.168.31.33 ;IPaddressofthehost
contact_groups admins ;Hostgroupsthishostisassociatedwith
icon_image vendors/redhat.gif
statusmap_image vendors/redhat.gd2
}
添加主机服务
defineservice{
use generic-service
host_name XI,WN,hz
service_description check_load
check_command check_nrpe!
check_load
}
defineservice{
use generic-service
host_name XI,WN,hz
service_description check_users
check_command check_nrpe!
check_users
}
defineservice{
use generic-service
host_name XI,WN,hz
service_description check_total
check_command check_nrpe!
check_total_procsi
}
defineservice{
use generic-service
host_name XI,WN,hz
service_description check_hda1
check_command check_nrpe!
check_hda1
service_description HTTP
check_command check_nrpe!
check_http
service_description PING
servicegroups Linux-Ping
check_command check_ping!
100.0,20%!
500.0,60%
service_description SwapUsage
check_command check_nrpe!
check_swap
}
cfg_file=/usr/local/icinga/etc/objects/linux.cfg
运行命令检测配置
/usr/local/icinga/bin/icinga-v/usr/local/icinga/etc/icinga.cfg
重启icinga服务
serviceicingareload
客户端安装依赖包
yuminstallgccopenssl-devel
客户端主机的配置
添加用户(普通账户)icinga
/usr/sbin/useraddicinga
passwdicinga
客户端编译和安装Icinga插件
wget
tarjxvfnagios-cn-plugins-1.5.tar.bz2
cdnagios-cn-plugins-1.5
./configure-prefix=/usr/local/icinga\
--with-package-name=icinga-plugins\
--with-nagios-user=icinga--with-nagios-group=icinga
make
makeinstall
客户端编译和安装Nrpe
wget
tarxvzficinga-nrpe-2.14.tar.gz
cdicinga-nrpe-2.14
./configure--prefix=/usr/local/icinga--with-nrpe-user=icinga--with-nrpe-group=icinga\
--with-icinga-user=icinga--with-icinga-group=icinga
makeall
makeinstall
makeinstall-plugin
makeinstall-daemon
makeinstall-daemon-config
makeinstall-init
配置客户端Nrpe
添加nrpe服务器地址,允许服务器对其读取信息
vi/usr/local/icinga/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.31.48
增加command字段来添加要监控的服务
command[check_users]=/usr/local/icinga/libexec/check_users-w5-c10
command[check_load]=/usr/local/icinga/libexec/check_load-w15,10,5-c30,25,20
command[check_hda1]=/usr/local/icinga/libexec/check_disk-w20%-c10%-p/dev/hda1
command[check_zombie_procs]=/usr/local/icinga/libexec/check_procs-w5-c10-sZ
command[check_total_procs]=/usr/local/icinga/libexec/check_procs-w150-c200
command[check_ssh]=/usr/local/icinga/libexec/check_ssh-Hlocalhost
command[check_swap]=/usr/local/icinga/libexec/check_swap-w20%-c10%
command[check_mysql]=/usr/local/icinga/libexec/check_mysql-Hlocalhost-uroot-ptomcat2008
command[check_apache]=/usr/local/icinga/libexec/check_apachestatus-Hlocalhost-p80
command[check_ntp]=/usr/local/icinga/libexec/check_ntp-Hlocalhost-w0.5-c1
command[check_snmp]=/usr/local/icinga/libexec/check_snmp_service-Hlocalhost-Cmonitor_energysh
启动Nrpe
serviceicinga-nrpestart
服务端查看
检测服务端check_nrpe与客户端运行的nrpedaemon之间的通信
/usr/local/icinga/libexec/check_nrpe-H192.168.31.33
NRPEv2.14
Windows 客户端部署
官方推荐NSClient++addon
下载 或者
双击安装即可。
这里下载的版本是NSCP-0.4.1.73-x64.msi
设置Agent
从服务里找到NSClient++,设置服务自动启动
属性里设置如下,这里没有设置密码
设置allowedhosts
配置文件在:
C:
\ProgramFiles\NSClient++\nsclient.ini
[/settings/default]
;ALLOWEDHOSTS-Acomaseparatedlistofallowedhosts.Youcanusenetmasks(/syntax)or*tocreateranges.
allowedhosts=192.168.31.48