centreon已定义了非常多常用的snmp命令,对一些服务器若是不想安装nsclient++插件的,可以使用snmp协议。
centreon已定义snmp命令:
/usr/local/nagios/libexec [root@centreon libexec]# ls check_centreon_* check_centreon_dummy check_centreon_snmp_multiple_process check_centreon_snmp_TcpConn check_centreon_MS_multiple_services check_centreon_snmp_packetErrors check_centreon_snmp_traffic check_centreon_ping check_centreon_snmp_process check_centreon_snmp_uptime check_centreon_snmp_cpu check_centreon_snmp_process_detailed check_centreon_snmp_value check_centreon_snmp_loadaverage check_centreon_snmp_remote_storage check_centreon_snmp_value_table.pl check_centreon_snmp_memory check_centreon_snmp_string
一般的监控基本上可以满足
windows安装snmp并设置:
在安全中添加public只读,以及填写centreon所在的服务器IP地址。
Linux安装snmp并设置:
[root@centreon libexec]# rpm -qa | grep snmp
net-snmp-libs-5.5-49.el6_5.1.x86_64
net-snmp-perl-5.5-49.el6_5.1.x86_64
net-snmp-utils-5.5-49.el6_5.1.x86_64
net-snmp-5.5-49.el6_5.1.x86_64
php-snmp-5.3.3-27.el6_5.x86_64
设置如下:
[root@centreon log]# cat /etc/snmp/snmpd.conf | grep -v ‘^#‘|sed /^$/d
com2sec notConfigUser 127.0.0.1 public
com2sec notConfigUser 192.168.198.250 public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact all none none
view all included .1 80
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
dontLogTCPWrappersConnects yes
以check_centreon_snmp_remote_storage为例:
[root@centreon libexec]# ./check_centreon_snmp_remote_storage --help ############################################## # Copyright (c) 2004-2013 Centreon # # Bugs to http://forge.centreon.com/ # ############################################## Usage: ./check_centreon_snmp_remote_storage -H (--hostname) Hostname to query (required) -C (--community) SNMP read community (defaults to public) used with SNMP v1 and v2c -v (--snmp-version) 1 for SNMP v1 (default) 2 for SNMP v2c 3 for SNMP v3 -P (--snmp-port) SNMP port (default: 161) -k (--authkey) snmp V3 key -u (--username) snmp V3 username -p (--password) snmp V3 password --authprotocol protocol MD5/SHA (v3) --privprotocol encryption system (DES/AES)(v3) --privpassword passphrase (v3) --64-bits Use 64 bits OID --maxrepetitions To use when you have the error: ‘Message size exceeded buffer maxMsgSize‘ Work only with SNMP v2c and v3 (Example: --maxrepetitions=1) --snmp-timeout SNMP Timeout -d (--disk) Set the disk (number expected) ex: 1, 2,... (default: 2 ) -n (--name) Allows to use disk name with option -d instead of disk oid index (ex: -d "C:" -n, -d "E:" -n, -d "Swap Memory" -n, -d "Real Memory" -n (choose an unique expression for each disk) -s (--show) Lists all disks (debug mode) -w (--warn) Minimum fill level at which a warning message will be generated (default 80) By using the optional suffixes MB/GB the argument is interpreted as absolute size and it becomes a threshold for free space. (ex. 100MB; 3GB) -c (--crit) Minimum fill level at which a critical message will be generated (default 95) By using the optional suffixes MB/GB the argument is interpreted as absolute size and it becomes a threshold for free space. (ex. 50MB; 1GB) ex.: -w 1GB -c 256MB generates a warning when free space reaches 1GB and critical when there are less than 256MB left -V (--version) Plugin version -L add Windows drive label to output -M Shows the size in output in MB instead of GB -t To use for AIX or AS/400 (ex. ‘AIX‘ or ‘AS/400‘) -a (--cache) Updates cache file every n hours instead of doing snmpwalk for every check (default: 3) -h (--help) usage help
查看这198.1这台window主机的所以存储设备
[root@centreon libexec]# ./check_centreon_snmp_remote_storage -H 192.168.198.1 -s hrStorage 1 :: C:\ Label: Serial Number 9067daf7 hrStorage 2 :: D:\ Label: Serial Number 82944 hrStorage 3 :: E:\ Label: Serial Number ab609 hrStorage 4 :: F:\ Label: Serial Number 8c504 hrStorage 5 :: G:\ Label: Serial Number e0aa9 hrStorage 6 :: H:hrStorage 7 :: I:hrStorage 8 :: Virtual Memory hrStorage 9 :: Physical Memory
[root@centreon libexec]# ./check_centreon_snmp_remote_storage -H 192.168.198.1 -n -d "C:" -w 80 -c 90 -v 2 -C public Disk WARNING - C: TOTAL: 50.000GB USED: 41.674GB (83%) FREE: 8.326GB (17%)|size=53687091200B used=44747120640B;42949672960;48318382080;0;53687091200
注意:里面的盘符需要大写:C
centreon里面的设置如下:
检测命令定义之后,可以定义服务模板,这个模板可以给主机模板引用。
主机模板中的关系中可以引用服务,这样常用的模板可以把一些常用的监控添加来。
本文出自 “尽管错,让我错到死!” 博客,请务必保留此出处http://hxw168.blog.51cto.com/8718136/1388191
【5】nagios从零学习使用 - centreon使用check_centreon_命令,布布扣,bubuko.com