1, 把check_cpu.sh 文件放在libexec目录下。
#!/bin/sh # Filename: check_cpu.sh procinfo=`which procinfo 2>/dev/null` sar=`which sar 2>/dev/null` function help { echo -e "\n\tThis plugin shows the % of used CPU, using either procinfo or sar (whichever is available)\n\n\t$0:\n\t\t-c <integer>\tIf the % of used CPU is above <integer>, returns CRITICAL state\n\t\t-w <integer>\tIf the % of used CPU is below CRITICAL and above <integer>, returns WARNING state\n" exit -1 } # Getting parameters: while getopts "w:c:h" OPT; do case $OPT in "w") warning=$OPTARG;; "c") critical=$OPTARG;; "h") help;; esac done # Checking parameters: ( [ "$warning" == "" ] || [ "$critical" == "" ] ) && echo "ERROR: You must specify warning