nagios监控mysql性能_nagios监控mysql(check_mysql)及内存使用率(check_mem)

一、监控本地(localhost)内存

1、上传监控脚本 check_mem 到/usr/local/nagios/libexec# chown -R nagios.nagios check_mem

# chmod +x check_mem

2、修改commands配置# vim /usr/local/nagios/etc/objects/commands.cfg

define command{

command_name        check_mem

command_line        $USER1$/check_mem -w $ARG1$ -c $ARG2$

}

3、修改localhost.cfg# vim /usr/local/nagios/etc/objects/localhost.cfg

define service{

use                             local-service

host_name                       localhost

service_description             check_mem

check_command                   check_mem!20!10

}

4、重启nagios服务# service nagios restart

5、check_mem 脚本#!/bin/bash

USAGE="`basename $0` [-w|--warning] [-c|--critical]"

THRESHOLD_USAGE="WARNING threshold must be greater than CRITICAL: `basename $0` $*"

calc=/tmp/memcalc

percent_free=/tmp/mempercent

critical=""

warning=""

STATE_OK=0

STATE_WARNING=1

STATE_CRITICAL=2

STATE_UNKNOWN=3

# print usage

if [[ $# -lt 4 ]]

then

echo ""

echo "Wrong Syntax: `basename $0` $*"

echo ""

echo "Usage: $USAGE"

echo ""

exit 0

fi

# read input

while [[ $# -gt 0 ]]

do

case "$1" in

-w|--warning)

shift

warning=$1

;;

-c|--critical)

shift

critical=$1

;;

esac

shift

done

# verify input

if [[ $warning -eq $critical || $warning -lt $critical ]]

then

echo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值