作为一个资深的打酱油工作者,需要偶尔展现下自己的水平,好让领导不认为你是空气, 当然,更重要的是:打好酱油!


背景:公司使用Netapp v3240 NAS存储提供CIFS共享,Qtree给应用系统作为附件存储。

     一天,某应用系统突然附件无法上传,排查后发现是Quota满了,然后紧急扩了下容量,就恢复了,这件事情上层领导不太满意,因为是用户报的故障给我们运维,运维事先并未及时发现。为了避免以后这类事情再发生,领导提出需要一个方案,监控Qtree使用率,并及时报警,好吧,我自报奋勇一下吧。


使用Nagios监控:

   公司已经有nagios监控软件了,我们都知道nagios非常强大,监控插件非常多,你几乎不用自己写监控插件,去nagios exchange网站上搜索就可以了。

   nagios exchange网站:http://exchange.nagios.org ,找星级高的插件下载。


   我下载的是这个插件:http://exchange.nagios.org/directory/Plugins/Hardware/Storage-Systems/SAN-and-NAS/NetApp/check_netapp-2Ddu/details


   阅读一下上面页面的英文说明,可以知道这个插件可以做什么,怎样去使用,以及注意事项。


   下载下来一共4个文件:

File

Description

check_netapp-du

Plugin code(源码)

netapp-shares.map

Share to volume mapping file(卷映射文件,我没用)

netapp-gencache

Cache generation (缓存文件)

NETWORK-APPLIANCE-MIB.txt

NetApp MIBs (Netapp MIB库)

   简单解释下插件的说明文档:

A very fast SNMP based disk space checker for NetApp NAS filers, which supports both Volumes and QTrees, also over 2TB.

一个基于SNMP协议的netapp NAS存储磁盘空间检测插件,支持Volume和Qtree,超过2TB也支持


This is a disk space checker for NetApp filers, based on an older plugin by Rob Hassing. The plugin interrogates the NAS via SNMP and supports both Volumes and subdirectories with user quota aka QTrees, also ones larger than 2TB.

介绍下插件之前的作者,插件查询使用SNMP协议,支持Volume和子目录的用户quota配额(又叫做Qtrees).


The plugin uses a map file (netapp-shares.map) and some basic heuristics to translate Windows share names to volume/Qtree names (CIFS share names are not exposed via SNMP).

插件使用一个映射文件,和一些基本的方法将windows共享名转换到volume/Qtree名,(CIFS共享名不能直接通过SNMP来查询)

###这个意思我猜是:如果想监控\\share.company.com\share1这样的共享文件夹,需要使用这个文件netapp-shares.map。###


Usage: 使用方法:

check_netapp-du -H host -v volume [-C community] -w warnpct -c critpct [--force-gencache] [--debug] 
check_netapp-du -H 主机名/IP -v 卷名/Qtree名 [-C 共同体名] -w 警告值 -c 严重值 [--force-gencache] [--debug] ##--force-gencache是更新缓存,--debug是启动debug模式。


For performance reasons, the SNMP Volume and QTree IDs are looked up from a local cache file rather than retrieved from the NetApp filer every time. It will be necessary to regenerate this cache regularly, as volumes are added or changed on the NAS.

一些性能原因,SNMP 卷和qtree ids是从本地缓存文件中查询的,从而不用每次都去netapp存储里去现查。所以,当NAS上有新卷被添加或者更改,必须重新生成缓存文件。


Since the running time of this cache generation may be too long for Nagios (depending on the global service check time-out), it is recommended to do this only from an interactive shell or a cron job. Run a check on any volume adding the "-–force-gencache" parameter to regenerate the volume ID cache. A sample script is provided which can be run from cron, provided you are running Opsview, and provided all NetApp filers are in the same host group.

建议使用一个crontab,定期更新缓存文件。


监控步骤:

1.check_netapp-du放在nagios的libexec插件目录,权限什么的我就不说了。

2.less check_netapp-du,可以看到以下内容:

$PROGNAME = "check_netapp-du";
$REVISION = "2.1b";
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}=''; 
$ENV{'ENV'}='';

# Path to manual CIFS to volume/qtree map file
my $MAPFILE = "/data/scripts/nagios/NAS/netapp-shares.map";

# Path to NetApp MIB table (get it from http://www.protocolsoftware.com/documents/mibs/netapp.mib.txt)
my $MIBFILE = "/usr/share/snmp/mibs/NETWORK-APPLIANCE-MIB.txt";

# Path to locaiton of cache files
my $CACHEPATH = "/data/scripts/nagios/NAS";

3.目录创建下,MIB库到自己该去的位子,

4.下面配置netapp存储的SNMP:

mkdir -p /data/scripts/nagios/NAS;cp NETWORK-APPLIANCE-MIB.txt /usr/share/snmp/mibs/

   先看下已有的Qtree,选一个等会测试:

nas 存储 zabbix监控 nas存储监控视频_ios

   配置SNMP:

nas 存储 zabbix监控 nas存储监控视频_操作系统_02


5.测试下,看能不能得到想要的结果:

nas 存储 zabbix监控 nas存储监控视频_nas 存储 zabbix监控_03

   成功了,看下百分比4.68%,和上面在netapp管理工具里看到的一样吧。

   这个命令第一次成功执行后,会生成这个缓存文件,下次再执行SNMP查询,会先去这个缓存文件里取Qtree对应的oid,再来用oid去通过该snmp查询信息,oid可以理解为共享名对应的一个数字唯一标示符:    

[v_nashengzhi@BJS0-0TH libexec]$ ls -al /data/scripts/nagios/NAS/
total 12
drwxr-xr-x 2 nagios nagios 4096 Sep 13 10:08 .
drwxr-xr-x 3 nagios nagios 4096 Aug  9 15:32 ..
-rw-r--r-- 1 nagios nagios 1160 Sep 13 10:08 .netapp-oidcache.10.199.94.11

nas 存储 zabbix监控 nas存储监控视频_操作系统_04


6.如果netapp nas上有新加的Qtree共享文件夹,那么缓存文件里还没有这个oid,缓存文件不是实时更新,是触发更新,需要执行这个命令(或者自己写个crontab):

   [v_nashengzhi@BJS0-0TH libexec]$ sudo ./check_netapp-du -H 10.199.94.11 -v cljgshare -w 75 -c 90 --force-gencache

   随便进行1次查询,并强制更新缓存文件。


   7.好了,到此基本就监控完成了,监控的本质还是SNMP,只要设备支持SNMP,我们得到MIB库以后,对MIB库里已经定义好了的对象实施监控,我这只是介绍下监控脚本,因为我发现博客里很少有通过nagios监控存储设备的,都是监控一些网络设备居多。

   剩下的工作就是把要监控的目录加到nagios的服务项目里,来看看最后的监控结果:

   

nas 存储 zabbix监控 nas存储监控视频_运维_05


nas 存储 zabbix监控 nas存储监控视频_ios_06

8.看看插件还支持哪些参数:

[v_nashengzhi@BJS0-0TH libexec]$ sudo ./check_netapp-du --help
Password:
Sorry, try again.
Password:
check_netapp-du v2.1b (nagios-plugins 1.4.15)
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Copyright (c) 2009 Rob Hassing, 2012 Peter Mc Aulay

This plugin reports the usage of a Netapp Storage volume

Usage: check_netapp-du -H <host> -v <volume> [-C community] -w <warn> -c <crit> [--force-gencach

-H, --hostname=HOST
   Name or IP address of host to check
-v, --volume=Volume
   Name of the volume to check
-C, --community=community
   SNMP read community (default public)
-w, --warning=X
   Percentage above which a WARNING status will result
-c, --critical=X
   Percentage above which a CRITICAL status will result
--force-gencache
   Force cache file generation (slow, don't use from Nagios)
--debug
   Show lots of debug messages
-V, --version
   Display program version



转载于:https://blog.51cto.com/blankspace/1296353