zabbix监控硬件

一)通过snmp监控
1、idrac上开启snmp服务
zabbix监控硬件_第1张图片
2、然后到zabbix server服务器上测试一下是否能get到数据:
snmpget -v 2c -c .1.3.6.1.4.1.674.10892.2.1.1.2.0
在这里插入图片描述
3、 添加主机
zabbix监控硬件_第2张图片
zabbix监控硬件_第3张图片
二)通过在每台agent机器上安装openmanage(针对dell服务器的
1、安装openmanage
wget -q -O - https://linux.dell.com/repo/hardware/dsu/bootstrap.cgi | bash
yum install dell-system-update -y
yum install srvadmin-base srvadmin-storageservices -y 或者 yum install srvadmin-all -y
/opt/dell/srvadmin/sbin/srvadmin-services.sh start
/opt/dell/srvadmin/sbin/srvadmin-services.sh restart
/opt/dell/srvadmin/sbin/srvadmin-services.sh enable
2、在每台agent上创建文件/usr/local/check_hardware.sh

	#!/usr/bin/bash 
	
	hardware_battery=$(sudo /opt/dell/srvadmin/bin/omreport chassis batteries|grep Status|awk -F ":" '{print $NF}'|sed 's/ //g')
	
	if [[ $hardware_battery != "Ok"  ]]
	then
	    echo "hardware_battery"
	    exit 1
	fi	
	#the sum fan number ? the ok fan number
	hardware_fan_number=$(sudo /opt/dell/srvadmin/bin/omreport chassis fans|grep -c "^Index")
	hardware_fan=$(sudo /opt/dell/srvadmin/bin/omreport chassis fans|awk '/^Status/{if($NF=="Ok") count+=1}END{print count}')
	
	if [[ $hardware_fan_number -ne $hardware_fan  ]]
	then
	    echo "hardware_fan"
	    exit 1
	fi
	 
	#nic judge
	status=$(/opt/dell/srvadmin/sbin/omreport chassis nics|grep Connection|awk -F ':' '{print $NF}'|sed 's/ //g')
	nic_num=$(/opt/dell/srvadmin/sbin/omreport chassis nics|grep -c  Connection)
	if [[ -f '/tmp/nicdata' ]]
	then
	    
	    nicdata=$(cat /tmp/nicdata |awk 'END{print}')
		echo  $nic_num:$status>>/tmp/nicdata
		last_nic_num=$(echo $nicdata|awk -F ':' '{print $1}')
		if [[ $nic_num !=  $last_nic_num  ]] 
		then
		    echo "hardware_nic"
			exit 1
		else
		    i=1
		    while (( "$i <= $nic_num"  ))
			do
			    nic_status=$(echo $status|cut -d ' ' -f$i)
				last_nic_status=$(echo $nicdata|cut -d ':' -f2|cut -d ' ' -f$i)
				if [[ $nic_status != $last_nic_status ]]
				then
				    echo "hardware_nic"
					exit 1
				fi	
				let "i++"
			done
		fi
	else
	    echo  $nic_num:$status>>/tmp/nicdata
	 fi
	
	
	
	
	hardware_cpu=$(sudo /opt/dell/srvadmin/bin/omreport chassis processors|awk '/^Health/{if($NF=="Ok") {print 1} else {print 0}}')
	
	if [[ $hardware_cpu -eq 0  ]]
	then
	    echo "hardware_cpu"
	    exit 1
	fi
	##the sum temps number ? the ok temps number
	hardware_temp_number=$(sudo /opt/dell/srvadmin/bin/omreport chassis temps|grep -c "Status")
	hardware_temp=$(sudo /opt/dell/srvadmin/bin/omreport chassis temps|awk '/^Status/{if($NF=="Ok") count+=1}END{print count}')
	
	if [[ $hardware_temp -ne $hardware_temp_number  ]]
	then
	    echo "hardware_temp"
	    exit 1
	fi
	##the sum pwrsupplies number ? the ok pwrsupplies number
	hardware_power_number=$(sudo /opt/dell/srvadmin/bin/omreport chassis pwrsupplies|grep -c "Index")
	hardware_power=$(sudo /opt/dell/srvadmin/bin/omreport chassis pwrsupplies|awk '/^Status/{if($NF=="Ok") count+=1}END{print count}')
	
	if [[ $hardware_power_number -ne $hardware_power  ]]
	then
	    echo "hardware_power"
	    exit 1
	fi
	hardware_memory=$(sudo /opt/dell/srvadmin/bin/omreport chassis memory|grep Health|awk -F ":" '{print $NF}'|sed 's/ //g') 
	if [[ $hardware_memory != "Ok"  ]]
	then
	    echo "hardware_memory"
	    exit 1
	fi
	echo 1

3、修改agent配置文件,自定义监控项hardware_check
UnsafeUserParameters=1
UserParameter=sh /usr/local/check_hardware.sh

4、创建Dell_Hardware模板

zabbix监控硬件_第4张图片
zabbix监控硬件_第5张图片

你可能感兴趣的:(zabbix,snmp,dell服务器,zabbix硬件)