利用Nagios监控Windows服务器CPU操纵率(SNMP方法)[网络技术]
本文“利用Nagios监控Windows服务器CPU操纵率(SNMP方法)[网络技术]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
监控WIndows服务器相关性能,倡议采取SNMP方法,但是配置对比麻烦.假定采取NSCLIENT++插件会越发便利,前提是需求在具体被监控服务器上安装插件.万一影响了服务器本身的利用程序就不太好了.所以,我一向在探求监控Windows服务器的SNMP方法.
1、增添脚本以下:
cat /usr/lib/nagios/plugins/check_snmp_win_cpuload.pl
#!/usr/bin/perl
#
# syntax: check_win_snmp_cpuload.pl HOST COMMUNITY WARN CRIT
#
# returns average load % across all CPUs
#
use strict;
use Net::SNMP;
my $host = shift;
my $community = shift;
my $warn = shift;
my $crit = shift;
unless($crit) {
errorExit("syntax: check_win_snmp_cpu.pl HOST COMMUNITY WARN CRIT");
}
our %ERRORS = (
OK => 0,
WARNING => 1,
CRITICAL => 2,
UNKNOWN => 3,
DEPENDENT => 4
);
my $oidCpuTable='.1.3.6.1.2.1.25.3.3.1.2';
# get SNMP session object
my ($snmp, $err) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => 161,
-version => 1
);
errorExit( $err ) unless (defined($snmp));
# get cpu load table
my $response = $snmp->get_table(
-ba搜索引擎优化id => $oidCpuTable
);
errorExit( "error getting cpu table" ) unless $response;
my %value = %{$response};
$snmp->close();
my $cnt = 0;
my $sum = 0;
foreach my $load ( values %value ){
$cnt += 1;
$sum += $load;
};
my $pct = int ($sum / $cnt);
my $err = ($pct > $crit) ? 'CRITICAL' : ($pct > $warn) ? 'WARNING' : 'OK';
print "$err : CPU Load $pct%\n";
exit $ERRORS{$err};
sub errorExit {
my $msg = shift;
print "UNKNOWN: $msg\n";
exit $ERRORS{UNKNOWN};
}
2、定义呼应的履行号令:
cat mysnmp.cfg
define command{
command_name snmp_win_cpu
command_line /usr/lib/nagios/plugins/check_snmp_win_cpuload.pl '$HOS
TADDRESS$' public 80 90
}
3、新建服务配置文件:
cat service.cfg
define service {
host_name jw-inside
service_description CPU
check_command snmp_win_cpu
use generic-service
}
4、新建主机文件:
define host {
host_name jw-inside
alias jw-inside
address 10.10.10.11
use generic-host
icon_image vendors/windowsxp.png
icon_image_alt jw-inside-server
vrml_image vendors/windowsxp.png
statusmap_image vendors/windowsxp.png
}
其实熟习nagios配置的人,只需求步骤1中的脚本便可以.我就不上图片了
以上是“利用Nagios监控Windows服务器CPU操纵率(SNMP方法)[网络技术]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |