扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
nagios主要功能是实现报警
永新网站建设公司创新互联,永新网站设计制作,有大型网站制作公司丰富经验。已为永新成百上千提供企业网站建设服务。企业网站搭建\外贸网站建设要多少钱,请找那个售后服务好的永新做网站的公司定做!
yum环境搭建:
[root@localhost~]#mount/dev/cdrom/mnt/cdrom/
mount:blockdevice/dev/cdromiswrite-protected,mountingread-only
[root@localhost~]#vim/etc/yum.repos.d/rhel-debuginfo.repo
[rhel-server]
name=RedHatEnterpriseLinuxserver
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
安装步骤
安装lamp环境
yuminstallMySQLmysql-develhttpdphpphp-gdphp-mbstring
测试lamp环境
创建一个组nagcmd
[root@localhostnagios-3.2.1]#groupaddnagcmd
创建一个账号nagios
[root@localhostnagios-3.2.1]#useradd-mnagios
加入组
[root@localhostnagios-3.2.1]#usermod-a-Gnagcmdnagios
将apache账号也添加进来
[root@localhostnagios-3.2.1]#usermod-a-Gnagcmdapache
解压缩
cdnagios-cn-3.2.3
配置
./configure--with-command-group=nagcmd--enable-event-broker
或者
./configure--with-command-group=nagcmd--prefix=/usr/local/nagios--sysconfdir=/etc/nagios--enable-event-broker
root@localhostnagios-3.2.1]#makeall
[root@localhostnagios-3.2.1]#makeinstall
(-Thisinstallstheinitscriptin/etc/rc.d/init.d)
makeinstall-commandmode
-Thisinstallsandconfigurespermissionsonthe
directoryforholdingtheexternalcommandfile
makeinstall-config
-Thisinstallssampleconfigfilesin/usr/local/nagios/etc
进入nagios目录
cd/usr/local/nagios/
在http服务器的配置目录(conf.d)下形成nagiosweb程序
cdnagios-cn-3.2.3
makeinstall-webconf
创建一个登陆nagiosweb程序的用户这个账号在以后通过web登陆nagios认证时使用
htpasswd-c/usr/local/nagios/etc/htpasswd.usersnagiosadmin
启动apache
servicehttpdstartchkconfighttpdon
安装nagios插件
./configure(perfix=/usr/local/nagios)--with-nagios-user=nagios--with-nagios-group=nagios
或者
./configure--with-nagios-user=nagios--with-nagios-group=nagios
make
makeinstall
将nagios服务加入chkconfig管理之类
chkconfig--addnagios
chkconfig--addnagios
检查nagios的配置文件的语法是否正确
/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg
可以将/usr/local/nagios/bin加入命令搜索路径中
vim.bashrc
..bashrc重新读取环境文件
可以将/usr/local/nagios/etc/nagios.cfg设置为一个连接
ln-s/usr/local/nagios/etc/nagios.cfg/etc/nagios.cfg
检查语法
nagios-v/etc/nagios.cfg
启动nagios服务
启动httpd服务
编辑vim/usr/local/nagios/etc/nagios.cfg
注释36行#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
重启nagios会报错,原因,是无可监控
打开该文件中的其他主机比如windows
39cfg_file=/usr/local/nagios/etc/objects/windows.cfg
重启服务
windows检测客户端配置
Snmp161
Nsclienrt12489check_nt
Nrpe5666
naclient改变里面的ns.ini
然后从其windows上的ncclient
在nagios服务器上,更改object下的window。dfg定义
重启nagios服务
linux客户段安装
先创建账号nagios
[root@localhost~]#yuminstallmysqlmysql-serverhttpdmysql-devel
[root@localhost~]#useraddnagios
安装插件
./configure(perfix=/usr/local/nagios)--with-nagios-user=nagios--with-nagios-group=nagios
或者
./configure--with-nagios-user=nagios--with-nagios-group=nagios
make&&makeinstall
安装nrpe(客户端和服务端都需要)
#tar-zxvfnrpe-2.12.tar.gz
#cdnrpe-2.12.tar.gz
#./configure--with-nrpe-user=nagios\
--with-nrpe-group=nagios\
--with-nagios-user=nagios\
--with-nagios-group=nagios\
--enable-command-args\
--enable-ssl
#makeall
#makeinstall-plugin
#makeinstall-daemon
#makeinstall-daemon-config
编辑客户端nrpe配置文件
vim/usr/local/nagios/etc/nrpe.cfg
(allowed_hosts=192.168.101.102(服务器地址))
以进程的方式启动nrpe
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d
nrpe服务器段
1.#./configure--with-nrpe-user=nagios\
--with-nrpe-group=nagios\
--with-nagios-user=nagios\
--with-nagios-group=nagios\
--enable-command-args\
--enable-ssl
#makeall
#makeinstall-plugin
2.commands.cfg定义外部构件nrpe
vim/usr/local/nagios/etc/objects/commands.cfg
增加
definecommand{
command_namecheck_nrpe
command_line$USER1$/check_nrpe-H$HOSTADDRESS$-c$ARG1$
}
3.为了监控linux系统修改nagios.cfg
vim/usr/local/nagios/etc/nagios.cfg
添加一行
cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg
4.在/usr/local/nagios/etc/objects创建mylinux.cfg
definehost{
uselinux-server;Inheritdefaultvaluesfromatemplate
host_namemylinux;Thenamewe'regivingtothishost
aliasmylinux;Alongernameassociatedwiththehost
address192.168.101.110;IPaddressofthehost
}
defineservice{
usegeneric-service
host_namemylinux
service_descriptioncheck-swap
check_commandcheck_nrpe!check_swap
}
defineservice{
usegeneric-service
host_namemylinux
service_descriptioncheck_load
check_commandcheck_nrpe!check_load
}
defineservice{
usegeneric-service
host_namemylinux
service_descriptioncheck-disk
check_commandcheck_nrpe!check_had1
}
defineservice{
usegeneric-service
host_namemylinux
service_descriptioncheck_user
check_commandcheck_nrpe!check_users
}
defineservice{
usegeneric-service
host_namemylinux
service_descriptioncheck_procs
check_commandcheck_nrpe!check_total_procs
}
改变数组
chownnagios.nagiosmylinux.cfg
5实现飞信报警
脚本(附件下载)
a、将飞信的文档传入linux系统,将库文件放入/usr/lib目录
chmoda+xfetion
b、使用下列命令测试./fetion--mobile=15136848083--pwd=lsx885--to15136848083--msg-type=0--msg-utf8$HOSTNAME
c.编辑vim/usr/local/nagios/etc/objects/contacts.cfg(这个文件可以不修改)
vim/usr/local/nagios/etc/objects/templates.cfg
34service_notification_commandsnotify-service-by-fetion;sendservicenotificationsviaemail
35host_notification_commandsnotify-service-by-fetion;sendhostnotificationsviaemail
d。定义命令
vim/usr/local/nagios/etc/objects/commands.cfg
definecommand{
command_namenotify-service-by-fetion
command_line/usr/bin/fetion--mobile=15136848083--pwd=lsx885--to15136848083--msg-type=0--msg-utf8$HOSTNAME
}
check_nrpe语法:
check_nrpe...-c
check_nrpe的内置命令:
·CheckAlwaysCRITICAL(check)
·CheckAlwaysOK(check)
·CheckAlwaysWARNING(check)
·CheckCPU(check)
·CheckCRITICAL(check)
·CheckCounter(check)
·CheckEventLog/CheckEventLog(check)
·CheckFile(check)
·CheckFileSize(check)
·CheckMem(check)
·CheckMultiple(check)
·CheckOK(check)
·CheckProcState(check)
·CheckServiceState(check)
·CheckTaskSched/CheckTaskSched(check)
·CheckUpTime(check)
·CheckVersion(check)
·CheckWARNING(check)
·CheckWMI/CheckWMI(check)
·CheckWMIValue(check)
用法如:
#check_nrpe...-cCheckCPU-awarn=80crit=90time=20mtime=10stime=4
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流