您好,登錄后才能下訂單哦!
服務器端安裝:
安裝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/nagios–v/usr/local/nagios/etc/nagios.cfg
servicenagios reload
問題總結:
1,Argument "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"操作符
以上這個問題就解決了
2,nagios+pnp讓windows出圖
[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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。