zabbix 監控


  • NGINX
    • 採用:https://github.com/vicendominguez/nginx-zabbix-template
    • 注意點:
      1. 採用Installation in the Zabbix Server,直接在zabbix server上下指令
      2. 可能有必要自行指定URL的位置,原先樣本內採用 HOST.CONN,這部分如果與現況不符合,就得將在 TEMPLATE 的 ITEM 的 HOST.CONN換成 MACRO 來指定,且同時也需要在HOST內加入該 MACRO 的URL值
  • MYSQL
    • 採用zabbix官方的template
    • 注意點:
      • 在Mysql的DB端,需要加一個使用者提供mysql取用狀態用
      • 並在Mysql的OS上要設定一個 .my.cnf,提供給zabbix_agent回應server的呼叫
      • # Zabbix Agent
        [mysql]
        host=localhost
        user=zabbix
        password=password
        #socket=/var/lib/mysql/mysqld.sock
        socket=/var/run/mysqld/mysqld.sock
        [mysqladmin]
        host=localhost
        user=zabbix
        password=password
        #socket=/var/lib/mysql/mysqld.sock
        socket=/var/run/mysqld/mysqld.sock
        
      • 修改 /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf 中,HOME=/etc/zabbix,這個部分,要符合前項.my.cnf的位置
      •  1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        # For all the following commands HOME should be set to the directory that has .my.cnf file with password information.
        
        # Flexible parameter to grab global variables. On the frontend side, use keys like mysql.status[Com_insert].
        # Key syntax is mysql.status[variable].
        UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/etc/zabbix mysql -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[*],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.tabl$
        
        UserParameter=mysql.ping,HOME=/etc/zabbix mysqladmin ping | grep -c alive
        UserParameter=mysql.version,mysql -V
        

留言

熱門文章