반응형

테스트 중에 나의 주요 목적인 MySQL 모니터링이 제대로 되고 있는지 확인해 보았다.


역시나 Server down.....OTL....

너란 녀석은 정말 힘들구나...


먼저 로그를 보는게 가장 좋다.

zabbix_agentd.log (/var/log/zabbix) 확인을 해 보았다.


여러 에러가 있었지만 이 부분이 가장 화근이었다.



보는 바와 같이 아래 에러를 이해하면 될 듯 싶다.

이미 존재한다고 한다......으응??????????????하아.....존재한다고..먼말이야;;;;

설마 존재하더라도 또 실행해도 되는거 아닌가....ㅠㅠ

이 내용을 빨리 이해했다면 시간을 허비하지 않아도 되었을텐데;;;

 9347:20160718:174922.943 using configuration file: /etc/zabbix/zabbix_agentd.conf

  9347:20160718:174922.973 cannot add user parameter "mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -uzabbix -pzabbix -N | awk '{print $$2}'": key "mysql.status" already exists



 zabbix_agentd.conf 확인

- 여기서 해결되었다.

- 아래보면 Include 에서 나는 2개 동시를 include 하였다.

그래서 아래와 같이 하나만 실행되도록 하고 나머지는 모두 막았다.



이후 다시 실행 해 봤더니 되었다...(사실 에러가 발생하면 zabbix agent가 실행이 안되는 것을 확인 가능하다)


아래와 같이 MySQL 관련 항목들이 모두 받아 오고 있는 것을 확인 가능하다.




 결론 : 


zabbix_agentd.conf 에서 include를 2번이나 실행하면 안된다.


참고사항: https://www.zabbix.com/forum/showthread.php?t=40870



userparameter_mysql.conf


여기에는 추가적으로 이것저것 설정할 수 있다.

아래는 내가 테스트로 추가하다가 다 주석하고 제대로 된 default는 아니지만 참고 하면 된다.


mysql 또는 mysqladmin 에 문법에 맞춰 user와 패스워드를 작성해 줬다.

그리고 문법은 검색하면 나오지만 아래 사이트 참고하면 좋을 듯 싶다.


참고사항 : http://zabbix.dothome.co.kr/doku.php/manual/appendix/recipes


UserParameter=변수명,문법


인데...문법만 실행하면 해당 결과 값이 리턴되어 나온다.

리턴된 값을 변수에 담게 되고  zabbix 에서 사용하는 것으로 예상된다.

그래서 자신의 문법이 틀렸는지 여부는 바로 서버에서 확인하면 될 듯 싶다.


이 부분에서 에러생기면 또 실행이 안되니 이 점 필히 체크 필요하다.


UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -uzabbix -pzabbix -N | awk '{print $$2}'

# Flexible parameter to determine database or table size. On the frontend side, use keys like mysql.size[zabbix,history,data].

# Key syntax is mysql.size[<database>,<table>,<type>].

# Database may be a database name or "all". Default is "all".

# Table may be a table name or "all". Default is "all".

# Type may be "data", "index", "free" or "both". Both is a sum of data and index. Default is "both".

# Database is mandatory if a table is specified. Type may be specified always.

# Returns value in bytes.

# 'sum' on data_length or index_length alone needed when we are getting this information for whole database instead of a single table

UserParameter=mysql.size[*],bash -c '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 -N'

UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin -uzabbix --password=zabbix ping | grep -c alive

UserParameter=mysql.version,mysql -V

#UserParameter=mysql.ping,mysqladmin -uzabbix --password=zabbix ping | grep alive | wc -l | tr -d " "

#UserParameter=mysql.uptime,mysqladmin -uzabbix --password=zabbix status | cut -f2 -d ":" | cut -f1 -d "T" | tr -d " "

#UserParameter=mysql.threads,mysqladmin -uzabbix --password=zabbix status | cut -f3 -d ":" | cut -f1 -d "Q" | tr -d " "

#UserParameter=mysql.questions,mysqladmin -uzabbix --password=zabbix status | cut -f4 -d ":"|cut -f1 -d "S" | tr -d " "

#UserParameter=mysql.slowqueries,mysqladmin -uzabbix --password=zabbix status | cut -f5 -d ":" | cut -f1 -d "O" | tr -d " "

#UserParameter=mysql.qps,mysqladmin -uzabbix --password=zabbix status | cut -f9 -d ":" | tr -d " "

#UserParameter=mysql.version,mysql -V





반응형

+ Recent posts