Nagios之linux监控windows主机

发布时间:2020-06-17 02:03:24 作者:chengcai
来源:网络 阅读:1108

服务器端安装:

安装snmp服务和其他插件服务:

[root@nagios~]# yum -y install net-snmp* #安装snmp服务。

CPAN安装:

wgetftp://ftp.monash.edu/pub/cpan/modules/by-category/23_Miscellaneous_Modules/CPAN/CPAN-1.9301.tar.gz

tar-zxf CPAN-1.9301.tar.gz

cdCPAN-1.9301

./configure

make

makeinstall

##该环境必须安装,在下面编译nagios-snmp-plugins时会用到。

安装完成后执行下列操作:

[root@nagioslibexec]# perl -MCPAN -e shell

Terminaldoes not support AddHistory.

cpanshell -- CPAN exploration and modules installation (v1.9301)

ReadLinesupport available (maybe install Bundle::CPAN or Bundle::CPANxxl?)

cpan[1]>install Net::SNMP

#安装相应的组件,上面是使用install方式进行安装,如果这种安装方式不成功,那么就需要使用下面的编译方式安装了。

nagios官方有详细介绍:

1)By CPAN (best)

oncommand line, as root :
[your_host]# perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.76)
ReadLine support enabled
cpan> install Net::SNMP

Ifit's the first time you run CPAN, it will probably ask you some (simple)questions.

CPANwill also ask you to satisfy some dependencies (Crypt::DES, Digest::MD5,etc..).

2)"By hand"

Getthe folowings modules (tar.gz format) on www.cpan.org #在cpan官网搜索下面的组件,下载安装。

-Crypt::DES
- Digest::MD5
- Digest::SHA1
- Digest::HMAC
- Net::SNMP

for each one (you must install Net::SNMP at the end) :
tar zxf <module>.tar.gz
cd <module>
perl Makefile.pl
make test
make install

#确保以上相关CPAN的组件全部安装成功。



安装nagios-snmp-plugins:

wgethttp://nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz

tarzxfv nagios-snmp-plugins.1.1.1.tgz

#解压后,进入解压后的目录

cdnagios_plugins
./install.sh

#根据提示,基本上都回车,安装。默认就会安装到/usr/local/nagios/libexec下面。可以通过ls查看,多了很多关于snmp的文件。

[root@nagios~]# ll /usr/local/nagios/libexec/|grep snmp

-rwxr-xr-x1 nagios nagios 408559 Aug 24 15:44 check_snmp

-rwxr-xr-x1 root root 10951 Aug 29 16:23 check_snmp_boostedge.pl

-rwxr-xr-x1 root root 17866 Aug 29 16:23 check_snmp_cpfw.pl

-rwxr-xr-x1 root root 16786 Aug 29 16:23 check_snmp_css.pl

-rwxr-xr-x1 root root 8747 Aug 29 16:23 check_snmp_css_main.pl

-rwxr-xr-x1 root root 33562 Aug 29 16:23 check_snmp_env.pl

-rwxr-xr-x1 root root 136373 Aug 29 12:09 check_snmp_int

-rwxr-xr-x1 root root 31919 Aug 29 16:23 check_snmp_int.pl

-rwxr-xr-x1 root root 10108 Aug 29 16:23 check_snmp_linkproof_nhr.pl

-rwxr-xr-x1 root root 22966 Aug 29 17:31 check_snmp_load.pl

-rwxr-xr-x1 root root 18735 Sep 2 21:10 check_snmp_mem.pl

-rwxr-xr-x1 root root 11898 Aug 29 16:23 check_snmp_nsbox.pl

-rwxr-xr-x1 root root 130702 Aug 29 12:09 check_snmp_process

-rwxr-xr-x1 root root 24233 Aug 29 16:23 check_snmp_process.pl

-rwxr-xr-x1 root root 146461 Aug 29 12:09 check_snmp_storage

-rwxr-xr-x1 root root 24006 Aug 29 17:10 check_snmp_storage.pl

-rwxr-xr-x1 root root 14489 Aug 29 16:23 check_snmp_vrrp.pl

-rwxr-xr-x1 root root 11967 Aug 29 16:23 check_snmp_win.pl

进行命令检查:

[root@nagios~]# /usr/local/nagios/libexec/check_snmp_load.pl -H 10.168.0.185 -C 168pop -Tstand -w 80 -c 90 ##检查被监控端的CPU负载

2CPU, average load 0.0% < 80% : OK

[root@nagios~]# /usr/local/nagios/libexec/check_snmp_storage.pl -H 10.168.0.185 -C 168pop-m "^Virtual Memory$" -w 70 -c 90 ##检查虚拟内存使用量

VirtualMemory: 13%used(1551MB/12285MB) (<70%) : OK

添加环境变量

[root@localhostlibexec]#vi /usr/local/nagios/etc/resource.cfg

$USER7$=-C168pop

$USER8$=-Tstand

打开windows主机配置文件:

[root@nagiosetc]# vi nagios.cfg

##############################################################################

#

#NAGIOS.CFG - Sample Main Config File for Nagios 3.2.0

#

#Read the documentation for more information on this configuration

#file. I've provided some comments here,but things may not be so

#clear without further explanation.

#Last Modified: 12-14-2008

##############################################################################

