zabbix監控mysql-如何使用zabbix自帶的模板監控-nagios監控mysql主從

用zabbix監控mysql(源碼安裝)安裝位置在/usr/local/zabbix/mysql


  1. 監控端(server):
    ios

    在被監控端主機上關聯該模板Template App MySQLsql

中文:組態->主機->名稱一欄點擊進去->模板,點擊連接新模板->添加->Template App MySQL->存檔vim

英文:Configuration->Hosts->Name->Templates,Link new templates->Add->Template App MySQL->Savebash


2. 被監控端(agent):ide

1)在源碼包../zabbix-2.2.1/conf/zabbix_agentd/ 拷貝模板spa

cp zabbix-2.2.1/conf/zabbix_agentd/userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/

2)授予監控mysql信息的用戶權限rest

mysql> grant usage on *.* to zabbix@'localhost' identified by 'zabbix';

3)修改my.cnform

[mysqladmin]
host=localhost
user=zabbix
password=zabbix
[mysql]
host=localhost
user=zabbix
password=zabbix

4)修改server

vim /usr/local/zabbix/etc/zabbix_agentd.conf.d/userparameter_mysql.conf
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -uzabbix -pzabbix -hlocalhost -N | awk '{print $$2}'
UserParameter=mysql.size[*],echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all"
 || ! "$1" ]] || echo " where table_schema='$1'")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name='$2'");" | HOME=/var/lib/zabbix mysql -uzabbix -pzabbix -hlocalhost -N
UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin -uzabbix -pzabbix -hlocalhost ping | grep -c alive
UserParameter=mysql.version,mysql -uzabbix -pzabbix -hlocalhost -V

5)

# /etc/init.d/mysqld restart
# /etc/init.d/zabbix_agentd restart

6)在server上的查看圖像數據

     Monitoring->Graphs->MySQL operations


nagios監控主從

ls /usr/local/nagios/etc/objects/commands.cfg

# vim /usr/local/nagios/etc/objects/commands.cfg
define command  {
         command_name    check_mysql_slave
         command_line  $USER1$/check_mysql -H $HOSTADDRESS$ -S -uzabbix -pzabbix
  }
修改被監控端的配置文件
# vim zabbix_agent.cfg
  
define service{
        use                             local-service
        host_name                       zabbix_agent
        service_description             MYSQL_SLAVE
        check_command                   check_mysql_slave                     
}

/etc/init.d/nagios restart
相關文章
相關標籤/搜索