发表于 2019-1-14 08:32:33

nagios plugin shell 自定义,并可以被rrdtool+pnp4nagios 绘画

  Current Status:
OK
  

  (for 0d 1h 57m 28s)Status
  Information:USERS OK - 3 users currently logged in
  Performance Data:   users=3;5;10;0#### 些数据控制绘图信息,和绘图数据生成
  Current Attempt:1/4(HARD state)
  Last Check Time:03212014 17:46:11
  Check Type:ACTIVE
  Check Latency / Duration:0.129 / 0.030 seconds
  Next Scheduled Check:03-21-2014 17:56:11
  Last State Change:03212014 15:56:11
  Last Notification:N/A (notification 0)
  xxxxxx.........
  

  

  

  ### 自定义插件要想输出如下信息
Status Information:0 , w=70 c=160Performance Data:users=70;160;0;114  必须在脚本的输出结果为 : 0 , w=70 c=160 | users=70;160;0;114
  其中'|' 作为数据的分隔位置。
  示例脚本,只是绘图完测试检测,可定义修改使用
#/bin/bash
# Datexxx
# Authorxx
# Description check the nagios pulgin shell uageage
Useage_help="$0 [-w|--warn number ][ -c |--critical number] "
Warning=0
Critical=0
STAT_OK=0
STAT_WARNING=1
STAT_CRITICAL=2
STAT_UNKNOW=3
process=`/bin/ps -ef | /usr/bin/wc -l `
while [ -n "$1" ]
do
case $1 in
-w|--warn)
shift
Warning=$1
;;
-c|--critical)
shift
Critical=$1
;;
*)
echo "$Useage_help"
exit 1
;;
esac
shift
done
#echo "Warning = $Warning , Critical = $Critical"
###    aa| bb
# aa : Status Information
# bb : Performance Data
echo "$STAT_OK , w=$Warning c=$Critical | users=$Warning;$Critical;0;$process"  

  

  调用方法与系统自带的一致。
  脚格式参照:http://os.运维网.com/art/201103/249956.htm
  




页: [1]
查看完整版本: nagios plugin shell 自定义,并可以被rrdtool+pnp4nagios 绘画