91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

nagios監控mysql(check_mysql)及內存使用率(check_mem)

發布時間:2020-07-14 07:46:21 來源:網絡 閱讀:5265 作者:nmshuishui 欄目:移動開發

一、監控本地(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]<percent free> [-c|--critical]<percent free>"
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 ""  
        echo "$THRESHOLD_USAGE"  
        echo ""  
        echo "Usage: $USAGE"  
        echo ""  
        exit 0
fi
# Total memory available  
total=`free -m | head -2 |tail -1 |gawk '{print $2}'`
# Total memory used  
used=`free -m | head -2 |tail -1 |gawk '{print $3}'`
# Calc total minus used  
free=`free -m | head -2 |tail -1 |gawk '{print $2-$3}'`
# normal values  
#echo "$total"MB total  
#echo "$used"MB used  
#echo "$free"MB free  
# make it into % percent free = ((free mem / total mem) * 100)  
echo "5" > $calc # decimal accuracy  
echo "k" >> $calc # commit  
echo "100" >> $calc # multiply  
echo "$free" >> $calc # division integer  
echo "$total" >> $calc # division integer  
echo "/" >> $calc # division sign  
echo "*" >> $calc # multiplication sign  
echo "p" >> $calc # print  
percent=`/usr/bin/dc $calc|/bin/sed 's/^\./0./'|/usr/bin/tr "." " "|/usr/bin/gawk {'print $1'}`
#percent1=`/usr/bin/dc $calc`  
#echo "$percent1"  
if [[ "$percent" -le  $critical ]]
        then
                echo "CRITICAL - $free MB ($percent%) Free Memory"  
                exit 2
fi
if [[ "$percent" -le  $warning ]]
        then
                echo "WARNING - $free MB ($percent%) Free Memory"  
                exit 1
fi
if [[ "$percent" -gt  $warning ]]
        then
                echo "OK - $free MB ($percent%) Free Memory"  
                exit 0
fi

二、監控客戶端內存使用情況

1、上傳監控腳本 check_mem 到/usr/local/nagios/libexec

# chown -R nagios.nagios check_mem
# chmod +x check_mem

2、修改nrpe.cfg

# vim /usr/local/nagios/etc/nrpe.cfg 
command[check_users]=/usr/local/nagios/libexec/check_users -w 3 -c 5
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_xvda]=/usr/local/nagios/libexec/check_disk -w 10% -c 5% -p /dev/xvda
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200 
command[check_xvdb2]=/usr/local/nagios/libexec/check_disk -w 10% -c 5% -p /dev/xvdb2
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command[check_mem]=/usr/bin/sudo /usr/local/nagios/libexec/check_mem -w 20 -c 10   #增加此行

3、在nagios服務器端增加監控服務

# vim /usr/local/nagios/etc/servers/192.168.200.111.cfg
define service{
        use                             generic-service
        host_name                       192.168.200.111
        service_description             check_mem
        check_command                   check_nrpe!check_mem
        }

三、排錯

1、NRPE: Unable to read output

(1)為nagios用戶增加sudo權限

# visudo
nagios  ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/check_mem

(2)注釋掉一下行,表示不需要控制終端

# visudo
#Defaults    requiretty



四、nagios監控mysql

1、check_mysql

    nagios監控mysql使用的是 check_mysql 這個插件,需要在nagios服務器上先安裝mysql-devel,然后再重新安裝nagios-plugin,這樣才會出現check_mysql。否則即使copy了一份,也照樣用不了。

2、編譯或重新編譯 nagios-plugin

#yum -y install mysql-devl
#cd nagios-plugins-2.0.3
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
#make && make install

3、查看 check_mysql

# ls /usr/local/nagios/libexec/check_mysql

4、建立專用數據庫

# mysql -uroot -p
mysql> create database nagios_monitor;

mysql> grant select on nagios_monitor.* to nagios@'%' identified by '123qaz!@#';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> select User,Password,Host from mysql.user;
+--------+-------------------------------------------+--------------+
| User   | Password                                  | Host         |
+--------+-------------------------------------------+--------------+
| root   | *B9627CB37815863D1E98D0C41E0233A772355E2B | localhost    |
| root   | *B9627CB37815863D1E98D0C41E0233A772355E2B | 127.0.0.1    |
| root   | *B9627CB37815863D1E98D0C41E0233A772355E2B | ::1          |
| cacti  | *BC3E1F14C7940F9C8BCDB05A38385754BB55CD64 | localhost    |
| nagios | *BC3E1F14C7940F9C8BCDB05A38385754BB55CD64 | %            |
+--------+-------------------------------------------+--------------+
8 rows in set (0.00 sec)

5、check 一下

# /usr/local/nagios/libexec/check_mysql -H 192.168.200.105 -unagios -dnagios_monitor -p 123qaz!@#
# 報了一個錯
/usr/local/nagios/libexec/check_mysql: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
# 解決:
ln -sv /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
# 再重新測試
# /usr/local/nagios/libexec/check_mysql -H 192.168.200.111 -unagios -dnagios_monitor -p 123qaz!@#
Uptime: 13991  Threads: 5  Questions: 1242101  Slow queries: 0  Opens: 159  Flush tables: 1  Open tables: 60  Queries per second avg: 88.778|Connections=315c;;; Open_files=85;;; Open_tables=60;;; Qcache_free_memory=16285768;;; Qcache_hits=1210926c;;; Qcache_inserts=16654c;;; Qcache_lowmem_prunes=0c;;; Qcache_not_cached=2c;;; Qcache_queries_in_cache=283;;; Queries=1242101c;;; Questions=1242101c;;; Table_locks_waited=2c;;; Threads_connected=5;;; Threads_running=1;;; Uptime=13991c;;;

6、監控localhost

(1)修改 commands.cfg

# vim /usr/local/nagios/etc/objects/commands.cfg
define command{
        command_name check_mysql
        command_line $USER1$/check_mysql -H $HOSTADDRESS$ -unagios -dnagios_monitor -p123qaz!@#
}

(2)修改 localhost.cfg

# vim /usr/local/nagios/etc/objects/localhost.cfg
define service{
        use                             local-service
        host_name                       localhost
        service_description             check_mysql
        check_command                   check_mysql
        }

(3)重啟 nagios

# service nagios restart

7、監控客戶端

(1)check 一下

# /usr/local/nagios/libexec/check_mysql -H 192.168.200.111 -unagios -dnagios_monitor -p123qaz!@#

(2)客戶端修改 nrpe.cfg

# vim /usr/local/nagios/etc/nrpe.cfg 
command[check_mysql]=/usr/local/nagios/libexec/check_mysql -H 192.168.200.111 -unagios -dnagios_monitor -p123qaz!@#

(3)重啟 nrpe

# killall nrpe
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

(4)服務端定義服務

# vim /usr/local/nagios/etc/servers/192.168.200.111.cfg 
define service{
        use                             generic-service
        host_name                       192.168.200.111
        service_description             check_mysql
        check_command                   check_nrpe!check_mysql
        }

(5)重啟 nagios 服務

# service nagios restart


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

兰坪| 剑川县| 万载县| 轮台县| 班戈县| 闸北区| 新巴尔虎左旗| 汉寿县| 咸宁市| 景谷| 镇康县| 普格县| 叶城县| 闽侯县| 虎林市| 赫章县| 家居| 古蔺县| 米林县| 蒙阴县| 山丹县| 桐乡市| 汝南县| 闽侯县| 仪陇县| 远安县| 阿拉善盟| 吐鲁番市| 武城县| 蒲城县| 凭祥市| 元阳县| 庆阳市| 城口县| 霍州市| 太康县| 林州市| 伽师县| 页游| 新蔡县| 离岛区|