Zabbix IPMI监控服务器硬件状况详解

#!/bin/bash #用于检测ipmi相关信息 #Create on 2016-011-18 #@author: Chinge_Yang args="$*" echo $(date +%F-%T) $args >> /tmp/check_ipmi.debug check_ipmi_dir=/usr/local/zabbix/shell/check_ipmi_sensor check_ipmi_bin=$check_ipmi_dir/check_ipmi_sensor ipmi_sensors=/usr/sbin/ipmi-sensors ipmi_cfg=$check_ipmi_dir/ipmi.cfg #$check_ipmi_bin -f $ipmi_cfg -v $args #${ipmi_sel} $args --config-file $ipmi_cfg --driver-type=LAN_2_0 --output-event-state --interpret-oem-data --entity-sensor-names options="--quiet-cache --sdr-cache-recreate --interpret-oem-data --output-sensor-state --ignore-not-available-sensors --driver-type=LAN_2_0 --output-sensor-thresholds" function usage(){ echo "Usage: `basename $0` options (-h HOST|-n NAME)" } function check(){ result=$($ipmi_sensors -h $host --config-file $ipmi_cfg $options|grep "$name"|awk -F"| " '{print $NF}') printf "%.4f\n" $result } if [ $# -lt 4 ] then usage exit 55 fi # 用法: scriptname -options # 注意: 必须使用破折号 (-) # 参数后接冒号,表示必须接值 while getopts ":h:n:" Option;do case $Option in h) host=$OPTARG ;; n) name=$OPTARG ;; *) usage ;; # 默认情况的处理 esac done shift $(($OPTIND - 1)) # (译者注: shift命令是可以带参数的, 参数就是移动的个数) # 将参数指针减1, 这样它将指向下一个参数. # $1 现在引用的是命令行上的第一个非选项参数, #+ 如果有一个这样的参数存在的话. check exit 0

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5d66e2679627eb833db5a68b0d159c9a.html