免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5459 | 回复: 4
打印 上一主题 下一主题

门户网站运维监控系列-如何监控Netapp存储设备(diskio) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-29 15:58 |只看该作者 |倒序浏览
Netapp系统的diskio监控(snmp方式)
文章摘自 http://www.centreon.com.cn



[root@SZVSXMON libexec]# ./check_netapp_diskio.pl  -H  SZVSDN01 -C SNMPSTRING
Disk read : 164.05 KB/s , Disk write : 148.84 KB/s |disk_read=167988.738197425Bytes/s disk_write=152413.39055794Bytes/s

插件代码如下:



[root@SZVSXMON libexec]# cat check_netapp_diskio.pl
#!/usr/bin/perl -w
#written by liwei on Oct 10,2008
#mail:  liwei@centreon.com.cn
#website: http://www.centreon.com.cn

use strict;
use Net::SNMP;
use Getopt::Long;

use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS $TIMEOUT);

my $o_host =    undef;          # hostname
my $o_community = undef;        # community
my $o_port =    161;            # port
my $o_warn =    undef;          # warning limit
my $o_crit=     undef;          # critical limit
my $o_timeout= 10;
my $exit_code = undef;
my $o_type=undef;
my $output=undef;
my $o_perf= undef;

my %oids = (
                  'cpuUsage'                      => ".1.3.6.1.4.1.789.1.2.1.3.0",
                  'globalStatus'                  => ".1.3.6.1.4.1.789.1.2.2.4.0",
                  'nfsHighOps'                    => ".1.3.6.1.4.1.789.1.2.2.5.0",
                  'nfsLowOps'                       => ".1.3.6.1.4.1.789.1.2.2.6.0",
                  'cifsHighOps'                   => ".1.3.6.1.4.1.789.1.2.2.7.0",
                  'cifsLowOps'                    => ".1.3.6.1.4.1.789.1.2.2.8.0",
                  'netRecHighBytes'                   => ".1.3.6.1.4.1.789.1.2.2.11.0",
                  'netRecLowBytes'                    => ".1.3.6.1.4.1.789.1.2.2.12.0",
                  'netSentHighBytes'                => ".1.3.6.1.4.1.789.1.2.2.13.0",
                  'netSentLowBytes'                   => ".1.3.6.1.4.1.789.1.2.2.14.0",
                  'diskReadHighBytes'               => ".1.3.6.1.4.1.789.1.2.2.15.0",
                  'diskReadLowBytes'                => ".1.3.6.1.4.1.789.1.2.2.16.0",
                  'diskWriteHighBytes'            => ".1.3.6.1.4.1.789.1.2.2.17.0",
                  'diskWriteLowBytes'               => ".1.3.6.1.4.1.789.1.2.2.18.0",


);


my @oidlist=($oids{diskReadHighBytes},$oids{diskReadLowBytes},$oids{diskWriteHighBytes},$oids{diskWriteLowBytes});

sub check_options {
    Getopt::Long::Configure ("bundling";
    GetOptions(
        'H:s'   => \\$o_host,            'hostname:s'    => \\$o_host,
        'p:i'   => \\$o_port,            'port:i'        => \\$o_port,
        'C:s'   => \\$o_community,       'community:s'   => \\$o_community,
        'c:s'   => \\$o_crit,            'critical:s'    => \\$o_crit,
        'w:s'   => \\$o_warn,            'warn:s'        => \\$o_warn,
#       'T:s'   => \\$o_type,
    );

}

########## MAIN #######

check_options();

# Connect to host
my ($session,$error);
         ($session, $error) = Net::SNMP->session(
                -hostname  => $o_host,
                -community => $o_community,
                -port      => $o_port,
                -timeout   => $o_timeout
          );

if (!defined($session)) {
   printf("ERROR: %s.\\n", $error);
   exit $ERRORS{"UNKNOWN"};
}

my $resultat=undef;
# Get rid of UTF8 translation in case of accentuated caracters (thanks to Dimo Velev).
$session->translate(Net::SNMP->TRANSLATE_NONE);

  if (Net::SNMP->VERSION < 4) {
    $resultat = $session->get_request(@oidlist);
  } else {
    $resultat = $session->get_request(-varbindlist  => \\@oidlist);
  }


if (!defined($resultat)) {
   printf("ERROR: Description/Type table : %s.\\n", $session->error);
   $session->close;
   exit $ERRORS{"UNKNOWN"};
}

$session->close;

my $new_read_bytes;
my $new_write_bytes;
my $left_shift= 2**32;
my $last_read_bytes = 0;
my $last_write_bytes  = 0;
my $row ;
my  $last_check_time ;
my  $update_time;
my @last_values=undef;

my $flg_created = 0;

$new_read_bytes= $$resultat{$oids{diskReadHighBytes}} *  $left_shift  +  $$resultat{$oids{diskReadLowBytes}};
$new_write_bytes= $$resultat{$oids{diskWriteHighBytes}} * $left_shift  +  $$resultat{$oids{diskWriteLowBytes}};

if (-e "/var/lib/centreon/centplugins/traffic_disk_".$o_host) {
    open(FILE,"<"."/var/lib/centreon/centplugins/traffic_disk_".$o_host);
    while($row = <FILE>{
                @last_values = split(":",$row);
                $last_check_time = $last_values[0];
                $last_read_bytes = $last_values[1];
                $last_write_bytes = $last_values[2];
                $flg_created = 1;
    }
    close(FILE);
} else {
    $flg_created = 0;
}

$update_time = time();

unless (open(FILE,">"."/var/lib/centreon/centplugins/traffic_disk_".$o_host)){
    print "Check mod for temporary file : /var/lib/centreon/centplugins/traffic_disk_".$o_host. " !\\n";
    exit $ERRORS{"UNKNOWN"};
}
print FILE "$update_timenew_read_bytesnew_write_bytes";
close(FILE);

if ($flg_created == 0){
    print "First execution : Buffer in creation.... \\n";
    exit($ERRORS{"UNKNOWN"});
}



my $read_diff=$new_read_bytes - $last_read_bytes;
$read_diff=$new_read_bytes if ($read_diff < 0);

my $write_diff=$new_write_bytes - $last_write_bytes;
$write_diff=$new_write_bytes if ($write_diff < 0);

my $time_diff=$update_time - $last_check_time;
$time_diff=$update_time if ($time_diff < 0);

my $read_rate = $read_diff / ( $time_diff );
my $write_rate = $write_diff / ( $time_diff );


printf("Disk read : %.2f KB/s , Disk write : %.2f KB/s ", $read_rate/1024, $write_rate/1024);
printf("|disk_read=".$read_rate."Bytes/s disk_write=".$write_rate."Bytes/s\\n";

[ 本帖最后由 cnweili 于 2008-12-29 16:00 编辑 ]

netapp_diskio.PNG (31.76 KB, 下载次数: 121)

netapp_diskio

netapp_diskio

论坛徽章:
0
2 [报告]
发表于 2008-12-29 17:09 |只看该作者
无所不能的nagios!!很好很强大!!

论坛徽章:
0
3 [报告]
发表于 2008-12-30 10:36 |只看该作者
好的. 收藏

论坛徽章:
0
4 [报告]
发表于 2008-12-31 16:50 |只看该作者
netapp ,好有钱哦。就去移动的IDC看到过。

论坛徽章:
0
5 [报告]
发表于 2009-01-15 20:59 |只看该作者
很好很强大
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP