温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-08-28 18:30:30 来源:网络 阅读:538 作者:海无崖 栏目:移动开发

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=160
Performance Data:users=70;160;0;114

必须在脚本的输出结果为 : 0 , w=70 c=160 | users=70;160;0;114

其中'|' 作为数据的分隔位置。

示例脚本,只是绘图完测试检测,可定义修改使用

#/bin/bash
# Date  xxx
# Author  xx
# 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.51cto.com/art/201103/249956.htm


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI