溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

nagios用nrpe監(jiān)控mem

發(fā)布時(shí)間:2020-09-16 05:05:18 來(lái)源:網(wǎng)絡(luò) 閱讀:587 作者:zhangfang2012 欄目:移動(dòng)開(kāi)發(fā)

在監(jiān)控端及nagios服務(wù)器上添加如下腳本

[root@nagios libexec]# cat /usr/local/nagios/libexec/check_mem.sh 

TOTAL=`free -m | head -2 |tail -1 |gawk '{print $2}'`

# Free memory 

FREE=`free -m | head -2 |tail -1 |gawk '{print $4}'`

# to calculate free percent

# use the expression  free * 100 / total

FREETMP=`expr $FREE \* 100`

PERCENT=`expr $FREETMP / $TOTAL`

echo "$FREE MB ($PERCENT%) Free Memory"

exit 0

vim /usr/local/nagios/etc/objects/commands.cfg (添加)

define command{

command_name check_mem

command_line $USER1/check_mem.sh   -H $HOSTADDRESS$

}

vim /usr/local/nagios/etc/objects/services.cfg (添加)

define service{

        use                     local-service

        host_name               mysqlhost

        service_groups  mysqlgroup

        service_description     check_mem

        check_command           check_nrpe!check_mem.sh

        max_check_attempts      2

        normal_check_interval   3

        retry_check_interval    2

        check_period            24x7

        notification_interval   5

        notification_period     24x7

        notification_options    w,u,c,r

        contact_groups          admins

}

在被監(jiān)控端

[root@171 html]# cat /usr/local/nagios/libexec/check_mem.sh 

TOTAL=`free -m | head -2 |tail -1 |gawk '{print $2}'`

# Free memory 

FREE=`free -m | head -2 |tail -1 |gawk '{print $4}'`

# to calculate free percent

# use the expression  free * 100 / total

FREETMP=`expr $FREE \* 100`

PERCENT=`expr $FREETMP / $TOTAL`

echo "$FREE MB ($PERCENT%) Free Memory"

exit 0

vim /usr/local/nagios/etc/nrpe.cfg (添加)

command[check_mem.sh]=/usr/local/nagios/libexec/check_mem.sh

重啟xientd服務(wù)

/etc/init.d/xinted restart

監(jiān)控端

重啟nagios服務(wù)

/etc/init.d/nagios restart

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI