服務(wù)器端安裝:
專(zhuān)注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)柏鄉(xiāng)免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千多家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
安裝snmp服務(wù)和其他插件服務(wù):
[root@nagios~]# yum -y install net-snmp* #安裝snmp服務(wù)。
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
##該環(huán)境必須安裝,在下面編譯nagios-snmp-plugins時(shí)會(huì)用到。
安裝完成后執(zhí)行下列操作:
[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
#安裝相應(yīng)的組件,上面是使用install方式進(jìn)行安裝,如果這種安裝方式不成功,那么就需要使用下面的編譯方式安裝了。
nagios官方有詳細(xì)介紹:
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) onwww.cpan.org #在cpan官網(wǎng)搜索下面的組件,下載安裝。
-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
#確保以上相關(guān)CPAN的組件全部安裝成功。
安裝nagios-snmp-plugins:
wgethttp://nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz
tarzxfv nagios-snmp-plugins.1.1.1.tgz
#解壓后,進(jìn)入解壓后的目錄
cdnagios_plugins
./install.sh
#根據(jù)提示,基本上都回車(chē),安裝。默認(rèn)就會(huì)安裝到/usr/local/nagios/libexec下面。可以通過(guò)ls查看,多了很多關(guān)于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
進(jìn)行命令檢查:
[root@nagios~]# /usr/local/nagios/libexec/check_snmp_load.pl -H 10.168.0.185 -C 168pop -Tstand -w 80 -c 90 ##檢查被監(jiān)控端的CPU負(fù)載
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 ##檢查虛擬內(nèi)存使用量
VirtualMemory: 13%used(1551MB/12285MB) (<70%) : OK
添加環(huán)境變量
[root@localhostlibexec]#vi /usr/local/nagios/etc/resource.cfg
$USER7$=-C168pop
$USER8$=-Tstand
打開(kāi)windows主機(jī)配置文件:
[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
以下為實(shí)際環(huán)境中nagios服務(wù)中監(jiān)控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主機(jī)服務(wù)文件:
[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負(fù)載
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
#檢查物理內(nèi)存使用率
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盤(pán)磁盤(pán)利用率
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
#檢查虛擬內(nèi)存使用率
defineservice{
use generic-service
hostgroup_name windows-servers
service_description ram_swap
check_command check_snmp_stor!"^VirtualMemory$"!60!80
}
配置完成后進(jìn)行配置文件檢查并重啟服務(wù):
/usr/local/nagios/bin/nagios–v/usr/local/nagios/etc/nagios.cfg
servicenagios reload
問(wèn)題總結(jié):
1,Argument "v6.0.1" isn't numeric in numeric lt (<)
關(guān)于:
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這個(gè)報(bào)錯(cuò);
我在/usr/local/nagios/libexec/check_snmp_storage.pl
文件中的407行做了修改將 "<"操作符替換為"lt"操作符,如果是">"那么也應(yīng)當(dāng)替換為"gt"操作符以上這個(gè)問(wèn)題就解決了
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 #加個(gè)-f就有數(shù)據(jù)了,也就出圖了。
Ram : 64%, Swap : 0% : > 20, 30 ; WARNING |ram_used=5262032;1633629;6534515;0;8168144swap_used=3728;4915888;14747663;0;16386292
本文題目:Nagios之linux監(jiān)控windows主機(jī)
URL鏈接:http://jinyejixie.com/article12/ghocgc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、網(wǎng)站設(shè)計(jì)公司、商城網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)、虛擬主機(jī)、用戶(hù)體驗(yàn)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)