#Definitions for monitoring a Windows machine

cfg_file=/usr/local/nagios/etc/objects/windows.cfg


以下为实际环境中nagios服务中监控windows的操作:

首先更改命令模板:

[root@nagiosobjects]# cat commands.cfg

###############################################################################

#COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS 3.2.0

#

#Last Modified: 05-31-2007

#

#NOTES: This config file provides you with some example command definitions

# that you can reference in host,service, and contact definitions.

#

# You don't need to keep commands in aseparate file from your other

# object definitions. This has been done just to make things easierto

# understand.

#


#process-host-perfdatacommand definition

definecommand {

command_name process-host-perfdata

command_line /usr/local/nagios/libexec/process_perfdata.pl

}

#process-service-perfdatacommand definiton

definecommand {

command_name process-service-perfdata

command_line /usr/local/nagios/libexec/process_perfdata.pl

}

#check_nrpecommand definition

definecommand {

command_name check_nrpe

command_line $USER1$/check_nrpe -H $HOSTADDRESS$-c $ARG1$

}


definecommand {

command_name check_weburl

command_line $USER1$/check_http $ARG1$ -w 10 -c 30

}

#check_snmp_stor"command definition

define command {

command_name check_snmp_stor

command_line $USER1$/check_snmp_storage.pl -H$HOSTADDRESS$ $USER7$ -m $ARG1$ -w $ARG2$ -c $ARG3$ -f

}

#"check_snmp_proc" command definition

define command {

command_name check_snmp_proc

command_line $USER1$/check_snmp_process.pl -H$HOSTADDRESS$ $USER7$ $ARG1$ $ARG2$ -f

}

#"check_snmp_load" command definition

define command {

command_name check_snmp_load

command_line $USER1$/check_snmp_load.pl -H$HOSTADDRESS$ $USER7$ $USER8$ -w $ARG1$ -c $ARG2$ -f

}


define command {

command_name check_traf

command_line $USER1$/check_traffic.sh -V 2c -H$HOSTADDRESS$ $USER7$ -I 1 -w 990,1000 -c 1000,1024 -M -b

}

然后更改windows主机服务文件:

[root@nagiosobjects]# cat windows.cfg

###############################################################################

#WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE

#

#Last Modified: 06-13-2007

#

#NOTES: This config file assumes that you are using the sample configuration

# files that get installed with theNagios quickstart guide.

#

###############################################################################

###############################################################################

#

#SERVICE DEFINITIONS

#

###############################################################################

###############################################################################


#Create a service for monitoring CPU load

#Change the host_name to match the name of the host you defined above

#检查CPU负载

defineservice{

use generic-service

hostgroup_name windows-servers

service_description CPU Load

check_command check_snmp_load!60!80

action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$

}

#Create a service for monitoring memory usage

#Change the host_name to match the name of the host you defined above

#检查物理内存使用率

defineservice{

use generic-service

hostgroup_name windows-servers

service_description Memory Usage

check_command check_snmp_stor!"^PhysicalMemory$"!80!90

action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$

}

#Create a service for monitoring C:\ disk usage

#Change the host_name to match the name of the host you defined above

#检查C盘磁盘利用率

defineservice{

use generic-service

hostgroup_name windows-servers

service_description C:\ Drive Space

check_command check_snmp_stor!"^C"!90!95

action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$

}

#Create a service for monitoring the Explorer.exe process

#Change the host_name to match the name of the host you defined above

#检查虚拟内存使用率

defineservice{

use generic-service

hostgroup_name windows-servers

service_description ram_swap

check_command check_snmp_stor!"^VirtualMemory$"!60!80

}

配置完成后进行配置文件检查并重启服务:

/usr/local/nagios/bin/nagiosv/usr/local/nagios/etc/nagios.cfg

servicenagios reload



问题总结:


1Argument "v6.0.1" isn't numeric in numeric lt (<)

关于:
Argument "v6.0.1" isn't numeric in numeric lt (<) at/usr/local/nagios/libexec/check_snmp_storage.pl line 407.

出自http://bbs.chinaunix.net/thread-3686728-1-1.html这个报错;
我在/usr/local/nagios/libexec/check_snmp_storage.pl
文件中的407行做了修改将 "<"操作符替换为"lt"操作符,如果是">"那么也应当替换为"gt"操作符
Nagios之linux监控windows主机
以上这个问题就解决了

2nagios+pnpwindows出图

[root@core_07libexec]# ./check_snmp_mem.pl -H 127.0.0.1 -C itnms -w 20,30 -c80,90
Ram : 64%, Swap : 0% : > 20, 30 ; WARNING
[root@core_07 libexec]# ./check_snmp_mem.pl -H 127.0.0.1 -C itnms -w20,30 -c 80,90 -f #加个-f就有数据了,也就出图了。
Ram : 64%, Swap : 0% : > 20, 30 ; WARNING |ram_used=5262032;1633629;6534515;0;8168144swap_used=3728;4915888;14747663;0;16386292


推荐阅读:
  1. Linux监控软件之 Nagios
  2. Nagios利用NSClient++监控Windows主机

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

nagios linux监控 windows主机

上一篇:Netscreen基础配置

下一篇:Oracle Study之--查看Oracle 版本运算字长(32/64位)方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》