以CentOS 6.3为例
1. 首先到vmware官网下载 perl 的 SDK VMware-vSphere-Perl-SDK-5.1.0-780721.x86_64.tar.gz
在安装sdk时,安装脚本使用cpan安装perl模块,会有一些perl模块安装不上,这些安装不上的模块,得手动使用cpan去安装,若还安装不上那么就用yum去安装,例如 UUID,yum install -y perl-UUID, 有时因为网络的连通状况,还需要设置cpan的urllist
2. 若要使监控vmware esx的脚本生效,还需要安装 Nagios::Plugin模块
下载 监控脚本
git clone git://git.op5.org/nagios/op5plugins.git
从op5plugins中拷贝 check_vmware_api.pl 到 /usr/lib64/nagios/plugins (我是使用yum安装的nagios)
3.定义command
######################### Check ESXI Command #########################
define command{
command_name check_esx_service
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u root -p password -l $ARG1$ -s usage -w $ARG2$ -c $ARG3$
}
define command{
command_name check_esx_status
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u root -p password -l $ARG1$ -s $ARG2$
}
define command{
command_name check_esx_net
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u root -p password -l net
}
define command{
command_name check_esx_io
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u root -p password -l io
}
define command{
command_name check_esx_vmfs
command_line $USER1$/check_esx3.pl -H $HOSTADDRESS$ -u root -p password -l vmfs
}
将 root 和 password 替换成 自己设置的用户和密码
定义 service
define service{
use local-service
hostgroup_name vmware-esxi5
service_description CPU Load
check_command check_esx_service!cpu!80!90
}
define service{
use local-service
hostgroup_name vmware-esxi5
service_description Mem Usage
check_command check_esx_service!mem!90!95
}
define service{
use local-service
hostgroup_name vmware-esxi5
service_description Net Status
check_command check_esx_net
}
define service{
use local-service
hostgroup_name vmware-esxi5
service_description IO Status
check_command check_esx_io
}
define service{
use local-service
hostgroup_name vmware-esxi5
service_description Uptime Status
check_command check_esx_status!runtime!status
}
define service{
use local-service
hostgroup_name vmware-esxi5
service_description Vmfs Status
check_command check_esx_vmfs
}
4. 重启Nagios
阅读(5197) | 评论(0) | 转发(0) |