设为首页 收藏本站
查看: 756|回复: 0

Nagios的NSClient++插件配置

[复制链接]

尚未签到

发表于 2019-1-14 08:51:04 | 显示全部楼层 |阅读模式
NSClinet++监控Windows主机的nagios插件
下载地址:https://nsclient.org/nscp/downloads
下载NSClient++-xxx-Win32
我们这里下载的是NSClient++-0.3.9-Win32.msi


安装NSClient++
双击程序安装,前面都点下一步,从下面可以看出来NSClient集成了很多的插件NRPE、NSCA等都支持

添加允许主机

下面没什么需要注意的了,直接下一步,安装完成就可以了。

服务开启以后可以看到服务端的端口开启了,NSClient++使用的是12489端口,而且我们也看到nrpe的端口也开启了





1、基于check_nt
Windows端安装目录下NSC.ini配置文件的要启用的模块:
[modules]
CheckSystem.dll
CheckDisk.dll
FileLogger.dll
NSClientListener.dll


[settings]
allowed_hosts = #允许的主机
Password=   #密码
修改配置后要重启服务:


nsclient++ /stop
nsclient++ /start






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


check_nt -H  -p -s  -v  ...


# check_nt -H 172.16.100.66 -p 12489 -v CPULOAD -w 80 -c 90 -l5,80,90-s redhat


[root@node4 ~]# cd/usr/local/nagios/libexec/
[root@node4 libexec]#./check_nt -H 192.168.0.5 -p 12489 -v CPULOAD -w 80 -c 90 -l 5,80,90 -s redhat
CPU Load 0% (5 minaverage) |   '5 min avgLoad'=0%;80;90;0;100






nagios端配置:



首先是命令配置:
[root@node4 ~]# cd/usr/local/nagios/etc/objects/
[root@node4 objects]#vim commands.cfg
define command{
command_name    check_nt
command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489-s redhat -v $ARG1$ $ARG2$
}
然后是主机配置:
# vim/usr/local/nagios/etc/objects/windows.cfg
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.0.5     ; IP address of the host
}
###############################################################################
###############################################################################
#
# HOST GROUPDEFINITIONS
#
###############################################################################
###############################################################################
# Define a hostgroupfor Windows machines
# All hosts that usethe windows-server template will automatically be a member of this group
define hostgroup{
hostgroup_name  windows-servers ; The name of the hostgroup
alias           Windows Servers ; Long name of thegroup
}
###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################
# Create a servicefor monitoring the version of NSCLient++ that is installed
# Change thehost_name to match the name of the host you defined above
define service{
use                     generic-service
host_name               winserver
service_description     NSClient++ Version
check_command           check_nt!CLIENTVERSION
}
# Create a servicefor monitoring the uptime of the server
# Change thehost_name to match the name of the host you defined above
define service{
use                     generic-service
host_name               winserver
service_description     Uptime
check_command           check_nt!UPTIME
}
# Create a servicefor monitoring CPU load
# Change thehost_name to match the name of the host you defined above
define service{
use                     generic-service
host_name               winserver
service_description     CPU Load
check_command           check_nt!CPULOAD!-l 5,80,90
}
# Create a servicefor monitoring memory usage
# Change thehost_name to match the name of the host you defined above
define service{
use                     generic-service
host_name               winserver
service_description     Memory Usage
check_command           check_nt!MEMUSE!-w 80 -c 90
}
# Create a servicefor monitoring C:\ disk usage
# Change thehost_name to match the name of the host you defined above
define service{
use                     generic-service
host_name               winserver
service_description     C:\ Drive Space
check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c90
}
# Create a servicefor monitoring the W3SVC service
# Change thehost_name to match the name of the host you defined above
define service{
use                     generic-service
host_name               winserver
service_description     W3SVC
check_command           check_nt!SERVICESTATE!-d SHOWALL -lW3SVC
}
# Create a servicefor monitoring the Explorer.exe process
# Change thehost_name to match the name of the host you defined above
define service{
use                     generic-service
host_name               winserver
service_description     Explorer
check_command           check_nt!PROCSTATE!-d SHOWALL -lExplorer.exe
}
在nagios配置文件内添加一条cfg
[root@node4 objects]# vim/usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
做完上述的操作以后重启nagios服务端的nagios服务
[root@node4 objects]#service nagios restart
Running configurationcheck...done.
Stopping nagios: done.
Starting nagios: done.

然后在nagios的web管理界面上你就会发现一个新的主机

而且服务里面也多出很多我们定义的服务



密码保护:
如果你在windows的机器上设置了密码,你需要在commands.cfg配置文档内加上-s PASSWORD如下:
vi/usr/local/nagios/etc/objects/commands.cfg
define command{
command_name        check_nt
command_line        $USER1$/check_nt-H $HOSTADDRESS$ -p 12489 -s PASSWORD -v $ARG1$$ARG2$
}


Save the file.




2、基于NRPE


Windows上NSClient++要启用如下模块:
[modules]
CheckSystem.dll
CheckDisk.dll
CheckExternalScripts.dll
FileLogger.dll
NRPEListener.dll


NRPE specific settingin NSClient++
use_ssl  #使用ssl
allow_arguments  #是否允许nagios服务端传递参数过来
allow_nasty_meta_chars # 传递参数的时候是否可以包含一些&等字符
bind_to_address=  #绑定在那个地址上,默认监听在0.0.0.0
            allowed_hosts= #允许主机


check_nrpe语法:
check_nrpe ... -c [-a   ]




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 -a warn=80 crit=90 time=20m time=10s time=4








Nagios端的配置:


1) Template


define host{
nametpl-windows-servers
usegeneric-host
check_period24x7
check_interval5
retry_interval1
max_check_attempts10
check_commandcheck-host-alive
notification_period24x7
notification_interval30
notification_optionsd,r
contact_groupsadmins
register0
}


2) 定义主机:
define host{
usetpl-windows-servers
host_namewindowshost
aliasMy First Windows Server
address172.16.100.66
}


3) 定义服务:


define service{
usegeneric-service
host_namewindowshost
service_descriptionCPU Load
check_commandcheck_nrpe!alias_cpu
}


define service{
usegeneric-service
host_namewindowshost
service_descriptionFree Space
check_commandcheck_nrpe!alias_disk
}




3、基于NSCA


[modules]
CheckSystem.dll
CheckDisk.dll
CheckExternalScripts.dll
CheckHelpers.dll
FileLogger.dll
NSCAAgent.dll


NSClient++配置


interval
encryption_method
password
nsca_host


修改配置后要重启服务








1) 模板
define host{
nametpl-windows-servers ; Name of this template
usegeneric-host ; Inherit default values
check_period24x7
check_interval5
retry_interval1
max_check_attempts10
check_commandcheck-host-alive
notification_period24x7
notification_interval30
notification_optionsd,r
contact_groupsadmins
register0 ; DONT REGISTER THIS - ITS A TEMPLATE
}


2)主机配置
define host{
usetpl-windows-servers
host_namewindowshost
aliasMy First Windows Server
address172.16.100.66
active_checks_enabled0
passive_checks_enabled1
}


3)服务配置


define service{
usegeneric-service
host_namewindowshost
service_descriptionCPU Load
check_commandcheck_nrpe!alias_cpu
active_checks_enabled0
passive_checks_enabled1
}


define service{
usegeneric-service
host_namewindowshost
service_descriptionFree Space
check_commandcheck_nrpe!alias_disk
active_checks_enabled0
passive_checks_enabled1
}  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-662992-1-1.html 上篇帖子: Nagios的NRPE插件配置 下篇帖子: Nagios添加服务监控
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表