Linux上Nagios安装配置初入门(3)

通过NRPE监控远程Linux主机要使用chech_nrpe插件进行,其语法格式如下:

check_nrpe -H <host> [-n][-u][-p <port>][-t <timeout>][-c <command>][-a <arglist...>]

定义监控远程Linux主机资源的通用性命令:

# vim /etc/nagios/objects/commands.cfg define command { command_name check_nrpe command_line $USER1$/check_nrpe –H "$HOSTADDRESS$" -c $ARG1$ }

定义远程Linux主机的资源配置文件,可根据实际情况定义

# cat /etc/nagios/objects/linux.cfg |grep "^\s*[^#\t].*$" define host{ use linux-server ; Inherit default values from a template host_name webserver ; The name we're giving to this host alias My Web Server ; A longer name associated with the host address 192.168.1.72 ; IP address of the host } define hostgroup{ hostgroup_name web-servers ; The name of the hostgroup alias Web Servers ; Long name of the group } define service{ use generic-service host_name webserver service_description CHECK USERS check_command check_nrpe!check_users } define service{ use generic-service host_name webserver service_description Load check_command check_nrpe!check_load } define service{ use generic-service host_name webserver service_description Disk check_command check_nrpe!check_xvda1 } define service{ use generic-service host_name webserver service_description Total Processes check_command check_nrpe!check_total_procs } define service{ use generic-service host_name webserver service_description Zombie Processes check_command check_nrpe!check_zombie_procs }

而后编辑nagios配置文件,使用刚才定义的linux.cfg,检查语法正确后重启nagios服务

# vim /etc/nagios/nagios.cfg cfg_file=/etc/nagios/objects/linux.cfg # /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg # service nagios start

这里写图片描述


三、基于NSClinet++监控Windows主机
windows主机安装NSClinet++完成后,默认已经启动服务,12489是check_nt与NSClinet++通信的端口,5666为nrpe监听的端口

这里写图片描述


1、基于check_nt
Windows端要启用的模块,修改配置后要重启服务

[modules] CheckSystem.dll CheckDisk.dll FileLogger.dll NSClientListener.dll [settings] allowed_hosts =

在nagios端使用如下命令测试测试

# /usr/local/nagios/libexec/check_nt -h ##查看帮助信息 check_nt -H <client ip> -p <port> -v <command> ... # check_nt -H 192.168.1.250 -p 12489 -v CPULOAD -w 80 -c 90 -l 5,80,90

定义监控远程Windows主机资源的通用性命令:

# vim /etc/nagios/objects/commands.cfg define command{ command_name check_nt command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s PASSWORD -v $ARG1$ $ARG2$ }

根据实际情况定义远程Windows主机的资源配置文件

# cat /etc/nagios/objects/windows.cfg |grep "^\s*[^#\t].*$" define host{ use windows-server ; Inherit default values from a template host_name winserver ; The name we're giving to this host alias My Windows Server ; A longer name associated with the host address 192.168.1.2 ; IP address of the host } define hostgroup{ hostgroup_name windows-servers ; The name of the hostgroup alias Windows Servers ; Long name of the group } define service{ use generic-service host_name winserver service_description NSClient++ Version check_command check_nt!CLIENTVERSION } define service{ use generic-service host_name winserver service_description Uptime check_command check_nt!UPTIME } define service{ use generic-service host_name winserver service_description CPU Load check_command check_nt!CPULOAD!-l 5,80,90 } define service{ use generic-service host_name winserver service_description Memory Usage check_command check_nt!MEMUSE!-w 80 -c 90 } define service{ use generic-service host_name winserver service_description C:\ Drive Space check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90 } define service{ use generic-service host_name winserver service_description W3SVC check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC } define service{ use generic-service host_name winserver service_description Explorer check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/1ff8509767fee9ab723c78de10f84d7f.html