├── 03-chapter ├── Readme.md ├── Zabbix_MySQLdump_per_table.sh ├── Zabbix_MySQLdump_per_table_v2.sh ├── partitiontables.sh ├── partitiontables_gt_zbx34.sh └── zabbix_install_on_ubuntu.md ├── 06-chapter ├── python-argparse-1.2.1-2.el6.noarch.rpm ├── zabbix_sendmail.py └── zabbix_sendmail_v2.py ├── 09-chapter ├── README.md ├── SaltStack │ ├── README.txt │ └── srv │ │ └── salt │ │ ├── top.sls │ │ └── zabbix │ │ ├── conf │ │ ├── zabbix_agentd.conf │ │ └── zabbix_agentd.conf.d │ │ │ ├── get_os_type.conf │ │ │ ├── haproxy_host_status.conf │ │ │ ├── haproxy_main_status.conf │ │ │ ├── haproxy_status_discovery.conf │ │ │ ├── harddisk_status.conf │ │ │ ├── ipvs_monitor.conf │ │ │ ├── monitor_mysql_status.conf │ │ │ ├── monitor_phpfpm_status.conf │ │ │ ├── monitor_website_status.conf │ │ │ ├── mysql_status.conf │ │ │ ├── nginx_status.conf │ │ │ ├── redis.conf │ │ │ ├── tcp_connect.conf │ │ │ └── web_site_discovery.conf │ │ ├── init.sls │ │ └── scripts │ │ ├── WEB.txt │ │ ├── diskio.pl │ │ ├── diskio.trapper.sh │ │ ├── haproxy_host_status │ │ ├── haproxy_main_status │ │ ├── haproxy_status_discovery │ │ ├── ipvs_monitor │ │ ├── monitor_phpfpm_status │ │ ├── monitor_website_status.py │ │ ├── monitor_website_status.pyc │ │ ├── monitor_website_status.pyo │ │ ├── mysql.py │ │ ├── mysql.pyc │ │ ├── mysql.pyo │ │ ├── nginx_status │ │ ├── redis │ │ ├── tcp_connect │ │ ├── web_discovery_low.py │ │ ├── web_discovery_low.pyc │ │ ├── web_discovery_low.pyo │ │ └── web_site_code_status └── low_level_discovery │ └── bind_file_system_not_display │ ├── 001.png │ ├── README.md │ ├── img │ ├── 000-0.png │ ├── 000-1.png │ ├── 000-2.png │ ├── 001.png │ ├── 002.png │ ├── 003.png │ ├── 004.png │ └── 005.png │ ├── scripts │ ├── \ │ └── fileSystemDiscoveryNotBind.py │ ├── zabbix_agentd.d │ └── fileSystemDiscoveryNotBind.conf │ └── zbx_export_templates_not_bind_dir_LLD.xml ├── 11-chapter ├── Dell-Hardware-monitor │ ├── IPMI │ │ └── zbx_templates_DELL_R415.xml │ └── OMSA │ │ ├── readme.md │ │ ├── userparameter_dell_hardware.conf │ │ └── zbx_templates_DELL_OMSA.xml ├── doc │ └── redis_monitor.md ├── linux_disk_io_monitor │ ├── README.md │ ├── check_harddisk.sh │ ├── linux_disk_io_template.xml │ └── userparameter_harddisk.conf ├── mysql_monitor │ ├── MySQL_monitor.xml │ ├── check_mysql.sh │ └── userparameter_mysql.conf ├── nginx_monitor │ ├── scripts │ │ └── nginx_status │ └── zabbix_agentd.d │ │ └── userparameter_nginx.conf ├── php-fpm_monitor │ ├── scripts │ │ └── monitor_phpfpm_status │ ├── templates │ │ └── zbx_templates_phpfpm_status.xml │ └── zabbix_agentd.d │ │ └── monitor_phpfpm_status.conf ├── py_oracle_zabbix │ ├── ORACLE_zbx_templates.xml │ ├── cx_Oracle-5.1.2-11g-py26-1.x86_64.rpm │ ├── install_oracle.sh │ ├── libaio-0.3.107-10.el6.x86_64.rpm │ ├── oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm │ ├── oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm │ ├── oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm │ ├── oracle-zabbix-monitor.tar.gz │ ├── oracle.conf │ ├── py_oracle.conf │ ├── pyora.py │ ├── pyora.xml │ ├── python-argparse-1.2.1-2.el6.noarch.rpm │ └── readme.txt ├── redis_monitor │ ├── Redis_monitor.xml │ ├── check_redis.sh │ └── userparameter_redis.conf ├── tcp_connect │ ├── templates │ │ └── zbx_export_templates_tcp.xml │ └── zabbix_agentd.d │ │ └── userparameter_tcp_connect_status.conf └── web_monitor │ ├── README.md │ ├── web-monitor.xml │ ├── web_site_code.conf │ └── web_site_code_status ├── 13-chapter └── zabbix-api-example │ ├── 12.3.6-zabbixhostget.py │ ├── 12.3.7-zabbixhostcreate.py │ └── 12.3.8-zabbixhostdelete.py ├── 14-chapter ├── zabbix-get.py └── zabbix_sender.py ├── 16-chapter └── keepalived │ ├── conf │ ├── chk_zabbix_server.sh │ └── keepalived.conf │ └── keepalived-1.2.7-3.el6.x86_64.rpm ├── 17-chapter └── zabbix-database-1.8-2.0-2.2.xlsx ├── NMP ├── README.md ├── SPECS │ ├── php-5.4.25.spec │ └── zabbix2.2.2.spec ├── SRPM │ ├── nginx-1.4.5-1.el6.ngx.src.rpm │ ├── php-5.4.25-1.el6.src.rpm │ └── zabbix-2.2.2-0.el6.zbx.src.rpm ├── conf │ ├── zabbix-apache-web.conf │ └── zabbix-nginx-web.conf ├── mysql-install-readme.md ├── nginx │ └── nginx-1.4.5-1.el6.ngx.x86_64.rpm ├── php │ ├── php-5.4.25-1.el6.x86_64.rpm │ └── require-rpm │ │ ├── libicu-4.2.1-9.1.el6_2.x86_64.rpm │ │ ├── libjpeg-turbo-1.2.1-1.el6.x86_64.rpm │ │ ├── libmcrypt-2.5.8-9.el6.x86_64.rpm │ │ └── libtidy-0.99.0-19.20070615.1.el6.x86_64.rpm └── zabbix │ ├── require-rpm │ ├── OpenIPMI-devel-2.0.16-12.el6.x86_64.rpm │ ├── fping-2.4b2-10.el6.x86_64.rpm │ ├── libssh2-1.2.2-7.el6_2.3.x86_64.rpm │ ├── libssh2-devel-1.2.2-7.el6_2.3.x86_64.rpm │ ├── php-bcmath-5.3.3-3.el6_2.8.x86_64.rpm │ └── php-mbstring-5.3.3-3.el6_2.8.x86_64.rpm │ ├── zabbix-agent-2.2.2-0.el6.zbx.x86_64.rpm │ ├── zabbix-java-gateway-2.2.2-0.el6.zbx.x86_64.rpm │ ├── zabbix-mysql-2.2.2-0.el6.zbx.x86_64.rpm │ ├── zabbix-proxy-2.2.2-0.el6.zbx.x86_64.rpm │ ├── zabbix-server-2.2.2-0.el6.zbx.x86_64.rpm │ ├── zabbix-web-apache-2.2.2-0.el6.zbx.noarch.rpm │ └── zabbix-web-nginx-2.2.2-0.el6.zbx.noarch.rpm ├── README.md ├── error-fix └── README.md ├── static └── img │ └── zabbix-QQ-group-1.jpeg ├── tools └── screen_create │ ├── README.md │ ├── add.sh │ ├── config │ ├── screen_creator.py │ └── zabbix_api.py ├── zabbix-agent-key └── zabbix-agent-key.md └── zabbix-conf ├── zabbix_agent.conf ├── zabbix_agentd.conf ├── zabbix_agentd.win.conf ├── zabbix_proxy.conf └── zabbix_server.conf /03-chapter/Readme.md: -------------------------------------------------------------------------------- 1 | ``` 2 | # sh partitiontables.sh 3 | Ready to partition tables. 4 | 5 | Ready to update permissions of Zabbix user to create routines 6 | 7 | Enter root DB user: root 8 | Enter root password: mysqlpassword 9 | 10 | 11 | 12 | Do you want to backup the database (recommended) (Y/n): y 13 | 14 | Enter output file, press return for default of /tmp/zabbix.sql 15 | 16 | Mysqldump succeeded!, proceeding with upgrade... 17 | 18 | 19 | Ready to proceed: 20 | 21 | Starting yearly partioning at: 2014 22 | and ending at: 2014 23 | With 90 days of daily history 24 | 25 | 26 | Ready to proceed (Y/n): 27 | y 28 | Altering table: history 29 | Altering table: history_log 30 | Altering table: history_str 31 | Altering table: history_text 32 | Altering table: history_uint 33 | Altering table: trends 34 | Altering table: trends_uint 35 | Creating monthly partitions for table: trends 36 | Creating monthly partitions for table: trends_uint 37 | Creating daily partitions for table: history 38 | Creating daily partitions for table: history_log 39 | Creating daily partitions for table: history_str 40 | Creating daily partitions for table: history_text 41 | Creating daily partitions for table: history_uint 42 | 43 | 44 | Ready to apply script to database, this may take a while.(Y/n): 45 | y 46 | Altering tables 47 | history 48 | history_log 49 | history_str 50 | history_text 51 | history_uint 52 | trends 53 | trends_uint 54 | trends 55 | trends_uint 56 | history 57 | history_log 58 | history_str 59 | history_text 60 | history_uint 61 | Installing procedures 62 | 63 | Do you want to update the /etc/zabbix/zabbix_server.conf 64 | to disable housekeeping (Y/n): n 65 | 66 | Do you want to update the crontab (Y/n): y 67 | The crontab entry can be either in /etc/cron.daily, or added 68 | to the crontab for root 69 | 70 | Do you want to add this to the /etc/cron.daily directory (Y/n): y 71 | 72 | Enter email of who should get the daily housekeeping reports: 73 | ``` 74 | -------------------------------------------------------------------------------- /03-chapter/Zabbix_MySQLdump_per_table.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #author: itnihao 3 | #mail: itnihao@qq.com 4 | #http://wwww.itnihao.com 5 | #https://github.com/itnihao/zabbix-book/blob/master/03-chapter/Zabbix_MySQLdump_per_table.sh 6 | 7 | source /etc/bashrc 8 | source /etc/profile 9 | 10 | MySQL_USER=zabbix 11 | MySQL_PASSWORD=zabbix 12 | MySQL_HOST=localhost 13 | MySQL_PORT=3306 14 | MySQL_DUMP_PATH=/mysql_backup 15 | MySQL_DATABASE_NAME=zabbix 16 | DATE=$(date '+%Y-%m-%d') 17 | 18 | [ -d ${MySQL_DUMP_PATH} ] || mkdir ${MySQL_DUMP_PATH} 19 | cd ${MySQL_DUMP_PATH} 20 | [ -d logs ] || mkdir logs 21 | [ -d ${DATE} ] || mkdir ${DATE} 22 | cd ${DATE} 23 | 24 | 25 | TABLE_NAME_ALL=$(mysql -u${MySQL_USER} -p${MySQL_PASSWORD} -P${MySQL_PORT} -h${MySQL_HOST} ${MySQL_DATABASE_NAME} -e "show tables"|egrep -v "(Tables_in_zabbix|history*|trends*|acknowledges|alerts|auditlog|events|service_alarms)") 26 | for TABLE_NAME in ${TABLE_NAME_ALL} 27 | do 28 | mysqldump -u${MySQL_USER} -p${MySQL_PASSWORD} -P${MySQL_PORT} -h${MySQL_HOST} ${MySQL_DATABASE_NAME} ${TABLE_NAME} >${TABLE_NAME}.sql 29 | sleep 1 30 | done 31 | 32 | 33 | [ "$?" == 0 ] && echo "${DATE}: Backup zabbix succeed" >> ${MySQL_DUMP_PATH}/logs/ZabbixMysqlDump.log 34 | [ "$?" != 0 ] && echo "${DATE}: Backup zabbix not succeed" >> ${MySQL_DUMP_PATH}/logs/ZabbixMysqlDump.log 35 | 36 | 37 | cd ${MySQL_DUMP_PATH}/ 38 | rm -rf $(date +%Y-%m-%d --date='5 days ago') 39 | exit 0 40 | -------------------------------------------------------------------------------- /03-chapter/Zabbix_MySQLdump_per_table_v2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #author: itnihao 3 | #mail: itnihao@qq.com 4 | #http://wwww.itnihao.com 5 | #https://github.com/itnihao/zabbix-book/blob/master/03-chapter/Zabbix_MySQLdump_per_table.sh 6 | #chmod 700 ${PATH}/Zabbix_MySQLdump_per_table_v2.sh 7 | #crontab -e (0 3 * * * ${PATH}/Zabbix_MySQLdump_per_table_v2.sh) 8 | 9 | red='\e[0;31m' # 红色 10 | RED='\e[1;31m' 11 | green='\e[0;32m' # 绿色 12 | GREEN='\e[1;32m' 13 | blue='\e[0;34m' # 蓝色 14 | BLUE='\e[1;34m' 15 | purple='\e[0;35m' # 紫色 16 | PURPLE='\e[1;35m' 17 | NC='\e[0m' # 没有颜色 18 | 19 | source /etc/bashrc 20 | source /etc/profile 21 | 22 | MySQL_USER=zabbix 23 | MySQL_PASSWORD=zabbix 24 | MySQL_HOST=localhost 25 | MySQL_PORT=3306 26 | MySQL_DUMP_PATH=/mysql_backup 27 | MYSQL_BIN_PATH=/usr/bin/mysql 28 | MYSQL_DUMP_BIN_PATH=/usr/bin/mysqldump 29 | MySQL_DATABASE_NAME=zabbix 30 | DATE=$(date '+%Y-%m-%d') 31 | 32 | MySQLDUMP () { 33 | [ -d ${MySQL_DUMP_PATH} ] || mkdir ${MySQL_DUMP_PATH} 34 | cd ${MySQL_DUMP_PATH} 35 | [ -d logs ] || mkdir logs 36 | [ -d ${DATE} ] || mkdir ${DATE} 37 | cd ${DATE} 38 | 39 | TABLE_NAME_ALL=$(${MYSQL_BIN_PATH} -u${MySQL_USER} -p${MySQL_PASSWORD} -h${MySQL_HOST} ${MySQL_DATABASE_NAME} -e \ 40 | "show tables"|egrep -v "(Tables_in_zabbix|history*|trends*|acknowledges|alerts|auditlog|events|service_alarms)") 41 | for TABLE_NAME in ${TABLE_NAME_ALL} 42 | do 43 | ${MYSQL_DUMP_BIN_PATH} --opt -u${MySQL_USER} -p${MySQL_PASSWORD} -P${MySQL_PORT} -h${MySQL_HOST} \ 44 | ${MySQL_DATABASE_NAME} ${TABLE_NAME} >${TABLE_NAME}.sql 45 | sleep 0.01 46 | done 47 | 48 | [ "$?" == 0 ] && echo "${DATE}: Backup zabbix succeed" >> ${MySQL_DUMP_PATH}/logs/ZabbixMysqlDump.log 49 | [ "$?" != 0 ] && echo "${DATE}: Backup zabbix not succeed" >> ${MySQL_DUMP_PATH}/logs/ZabbixMysqlDump.log 50 | 51 | cd ${MySQL_DUMP_PATH}/ 52 | [ "$?" == 0 ] && rm -rf $(date +%Y-%m-%d --date='5 days ago') 53 | exit 0 54 | } 55 | 56 | MySQLImport () { 57 | cd ${MySQL_DUMP_PATH} 58 | DATE=$(ls ${MySQL_DUMP_PATH} |egrep "\b^[0-9]+-[0-9]+-[0-9]+$\b") 59 | echo -e "${green}${DATE}" 60 | echo -e "${blue}what DATE do you want to import,please input date:${NC}" 61 | read SELECT_DATE 62 | if [ -d "${SELECT_DATE}" ];then 63 | echo -e "you select is ${green}${SELECT_DATE}${NC}, do you want to contine,if,input ${red}(yes|y|Y)${NC},if other exit" 64 | read Input 65 | [[ 'yes|y|Y' =~ "${Input}" ]] 66 | status="$?" 67 | if [ "${status}" == "0" ];then 68 | echo "now import SQL....... Please wait......." 69 | else 70 | exit 1 71 | fi 72 | cd ${SELECT_DATE} 73 | for PER_TABEL_SQL in $(ls *.sql) 74 | do 75 | ${MYSQL_BIN_PATH} -u${MySQL_USER} -p${MySQL_PASSWORD} -h${MySQL_HOST} ${MySQL_DATABASE_NAME} < ${PER_TABEL_SQL} 76 | echo -e "import ${PER_TABEL_SQL} ${PURPLE}........................${NC}" 77 | done 78 | echo "Finish import SQL,Please check Zabbix database" 79 | else 80 | echo "Don't exist ${SELECT_DATE} DIR" 81 | fi 82 | } 83 | 84 | case "$1" in 85 | MySQLDUMP|mysqldump) 86 | MySQLDUMP 87 | ;; 88 | MySQLImport|mysqlimport) 89 | MySQLImport 90 | ;; 91 | *) 92 | echo "Usage: $0 {(MySQLDUMP|mysqldump) (MySQLImport|mysqlimport)}" 93 | ;; 94 | esac 95 | -------------------------------------------------------------------------------- /03-chapter/zabbix_install_on_ubuntu.md: -------------------------------------------------------------------------------- 1 | #Ubuntu下搭建Zabbix 2 | #一、操作系统的安装 3 | 安装Ubuntu,过程略 4 | #二、DEB源的配置 5 | 参考文档 6 | ``` 7 | https://www.zabbix.com/documentation/2.2/manual/installation/install_from_packages 8 | ``` 9 | 各版本的配置信息如下 10 | ``` 11 | Zabbix 2.2 for Debian 6: 12 | # wget http://repo.zabbix.com/zabbix/2.2/debian/pool/main/z/zabbix-release/zabbix-release_2.2-1+squeeze_all.deb 13 | # dpkg -i zabbix-release_2.2-1+squeeze_all.deb 14 | # apt-get update 15 | 16 | Zabbix 2.2 for Debian 7: 17 | # wget http://repo.zabbix.com/zabbix/2.2/debian/pool/main/z/zabbix-release/zabbix-release_2.2-1+wheezy_all.deb 18 | # dpkg -i zabbix-release_2.2-1+wheezy_all.deb 19 | # apt-get update 20 | 21 | Zabbix 2.2 for Ubuntu 12.04 LTS: 22 | # wget http://repo.zabbix.com/zabbix/2.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.2-1+precise_all.deb 23 | # dpkg -i zabbix-release_2.2-1+precise_all.deb 24 | # apt-get update 25 | 26 | Zabbix 2.2 for Ubuntu 14.04 LTS: 27 | # wget http://repo.zabbix.com/zabbix/2.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.2-1+trusty_all.deb 28 | # dpkg -i zabbix-release_2.2-1+trusty_all.deb 29 | # apt-get update 30 | 31 | #cat /etc/apt/sources.list.d/zabbix.list #源里面的记录如下 32 | deb http://repo.zabbix.com/zabbix/2.2/ubuntu trusty main 33 | deb-src http://repo.zabbix.com/zabbix/2.2/ubuntu trusty main 34 | ``` 35 | 安装Zabbix-Server 36 | 3.1、安装Zabbix-Server 37 | ``` 38 | # sudo apt-get install zabbix-server-mysql php5-mysql zabbix-frontend-php 39 | ``` 40 | 3.2、配置zabbix_server.conf 41 | ``` 42 | # vi /etc/zabbix/zabbix_server.conf 43 | DBHost=localhost 44 | DBName=zabbix 45 | DBUser=zabbix 46 | DBPassword=zabbix 47 | ``` 48 | 3.3、设置开机启动项 49 | ``` 50 | #vim /etc/default/zabbix-server 51 | START=yes 52 | ``` 53 | 3.4、启动zabbix-server服务 54 | ``` 55 | #sudo service zabbix-server start 56 | ``` 57 | 58 | 3.5、启动MySQL服务 59 | ``` 60 | #sudo service mysql start 61 | ``` 62 | 63 | 3.6、创建Zabbix数据库 64 | ``` 65 | # mysql -uroot 66 | mysql> create database zabbix character set utf8 collate utf8_bin; 67 | mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; 68 | mysql> flush privileges; 69 | ``` 70 | 3.7、导入Zabbix数据库 71 | ``` 72 | #cd /usr/share/zabbix-server-mysql/ 73 | #sudo gunzip *.gz 74 | #mysql -u zabbix -p zabbix < schema.sql 75 | #mysql -u zabbix -p zabbix < images.sql 76 | #mysql -u zabbix -p zabbix < data.sql 77 | 78 | 79 | #sudo cp /usr/share/doc/zabbix-frontend-php/examples/zabbix.conf.php.example /etc/zabbix/zabbix.conf.php 80 | #sudo cp /usr/share/doc/zabbix-frontend-php/examples/apache.conf /etc/apache2/sites-enabled/apache.conf 81 | # cat /etc/apache2/sites-enabled/apache.conf 82 | # Define /zabbix alias, this is the default 83 | 84 | php_value max_execution_time 300 85 | php_value memory_limit 128M 86 | php_value post_max_size 16M 87 | php_value upload_max_filesize 2M 88 | php_value max_input_time 300 89 | php_value date.timezone Europe/Riga 90 | Alias /zabbix /usr/share/zabbix 91 | 92 | ``` 93 | 启动apache 94 | ``` 95 | #sudo service apache2 restart 96 | ``` 97 | 98 | 3.8、配置Zabbix Web 99 | 配置Web的过程略,需要注意事项。 100 | 由于apache以www-data用户启动,而配置文件需要写道/etc/zabbix目录,所以需要对其授权。 101 | ``` 102 | #chown www-data.www.data /etc/zabbix -R 103 | ``` 104 | 在web页面安装完成后,可以将其权限改为Zabbix用户所有。 105 | ``` 106 | #chown zabbix.zabbix /etc/zabbix -R 107 | ``` 108 | 配置完成后, 109 | ``` 110 | #cat /etc/zabbix/zabbix.conf.php 111 | 131 | ``` 132 | 133 | 安装Zabbix-Agent 134 | ``` 135 | #sudo apt-get update 136 | #sudo apt-get install zabbix-agent 137 | #sudo vim /etc/zabbix/zabbix_agentd.conf 138 | Server=10.10.10.10 139 | Hostname=Web-DB-001 140 | #sudo service zabbix-agent restart 141 | ``` 142 | 143 | 144 | 145 | 登录Zabbix Web 146 | 访问http://10.10.10.10/zabbix 147 | Username = Admin 148 | Password = zabbix 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /06-chapter/python-argparse-1.2.1-2.el6.noarch.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/06-chapter/python-argparse-1.2.1-2.el6.noarch.rpm -------------------------------------------------------------------------------- /06-chapter/zabbix_sendmail.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #coding:utf-8 3 | #author: itnihao 4 | #mail: itnihao@qq.com 5 | #url: https://github.com/itnihao/zabbix-book/edit/master/06-chapter/zabbix_sendmail.py 6 | 7 | import smtplib 8 | from email.mime.text import MIMEText 9 | import os 10 | import argparse 11 | import logging 12 | import datetime 13 | 14 | mail_host = 'smtp.163.com' 15 | mail_user = 'monitor_itnihao' 16 | mail_pass = '123456' 17 | mail_postfix = '163.com' 18 | 19 | #mail_host='smtp.qq.com' 20 | #mail_user='itnihao' 21 | #mail_pass='123456' 22 | #mail_postfix='qq.com' 23 | 24 | def send_mail(mail_to,subject,content): 25 | me = mail_user+"<"+mail_user+"@"+mail_postfix+">" 26 | msg = MIMEText(content) 27 | msg['Subject'] = subject 28 | msg['From'] = me 29 | msg['to'] = mail_to 30 | global sendstatus 31 | global senderr 32 | 33 | try: 34 | smtp = smtplib.SMTP() 35 | smtp.connect(mail_host) 36 | smtp.login(mail_user,mail_pass) 37 | smtp.sendmail(me,mail_to,msg.as_string()) 38 | smtp.close() 39 | print 'send ok' 40 | sendstatus = True 41 | except Exception,e: 42 | senderr=str(e) 43 | print senderr 44 | sendstatus = False 45 | 46 | def logwrite(sendstatus,mail_to,content): 47 | logpath='/var/log/zabbix/alert' 48 | 49 | if not sendstatus: 50 | content = senderr 51 | 52 | if not os.path.isdir(logpath): 53 | os.makedirs(logpath) 54 | 55 | t=datetime.datetime.now() 56 | daytime=t.strftime('%Y-%m-%d') 57 | daylogfile=logpath+'/'+str(daytime)+'.log' 58 | logging.basicConfig(filename=daylogfile,level=logging.DEBUG) 59 | os.system('chown zabbix.zabbix {0}'.format(daylogfile)) 60 | logging.info('*'*130) 61 | logging.debug(str(t)+' mail send to {0},content is :\n {1}'.format(mail_to,content)) 62 | 63 | 64 | if __name__ == "__main__": 65 | parser = argparse.ArgumentParser(description='Send mail to user for zabbix alerting') 66 | parser.add_argument('mail_to',action="store", help='The address of the E-mail that send to user ') 67 | parser.add_argument('subject',action="store", help='The subject of the E-mail') 68 | parser.add_argument('content',action="store", help='The content of the E-mail') 69 | args = parser.parse_args() 70 | mail_to=args.mail_to 71 | subject=args.subject 72 | content=args.content 73 | 74 | send_mail(mail_to,subject,content) 75 | logwrite(sendstatus,mail_to,content) 76 | -------------------------------------------------------------------------------- /06-chapter/zabbix_sendmail_v2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #coding:utf-8 3 | #author: itnihao 4 | #mail: itnihao@qq.com 5 | #url: https://github.com/itnihao/zabbix-book/edit/master/06-chapter/zabbix_sendmail_v2.py 6 | 7 | import smtplib 8 | from email.mime.text import MIMEText 9 | import os 10 | import argparse 11 | import logging 12 | import datetime 13 | 14 | #QQ enterprise 15 | #smtp_server = 'smtp.exmail.qq.com' 16 | #smtp_port = 25 17 | #smtp_user = 'itnihao_zabbix@itnihao.com' 18 | #smtp_pass = '1234567890' 19 | 20 | #163 Mail 21 | #smtp_server = 'smtp.163.com' 22 | #smtp_port = 25 23 | #smtp_user = 'itnihao_zabbix@163.com' 24 | #smtp_pass = '1234567890' 25 | 26 | #QQ Mail 27 | smtp_server ='smtp.qq.com' 28 | smtp_port = 25 29 | smtp_user ='itnihao_zabbix@qq.com' 30 | smtp_pass ='1234567890' 31 | 32 | def send_mail(mail_to,subject,content): 33 | msg = MIMEText(content,_subtype='plain', _charset='utf-8') 34 | msg['Subject'] = unicode(subject,'UTF-8') 35 | msg['From'] = smtp_user 36 | msg['to'] = mail_to 37 | global sendstatus 38 | global senderr 39 | 40 | try: 41 | if smtp_port == 465: 42 | smtp = smtplib.SMTP_SSL() 43 | else: 44 | smtp = smtplib.SMTP() 45 | smtp.connect(smtp_server,smtp_port) 46 | smtp.login(smtp_user,smtp_pass) 47 | smtp.sendmail(smtp_user,mail_to,msg.as_string()) 48 | smtp.close() 49 | print 'send ok' 50 | sendstatus = True 51 | except Exception,e: 52 | senderr=str(e) 53 | print senderr 54 | sendstatus = False 55 | 56 | def logwrite(sendstatus,mail_to,content): 57 | logpath='/var/log/zabbix/alert' 58 | 59 | if not sendstatus: 60 | content = senderr 61 | 62 | if not os.path.isdir(logpath): 63 | os.makedirs(logpath) 64 | 65 | t=datetime.datetime.now() 66 | daytime=t.strftime('%Y-%m-%d') 67 | daylogfile=logpath+'/'+str(daytime)+'.log' 68 | logging.basicConfig(filename=daylogfile,level=logging.DEBUG) 69 | os.system('chown zabbix.zabbix {0}'.format(daylogfile)) 70 | logging.info('*'*130) 71 | logging.debug(str(t)+' mail send to {0},content is :\n {1}'.format(mail_to,content)) 72 | 73 | 74 | if __name__ == "__main__": 75 | parser = argparse.ArgumentParser(description='Send mail to user for zabbix alerting') 76 | parser.add_argument('mail_to',action="store", help='The address of the E-mail that send to user ') 77 | parser.add_argument('subject',action="store", help='The subject of the E-mail') 78 | parser.add_argument('content',action="store", help='The content of the E-mail') 79 | args = parser.parse_args() 80 | mail_to=args.mail_to 81 | subject=args.subject 82 | content=args.content 83 | 84 | send_mail(mail_to,subject,content) 85 | logwrite(sendstatus,mail_to,content) 86 | -------------------------------------------------------------------------------- /09-chapter/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/README.md -------------------------------------------------------------------------------- /09-chapter/SaltStack/README.txt: -------------------------------------------------------------------------------- 1 | ``` 2 | shell#rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm 3 | ``` 4 | ##install salt-master 5 | ``` 6 | shell#yum install salt-master 7 | ``` 8 | 9 | ##install salt-minion 10 | ``` 11 | shell#yum install salt-minion 12 | ``` 13 | #configuration salt-minion 14 | ``` 15 | shell#vim /etc/salt/minion 16 | master: salt-master.itnihao.com #master IP or DNS 17 | id: zabbix-agent.itnihao.com #minion ID 18 | ``` 19 | 20 | 21 | #salt-key 22 | ``` 23 | shell#salt-key -a zabbix-agent.itnihao.com 24 | ``` 25 | 26 | 27 | 28 | #top.sls 29 | ``` 30 | shell#mkdir /srv/salt/ 31 | ``` 32 | 33 | #highstate 34 | ``` 35 | shell#salt '*' state.highstate 36 | ``` 37 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/top.sls: -------------------------------------------------------------------------------- 1 | base: 2 | '*.itnihao.com': 3 | - zabbix 4 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf: -------------------------------------------------------------------------------- 1 | # This is a config file for the Zabbix agent daemon (Unix) 2 | # To get more information about Zabbix, visit http://www.zabbix.com 3 | 4 | ############ GENERAL PARAMETERS ################# 5 | 6 | ### Option: PidFile 7 | # Name of PID file. 8 | # 9 | # Mandatory: no 10 | # Default: 11 | PidFile=/var/run/zabbix/zabbix_agentd.pid 12 | 13 | ### Option: LogFile 14 | # Name of log file. 15 | # If not set, syslog is used. 16 | # 17 | # Mandatory: no 18 | # Default: 19 | # LogFile= 20 | 21 | LogFile=/var/log/zabbix/zabbix_agentd.log 22 | 23 | ### Option: LogFileSize 24 | # Maximum size of log file in MB. 25 | # 0 - disable automatic log rotation. 26 | # 27 | # Mandatory: no 28 | # Range: 0-1024 29 | # Default: 30 | LogFileSize=10 31 | 32 | ### Option: DebugLevel 33 | # Specifies debug level 34 | # 0 - no debug 35 | # 1 - critical information 36 | # 2 - error information 37 | # 3 - warnings 38 | # 4 - for debugging (produces lots of information) 39 | # 40 | # Mandatory: no 41 | # Range: 0-4 42 | # Default: 43 | # DebugLevel=3 44 | 45 | ### Option: SourceIP 46 | # Source IP address for outgoing connections. 47 | # 48 | # Mandatory: no 49 | # Default: 50 | # SourceIP= 51 | 52 | ### Option: EnableRemoteCommands 53 | # Whether remote commands from Zabbix server are allowed. 54 | # 0 - not allowed 55 | # 1 - allowed 56 | # 57 | # Mandatory: no 58 | # Default: 59 | EnableRemoteCommands=1 60 | 61 | ### Option: LogRemoteCommands 62 | # Enable logging of executed shell commands as warnings. 63 | # 0 - disabled 64 | # 1 - enabled 65 | # 66 | # Mandatory: no 67 | # Default: 68 | LogRemoteCommands=1 69 | 70 | ##### Passive checks related 71 | 72 | ### Option: Server 73 | # List of comma delimited IP addresses (or hostnames) of Zabbix servers. 74 | # Incoming connections will be accepted only from the hosts listed here. 75 | # If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally. 76 | # 77 | # Mandatory: no 78 | # Default: 79 | # Server= 80 | 81 | Server=127.0.0.1,10.10.10.1 82 | 83 | ### Option: ListenPort 84 | # Agent will listen on this port for connections from the server. 85 | # 86 | # Mandatory: no 87 | # Range: 1024-32767 88 | # Default: 89 | # ListenPort=10050 90 | 91 | ### Option: ListenIP 92 | # List of comma delimited IP addresses that the agent should listen on. 93 | # First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks. 94 | # 95 | # Mandatory: no 96 | # Default: 97 | # ListenIP=0.0.0.0 98 | 99 | ### Option: StartAgents 100 | # Number of pre-forked instances of zabbix_agentd that process passive checks. 101 | # If set to 0, disables passive checks and the agent will not listen on any TCP port. 102 | # 103 | # Mandatory: no 104 | # Range: 0-100 105 | # Default: 106 | # StartAgents=3 107 | StartAgents=5 108 | 109 | 110 | ##### Active checks related 111 | 112 | ### Option: ServerActive 113 | # List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks. 114 | # If port is not specified, default port is used. 115 | # IPv6 addresses must be enclosed in square brackets if port for that host is specified. 116 | # If port is not specified, square brackets for IPv6 addresses are optional. 117 | # If this parameter is not specified, active checks are disabled. 118 | # Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1] 119 | # 120 | # Mandatory: no 121 | # Default: 122 | # ServerActive= 123 | 124 | ServerActive=127.0.0.1:10051,10.10.10.1:10051 125 | 126 | ### Option: Hostname 127 | # Unique, case sensitive hostname. 128 | # Required for active checks and must match hostname as configured on the server. 129 | # Value is acquired from HostnameItem if undefined. 130 | # 131 | # Mandatory: no 132 | # Default: 133 | # Hostname= 134 | 135 | Hostname=zabbix-master.itnihao.com 136 | 137 | ### Option: HostnameItem 138 | # Item used for generating Hostname if it is undefined. Ignored if Hostname is defined. 139 | # Does not support UserParameters or aliases. 140 | # 141 | # Mandatory: no 142 | # Default: 143 | # HostnameItem=system.hostname 144 | 145 | ### Option: HostMetadata 146 | # Optional parameter that defines host metadata. 147 | # Host metadata is used at host auto-registration process. 148 | # An agent will issue an error and not start if the value is over limit of 255 characters. 149 | # If not defined, value will be acquired from HostMetadataItem. 150 | # 151 | # Mandatory: no 152 | # Range: 0-255 characters 153 | # Default: 154 | # HostMetadata= 155 | 156 | ### Option: HostMetadataItem 157 | # Optional parameter that defines an item used for getting host metadata. 158 | # Host metadata is used at host auto-registration process. 159 | # During an auto-registration request an agent will log a warning message if 160 | # the value returned by specified item is over limit of 255 characters. 161 | # This option is only used when HostMetadata is not defined. 162 | # 163 | # Mandatory: no 164 | # Default: 165 | # HostMetadataItem= 166 | 167 | ### Option: RefreshActiveChecks 168 | # How often list of active checks is refreshed, in seconds. 169 | # 170 | # Mandatory: no 171 | # Range: 60-3600 172 | # Default: 173 | # RefreshActiveChecks=120 174 | 175 | ### Option: BufferSend 176 | # Do not keep data longer than N seconds in buffer. 177 | # 178 | # Mandatory: no 179 | # Range: 1-3600 180 | # Default: 181 | # BufferSend=5 182 | 183 | ### Option: BufferSize 184 | # Maximum number of values in a memory buffer. The agent will send 185 | # all collected data to Zabbix Server or Proxy if the buffer is full. 186 | # 187 | # Mandatory: no 188 | # Range: 2-65535 189 | # Default: 190 | # BufferSize=100 191 | 192 | ### Option: MaxLinesPerSecond 193 | # Maximum number of new lines the agent will send per second to Zabbix Server 194 | # or Proxy processing 'log' and 'logrt' active checks. 195 | # The provided value will be overridden by the parameter 'maxlines', 196 | # provided in 'log' or 'logrt' item keys. 197 | # 198 | # Mandatory: no 199 | # Range: 1-1000 200 | # Default: 201 | # MaxLinesPerSecond=100 202 | 203 | ############ ADVANCED PARAMETERS ################# 204 | 205 | ### Option: Alias 206 | # Sets an alias for an item key. It can be used to substitute long and complex item key with a smaller and simpler one. 207 | # Multiple Alias parameters may be present. Multiple parameters with the same Alias key are not allowed. 208 | # Different Alias keys may reference the same item key. 209 | # For example, to retrieve the ID of user 'zabbix': 210 | # Alias=zabbix.userid:vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1] 211 | # Now shorthand key zabbix.userid may be used to retrieve data. 212 | # Aliases can be used in HostMetadataItem but not in HostnameItem parameters. 213 | # 214 | # Mandatory: no 215 | # Range: 216 | # Default: 217 | 218 | ### Option: Timeout 219 | # Spend no more than Timeout seconds on processing 220 | # 221 | # Mandatory: no 222 | # Range: 1-30 223 | # Default: 224 | # Timeout=3 225 | 226 | ### Option: AllowRoot 227 | # Allow the agent to run as 'root'. If disabled and the agent is started by 'root', the agent 228 | # will try to switch to user 'zabbix' instead. Has no effect if started under a regular user. 229 | # 0 - do not allow 230 | # 1 - allow 231 | # 232 | # Mandatory: no 233 | # Default: 234 | # AllowRoot=0 235 | 236 | ### Option: Include 237 | # You may include individual files or all files in a directory in the configuration file. 238 | # Installing Zabbix will create include directory in /usr/etc, unless modified during the compile time. 239 | # 240 | # Mandatory: no 241 | # Default: 242 | # Include= 243 | 244 | # Include=/usr/etc/zabbix_agentd.userparams.conf 245 | # Include=/usr/etc/zabbix_agentd.conf.d/ 246 | Include=/etc/zabbix/zabbix_agentd.conf.d/ 247 | 248 | 249 | ####### USER-DEFINED MONITORED PARAMETERS ####### 250 | 251 | ### Option: UnsafeUserParameters 252 | # Allow all characters to be passed in arguments to user-defined parameters. 253 | # 0 - do not allow 254 | # 1 - allow 255 | # 256 | # Mandatory: no 257 | # Range: 0-1 258 | # Default: 259 | # UnsafeUserParameters=0 260 | UnsafeUserParameters=1 261 | 262 | 263 | ### Option: UserParameter 264 | # User-defined parameter to monitor. There can be several user-defined parameters. 265 | # Format: UserParameter=, 266 | # See 'zabbix_agentd' directory for examples. 267 | # 268 | # Mandatory: no 269 | # Default: 270 | # UserParameter= 271 | 272 | ####### LOADABLE MODULES ####### 273 | 274 | ### Option: LoadModulePath 275 | # Full path to location of agent modules. 276 | # Default depends on compilation options. 277 | # 278 | # Mandatory: no 279 | # Default: 280 | # LoadModulePath=${libdir}/modules 281 | 282 | ### Option: LoadModule 283 | # Module to load at agent startup. Modules are used to extend functionality of the agent. 284 | # Format: LoadModule= 285 | # The modules must be located in directory specified by LoadModulePath. 286 | # It is allowed to include multiple LoadModule parameters. 287 | # 288 | # Mandatory: no 289 | # Default: 290 | # LoadModule= 291 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/get_os_type.conf: -------------------------------------------------------------------------------- 1 | UserParameter=get.os.type,head -1 /etc/issue 2 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/haproxy_host_status.conf: -------------------------------------------------------------------------------- 1 | UserParameter=haproxy.host.status,/etc/zabbix/scripts/haproxy_host_status status $1 2 | UserParameter=haproxy.host.qcur[*],/etc/zabbix/scripts/haproxy_host_status host_qcur $1 3 | UserParameter=haproxy.host.qmax[*],/etc/zabbix/scripts/haproxy_host_status host_qmax $1 4 | UserParameter=haproxy.host.scur[*],/etc/zabbix/scripts/haproxy_host_status host_scur $1 5 | UserParameter=haproxy.host.smax[*],/etc/zabbix/scripts/haproxy_host_status host_smax $1 6 | UserParameter=haproxy.host.stot[*],/etc/zabbix/scripts/haproxy_host_status host_stot $1 7 | UserParameter=haproxy.host.bytes_in[*],/etc/zabbix/scripts/haproxy_host_status host_bytes_in $1 8 | UserParameter=haproxy.host.bytes_out[*],/etc/zabbix/scripts/haproxy_host_status host_bytes_out $1 9 | UserParameter=haproxy.host.err_conn[*],/etc/zabbix/scripts/haproxy_host_status host_err_conn $1 10 | UserParameter=haproxy.host.err_resp[*],/etc/zabbix/scripts/haproxy_host_status host_err_resp $1 11 | UserParameter=haproxy.host.warn_retr[*],/etc/zabbix/scripts/haproxy_host_status host_warn_retr $1 12 | UserParameter=haproxy.host.warn_redis[*],/etc/zabbix/scripts/haproxy_host_status host_warn_redis $1 13 | UserParameter=haproxy.host.down_cur[*],/etc/zabbix/scripts/haproxy_host_status host_down_cur $1 14 | UserParameter=haproxy.host.down_tot[*],/etc/zabbix/scripts/haproxy_host_status host_down_tot $1 15 | UserParameter=haproxy.host.uptime_cur[*],/etc/zabbix/scripts/haproxy_host_status host_uptime_cur $1 16 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/haproxy_main_status.conf: -------------------------------------------------------------------------------- 1 | UserParameter=haproxy.fend.tatus[*],/etc/zabbix/scripts/haproxy_main_status fend_tatus $1 2 | UserParameter=haproxy.fend.scur[*],/etc/zabbix/scripts/haproxy_main_status fend_scur $1 3 | UserParameter=haproxy.fend.smax[*],/etc/zabbix/scripts/haproxy_main_status fend_smax $1 4 | UserParameter=haproxy.fend.stot[*],/etc/zabbix/scripts/haproxy_main_status fend_stot $1 5 | UserParameter=haproxy.fend.bytes_in[*],/etc/zabbix/scripts/haproxy_main_status fend_bytes_in $1 6 | UserParameter=haproxy.fend.bytes_out[*],/etc/zabbix/scripts/haproxy_main_status fend_bytes_out $1 7 | UserParameter=haproxy.fend.err_req[*],/etc/zabbix/scripts/haproxy_main_status fend_err_req $1 8 | UserParameter=haproxy.bend.status[*],/etc/zabbix/scripts/haproxy_main_status bend_status $1 9 | UserParameter=haproxy.bend.qcur[*],/etc/zabbix/scripts/haproxy_main_status bend_qcur $1 10 | UserParameter=haproxy.bend.qmax[*],/etc/zabbix/scripts/haproxy_main_status bend_qmax $1 11 | UserParameter=haproxy.bend.scur[*],/etc/zabbix/scripts/haproxy_main_status bend_scur $1 12 | UserParameter=haproxy.bend.smax[*],/etc/zabbix/scripts/haproxy_main_status bend_smax $1 13 | UserParameter=haproxy.bend.stot[*],/etc/zabbix/scripts/haproxy_main_status bend_stot $1 14 | UserParameter=haproxy.bend.bytes_in[*],/etc/zabbix/scripts/haproxy_main_status bend_bytes_in $1 15 | UserParameter=haproxy.bend.bytes_out[*],/etc/zabbix/scripts/haproxy_main_status bend_bytes_out $1 16 | UserParameter=haproxy.bend.err_conn[*],/etc/zabbix/scripts/haproxy_main_status bend_err_conn $1 17 | UserParameter=haproxy.bend.err_resp[*],/etc/zabbix/scripts/haproxy_main_status bend_err_resp $1 18 | UserParameter=haproxy.bend.warn_retr[*],/etc/zabbix/scripts/haproxy_main_status bend_warn_retr $1 19 | UserParameter=haproxy.bend.warn_redis[*],/etc/zabbix/scripts/haproxy_main_status bend_warn_redis $1 20 | UserParameter=haproxy.bend.down_cur[*],/etc/zabbix/scripts/haproxy_main_status bend_down_cur $1 21 | UserParameter=haproxy.bend.down_tot[*],/etc/zabbix/scripts/haproxy_main_status bend_down_tot $1 22 | UserParameter=haproxy.bend.uptime_cur[*],/etc/zabbix/scripts/haproxy_main_status bend_uptime_cur $1 23 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/haproxy_status_discovery.conf: -------------------------------------------------------------------------------- 1 | UserParameter=haproxy.front.discovery,/etc/zabbix/scripts/haproxy_status_discovery haproxy_front_discovery 2 | UserParameter=haproxy.backend.discovery,/etc/zabbix/scripts/haproxy_status_discovery haproxy_backend_discovery 3 | UserParameter=haproxy.backendhost.discovery,/etc/zabbix/scripts/haproxy_status_discovery haproxy_backendhost_discovery 4 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/harddisk_status.conf: -------------------------------------------------------------------------------- 1 | #discovery hard disk 2 | UserParameter=custom.vfs.discovery.diskname[*],/etc/zabbix/scripts/diskio.pl 3 | #disk status 4 | UserParameter=custom.vfs.dev.major[*],/etc/zabbix/scripts/diskio.pl $1 MAJOR 5 | UserParameter=custom.vfs.dev.minor[*],/etc/zabbix/scripts/diskio.pl $1 MINOR 6 | UserParameter=custom.vfs.dev.read.completed[*],/etc/zabbix/scripts/diskio.pl $1 READS_COMPLETED 7 | UserParameter=custom.vfs.dev.read.merged[*],/etc/zabbix/scripts/diskio.pl $1 READS_MERGED 8 | UserParameter=custom.vfs.dev.read.sectors[*],/etc/zabbix/scripts/diskio.pl $1 READS_SECTORS 9 | UserParameter=custom.vfs.dev.read.time[*],/etc/zabbix/scripts/diskio.pl $1 READS_TIME 10 | UserParameter=custom.vfs.dev.writes.completed[*],/etc/zabbix/scripts/diskio.pl $1 WRITES_COMPLETED 11 | UserParameter=custom.vfs.dev.writes.merged[*],/etc/zabbix/scripts/diskio.pl $1 WRITES_MERGED 12 | UserParameter=custom.vfs.dev.writes.sectors[*],/etc/zabbix/scripts/diskio.pl $1 WRITES_SECTORS 13 | UserParameter=custom.vfs.dev.writes.time[*],/etc/zabbix/scripts/diskio.pl $1 WRITES_TIME 14 | UserParameter=custom.vfs.dev.io.queue[*],/etc/zabbix/scripts/diskio.pl $1 IO_QUEUE 15 | UserParameter=custom.vfs.dev.io.time[*],/etc/zabbix/scripts/diskio.pl $1 IO_TIME 16 | UserParameter=custom.vfs.dev.wio.time[*],/etc/zabbix/scripts/diskio.pl $1 WIO_TIME 17 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/ipvs_monitor.conf: -------------------------------------------------------------------------------- 1 | UserParameter=lvs.connect.activeconn,/etc/zabbix/scripts/ipvs_monitor ActiveConn 2 | UserParameter=lvs.connect.inactconn,/etc/zabbix/scripts/ipvs_monitor InActConn 3 | UserParameter=lvs.connect.realhostnum,/etc/zabbix/scripts/ipvs_monitor HostNum 4 | UserParameter=lvs.connect.viportnum,/etc/zabbix/scripts/ipvs_monitor VipPortNum 5 | UserParameter=lvs.connect.usedhostportnum,/etc/zabbix/scripts/ipvs_monitor UsedHostNum 6 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/monitor_mysql_status.conf: -------------------------------------------------------------------------------- 1 | UserParameter=mysql.Open_tables,/etc/zabbix/scripts/mysql.py Open_tables 2 | UserParameter=mysql.Opened_tables,/etc/zabbix/scripts/mysql.py Opened_tables 3 | UserParameter=mysql.Max_used_connections,/etc/zabbix/scripts/mysql.py Max_used_connections 4 | UserParameter=mysql.Threads_connected,/etc/zabbix/scripts/mysql.py Threads_connected 5 | UserParameter=mysql.Qcache_free_blocks,/etc/zabbix/scripts/mysql.py Qcache_free_blocks 6 | UserParameter=mysql.Qcache_total_blocks,/etc/zabbix/scripts/mysql.py Qcache_total_blocks 7 | UserParameter=mysql.Handler_read_first,/etc/zabbix/scripts/mysql.py Handler_read_first 8 | UserParameter=mysql.Handler_read_key,/etc/zabbix/scripts/mysql.py Handler_read_key 9 | UserParameter=mysql.Handler_read_rnd_next,/etc/zabbix/scripts/mysql.py Handler_read_rnd_next 10 | UserParameter=mysql.Slow_queries,/etc/zabbix/scripts/mysql.py Slow_queries 11 | UserParameter=mysql.Table_locks_waited,/etc/zabbix/scripts/mysql.py Table_locks_waited 12 | UserParameter=mysql.Threads_running,/etc/zabbix/scripts/mysql.py Threads_running 13 | UserParameter=mysql.Uptime,/etc/zabbix/scripts/mysql.py Uptime 14 | UserParameter=mysql.Qcache_hits,/etc/zabbix/scripts/mysql.py Qcache_hits 15 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/monitor_phpfpm_status.conf: -------------------------------------------------------------------------------- 1 | UserParameter=phpfpm.status.pool,/etc/zabbix/scripts/monitor_phpfpm_status pool 2 | UserParameter=phpfpm.status.process.manager,/etc/zabbix/scripts/monitor_phpfpm_status process_manager 3 | UserParameter=phpfpm.status.start.since,/etc/zabbix/scripts/monitor_phpfpm_status start_since 4 | UserParameter=phpfpm.status.accepted.conn,/etc/zabbix/scripts/monitor_phpfpm_status accepted_conn 5 | UserParameter=phpfpm.status.listen.queue,/etc/zabbix/scripts/monitor_phpfpm_status listen_queue 6 | UserParameter=phpfpm.status.max.listen.queue,/etc/zabbix/scripts/monitor_phpfpm_status max_listen_queue 7 | UserParameter=phpfpm.status.listen.queue.len,/etc/zabbix/scripts/monitor_phpfpm_status listen_queue_len 8 | UserParameter=phpfpm.status.idle.processes,/etc/zabbix/scripts/monitor_phpfpm_status idle_processes 9 | UserParameter=phpfpm.status.active.processes,/etc/zabbix/scripts/monitor_phpfpm_status active_processes 10 | UserParameter=phpfpm.status.total.processes,/etc/zabbix/scripts/monitor_phpfpm_status total_processes 11 | UserParameter=phpfpm.status.max.active.processes,/etc/zabbix/scripts/monitor_phpfpm_status max_active_processes 12 | UserParameter=phpfpm.status.max.children.reached,/etc/zabbix/scripts/monitor_phpfpm_status max_children_reached 13 | #php-fpm.conf里面添加如下 14 | ############################################################################### 15 | #pm.status_path = /phpfpmstatus 16 | ############################################################################### 17 | #nginx.conf配置如下 18 | ############################################################################### 19 | #http{ 20 | #.................. 21 | #server { 22 | # listen 127.0.0.1:80; 23 | # server_name 127.0.0.1; 24 | # location ~ ^/(phpfpmstatus)$ { 25 | # include fastcgi_params; 26 | # fastcgi_pass unix:/tmp/fpm.sock; 27 | # #fastcgi_pass 127.0.0.1:9000; 28 | # fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; 29 | # } 30 | #} 31 | #................ 32 | #} 33 | ############################################################################### 34 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/monitor_website_status.conf: -------------------------------------------------------------------------------- 1 | UserParameter=iqm.web.monitor.basehtmlspeed[*],/etc/zabbix/scripts/monitor_website_status.py basehtmlspeed $1 2 | UserParameter=iqm.web.monitor.status[*],/etc/zabbix/scripts/monitor_website_status.py status $1 3 | UserParameter=iqm.web.monitor.dnstime[*],/etc/zabbix/scripts/monitor_website_status.py dnstime $1 4 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/mysql_status.conf: -------------------------------------------------------------------------------- 1 | 2 | ## For Tribily's MySQL Extended Role 3 | UserParameter=mysql.ping,/usr/bin/mysqladmin -uzabbix -pzabbix ping|grep alive|wc -l 4 | UserParameter=mysql.uptime,/usr/bin/mysqladmin -uzabbix -pzabbix status|cut -f2 -d":"|cut -f1 -d"T" 5 | UserParameter=mysql.threads,/usr/bin/mysqladmin -uzabbix -pzabbix status|cut -f3 -d":"|cut -f1 -d"Q" 6 | UserParameter=mysql.questions,/usr/bin/mysqladmin -uzabbix -pzabbix status|cut -f4 -d":"|cut -f1 -d"S" 7 | UserParameter=mysql.slowqueries,/usr/bin/mysqladmin -uzabbix -pzabbix status|cut -f5 -d":"|cut -f1 -d"O" 8 | UserParameter=mysql.qps,/usr/bin/mysqladmin -uzabbix -pzabbix status|cut -f9 -d":" 9 | UserParameter=mysql.version,mysql -V | cut -f6 -d" " | sed 's/,//' 10 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/nginx_status.conf: -------------------------------------------------------------------------------- 1 | UserParameter=nginx.accepts,/etc/zabbix/scripts/nginx_status accepts 2 | UserParameter=nginx.handled,/etc/zabbix/scripts/nginx_status handled 3 | UserParameter=nginx.requests,/etc/zabbix/scripts/nginx_status requests 4 | UserParameter=nginx.connections.active,/etc/zabbix/scripts/nginx_status active 5 | UserParameter=nginx.connections.reading,/etc/zabbix/scripts/nginx_status reading 6 | UserParameter=nginx.connections.writing,/etc/zabbix/scripts/nginx_status writing 7 | UserParameter=nginx.connections.waiting,/etc/zabbix/scripts/nginx_status waiting 8 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/redis.conf: -------------------------------------------------------------------------------- 1 | UserParameter=redis.port.discovery,/etc/zabbix/scripts/redis redis_discovery 2 | UserParameter=redis.port.monitor[*],/etc/zabbix/scripts/redis redis_monitor $1 3 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/tcp_connect.conf: -------------------------------------------------------------------------------- 1 | UserParameter=tcp_connect.established,/etc/zabbix/scripts/tcp_connect established 2 | UserParameter=tcp_connect.listen,/etc/zabbix/scripts/tcp_connect listen 3 | UserParameter=tcp_connect.timewait,/etc/zabbix/scripts/tcp_connect timewait 4 | UserParameter=tcp_connect.timeclose,/etc/zabbix/scripts/tcp_connect timeclose 5 | UserParameter=tcp_connect.finwait1,/etc/zabbix/scripts/tcp_connect finwait1 6 | UserParameter=tcp_connect.finwait2,/etc/zabbix/scripts/tcp_connect finwait2 7 | UserParameter=tcp_connect.synsent,/etc/zabbix/scripts/tcp_connect synsent 8 | UserParameter=tcp_connect.synrecv,/etc/zabbix/scripts/tcp_connect synrecv 9 | UserParameter=tcp_connect.closewait,/etc/zabbix/scripts/tcp_connect closewait 10 | 11 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/conf/zabbix_agentd.conf.d/web_site_discovery.conf: -------------------------------------------------------------------------------- 1 | UserParameter=web.site.discovery,/etc/zabbix/scripts/web_site_code_status web_site_discovery 2 | UserParameter=web.site.code[*],/etc/zabbix/scripts/web_site_code_status web_site_code $1 3 | #/etc/zabbix/scripts/web_site_code_status web_site_code $1 $2 4 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/init.sls: -------------------------------------------------------------------------------- 1 | zabbix-agent: 2 | service: 3 | - running 4 | - watch: 5 | - file: zabbix_agentd.conf 6 | - file: zabbix_agentd.conf.d 7 | - pkg: zabbix-agentd 8 | require: 9 | - pkg: zabbix-agent 10 | 11 | zabbix-agentd: 12 | pkg.installed: 13 | - name: zabbix-agent 14 | - version: '2.2.2-0.el6.zbx' 15 | - skip_verify: True 16 | - skip_suggestions: True 17 | - fromrepo: zabbix 18 | - refresh: True 19 | 20 | zabbix_agentd.conf: 21 | file.managed: 22 | - name: /etc/zabbix/zabbix_agentd.conf 23 | - source: salt://zabbix/conf/zabbix_agentd.conf 24 | - mode: 644 25 | - user: zabbix 26 | - group: zabbix 27 | - template: jinja 28 | 29 | zabbix_agentd.conf.d: 30 | file.recurse: 31 | - name: /etc/zabbix/zabbix_agentd.conf.d 32 | - source: salt://zabbix/conf/zabbix_agentd.conf.d 33 | - include_empty: True 34 | - user: zabbix 35 | - group: zabbix 36 | - dir_mode: 755 37 | - file_mode: 644 38 | - template: jinja 39 | 40 | scripts: 41 | file.recurse: 42 | - name: /etc/zabbix/scripts 43 | - source: salt://zabbix/scripts 44 | - include_empty: True 45 | - user: zabbix 46 | - group: zabbix 47 | - dir_mode: 755 48 | - file_mode: 700 49 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/WEB.txt: -------------------------------------------------------------------------------- 1 | www.qq.com 2 | www.baidu.com 3 | 4 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/diskio.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | #The slution is in https://www.zabbix.com/forum/showthread.php?t=26756 3 | #admin@itnihao.com modified it at 2013-01-30 4 | 5 | $first = 1; 6 | 7 | $dm_device = $ARGV[0]; 8 | $dm_info = $ARGV[1]; 9 | 10 | if (!$dm_device) { 11 | $exec = "grep '\\b[a-z][a-z][a-z]\\b' /proc/diskstats"; 12 | } else { 13 | $exec = "grep \"\\b$dm_device\\b\" /proc/diskstats" 14 | } 15 | 16 | if (!$dm_info) { 17 | print "{\n"; 18 | print "\t\"data\":[\n\n"; 19 | 20 | for (`$exec` ) { 21 | ( $major_number, 22 | $minor_number, 23 | $dm_name, 24 | $reads_completed, 25 | $reads_merged, 26 | $reads_sectors, 27 | $reads_time, 28 | $writes_completed, 29 | $writes_merged, 30 | $writes_sectors, 31 | $writes_time, 32 | $io_queue, 33 | $io_time, 34 | $weighted_io_time 35 | ) = m/ +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+)/; 36 | 37 | print "\t\n" if not $first; 38 | $first = 0; 39 | 40 | print "\t\t{"; 41 | print " \"{#DISKNAME}\":\"$dm_name\""; 42 | print "\t},"; 43 | } 44 | print "\n\t]\n"; 45 | print "}\n"; 46 | } else { 47 | 48 | for (`$exec` ) { 49 | ( $major_number, 50 | $minor_number, 51 | $dm_name, 52 | $reads_completed, 53 | $reads_merged, 54 | $reads_sectors, 55 | $reads_time, 56 | $writes_completed, 57 | $writes_merged, 58 | $writes_sectors, 59 | $writes_time, 60 | $io_queue, 61 | $io_time, 62 | $weighted_io_time 63 | ) = m/ +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+)/; 64 | 65 | } 66 | if ($dm_info eq "MAJOR") {print $major_number;} 67 | elsif ($dm_info eq "MINOR") {print $minor_number;} 68 | elsif ($dm_info eq "DISKNAME") {print $dm_name;} 69 | elsif ($dm_info eq "READS_COMPLETED") {print $reads_completed;} 70 | elsif ($dm_info eq "READS_MERGED") {print $reads_merged;} 71 | elsif ($dm_info eq "READS_SECTORS") {print $reads_sectors;} 72 | elsif ($dm_info eq "READS_TIME") {print $reads_time;} 73 | elsif ($dm_info eq "WRITES_COMPLETED") {print $writes_completed;} 74 | elsif ($dm_info eq "WRITES_MERGED") {print $writes_merged;} 75 | elsif ($dm_info eq "WRITES_SECTORS") {print $writes_sectors;} 76 | elsif ($dm_info eq "WRITES_TIME") {print $writes_time;} 77 | elsif ($dm_info eq "IO_QUEUE") {print $io_queue;} 78 | elsif ($dm_info eq "IO_TIME") {print $io_time;} 79 | elsif ($dm_info eq "WIO_TIME") {print $weighted_io_time;} 80 | else {print "ERROR: Chose one of the following info:\n MAJOR MINOR DISKNAME READS_COMPLETED READS_MERGED READS_SECTORS READS_TIME WRITES_COMPLETED WRITES_MERGED WRITES_SECTORS WRITES_TIME IO_QUEUE IO_TIME WIO_TIME\n";} 81 | } 82 | 83 | ################################################ 84 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/diskio.trapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ################################################################# 3 | # Zabbix trapper monitor 4 | ##### 5 | # Version: 0.1 - 20011/08/09 6 | # Author: Jean Baptiste Favre < jean-baptiste.favre@iscool-e.com> 7 | ##### 8 | # Version: 0.2 - 20012/05/04 9 | # Author: Charles-Christian Croix < karles@karlesnine.com > 10 | ##### 11 | # Changelog: 12 | # - v0.1: replace (ugly) vfs.fs.size & custom.vfs.dev.* metrics 13 | # from customs checks to zabbix trapper implementation 14 | # - v0.2: add inode support 15 | # change ItemName to custom.ItemName 16 | # change /dev/sd* devise support to /dev/xvd* (ubuntu LTS 12.04) 17 | ################################################################# 18 | # vfs.fs.size metrics 19 | df -Pk | awk ' /^\/dev\// { 20 | print "- custom.vfs.fs.size[" $6 ",total] " $2 21 | print "- custom.vfs.fs.size[" $6 ",used] " $3 22 | print "- custom.vfs.fs.size[" $6 ",free] " $4 23 | print "- custom.vfs.fs.size[" $6 ",pfree] " 100 - $5 24 | print "- custom.vfs.fs.size[" $6 ",pused] " 0 + $5 25 | }' 26 | # vfs.fs.inode metrics 27 | df -Pki | awk ' /^\/dev\// { 28 | print "- custom.vfs.fs.inode[" $6 ",total] " $2 29 | print "- custom.vfs.fs.inode[" $6 ",used] " $3 30 | print "- custom.vfs.fs.inode[" $6 ",free] " $4 31 | print "- custom.vfs.fs.inode[" $6 ",pfree] " 100 - $5 32 | print "- custom.vfs.fs.inode[" $6 ",pused] " 0 + $5 33 | }' 34 | # custom.vfs.dev. 35 | grep xvd /proc/diskstats | awk '{ 36 | if ( $3=="xvda1" ) 37 | disk = "xvda" 38 | else 39 | disk = $3 40 | print "- custom.vfs.dev.io.active["disk"] "$12 41 | print "- custom.vfs.dev.io.ms["disk"] "$13 42 | print "- custom.vfs.dev.read.ms["disk"] "$7 43 | print "- custom.vfs.dev.read.ops["disk"] "$4 44 | print "- custom.vfs.dev.read.sectors["disk"] "$6 45 | print "- custom.vfs.dev.write.ms["disk"] "$11 46 | print "- custom.vfs.dev.write.ops["disk"] "$8 47 | print "- custom.vfs.dev.write.sectors["disk"] "$10 48 | }' 49 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/haproxy_host_status: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Script to fetch haproxy statuses for tribily monitoring systems 3 | # Author: krish@tribily.com 4 | # License: GPLv2 5 | 6 | # Set Variables 7 | IPADDR="www.itnihao.com" 8 | PORT="80" 9 | DATE=`date +%Y%m%d` 10 | #http://www.itnihao.com/backend/haproxy-stats;csv 11 | cd /tmp/ 12 | wget --http-user=itnihao --http-password=itnihao $IPADDR:$PORT/backend/haproxy-stats\;csv -O haproxy_stats_$DATE.host.csv -o /dev/null 13 | FILE="/tmp/haproxy_stats_$DATE.host.csv" 14 | 15 | # Write the functions 16 | 17 | # Status of Servers 18 | function host_status { 19 | grep "$1," $FILE | cut -f18 -d,|sort|uniq 20 | } 21 | 22 | # Queue Informations 23 | function host_qcur { 24 | grep "$1," $FILE | cut -f3 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 25 | } 26 | function host_qmax { 27 | grep "$1," $FILE | cut -f4 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 28 | } 29 | 30 | # Session Informations 31 | function host_scur { 32 | grep "$1," $FILE | cut -f5 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 33 | } 34 | function host_smax { 35 | grep "$1," $FILE | cut -f6 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 36 | } 37 | function host_stot { 38 | grep "$1," $FILE | cut -f8 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 39 | } 40 | # Traffic Information 41 | function host_bytes_in { 42 | grep "$1," $FILE | cut -f9 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 43 | } 44 | function host_bytes_out { 45 | grep "$1," $FILE | cut -f10 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 46 | } 47 | 48 | # Error Information 49 | function host_err_conn { 50 | grep "$1," $FILE | cut -f14 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 51 | } 52 | function host_err_resp { 53 | grep "$1," $FILE | cut -f15 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 54 | } 55 | # Warning Information 56 | function host_warn_retr { 57 | grep "$1," $FILE | cut -f16 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 58 | } 59 | function host_warn_redis { 60 | grep "$1," $FILE | cut -f17 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 61 | } 62 | # Downtime Information 63 | function host_down_cur { 64 | STATUS=$(grep "$1," $FILE | cut -f18 -d,|sort|uniq) 65 | if [ "$STATUS" == "DOWN" ] 66 | then 67 | grep "$1," $FILE | cut -f24 -d,|sort|uniq 68 | else 69 | echo "0" 70 | fi 71 | } 72 | function host_down_tot { 73 | grep "$1," $FILE | cut -f25 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 74 | } 75 | 76 | # Uptime Information 77 | function host_uptime_cur { 78 | STATUS=`grep "$1," $FILE | cut -f18 -d,`|sort|uniq 79 | if [ "$STATUS" == "UP" ] 80 | then 81 | grep "$1," $FILE | cut -f24 -d,|awk 'BEGIN{total=0}{total=total+$1}END{print total }' 82 | else 83 | echo "0" 84 | fi 85 | } 86 | 87 | # Version Information 88 | # Donot edit this section ever 89 | function tribily_ver { 90 | VERSION="1.0" 91 | echo ${VERSION} 92 | } 93 | 94 | 95 | 96 | # Run the requested function 97 | case "$1" in 98 | host_status) 99 | host_status $2 100 | ;; 101 | host_qcur) 102 | host_qcur $2 103 | ;; 104 | host_qmax) 105 | host_qmax $2 106 | ;; 107 | host_scur) 108 | host_scur $2 109 | ;; 110 | host_smax) 111 | host_smax $2 112 | ;; 113 | host_stot) 114 | host_stot $2 115 | ;; 116 | host_bytes_in) 117 | host_bytes_in $2 118 | ;; 119 | host_bytes_out) 120 | host_bytes_out $2 121 | ;; 122 | host_err_conn) 123 | host_err_conn $2 124 | ;; 125 | host_err_resp) 126 | host_err_resp $2 127 | ;; 128 | host_warn_retr) 129 | host_warn_retr $2 130 | ;; 131 | host_warn_redis) 132 | host_warn_redis $2 133 | ;; 134 | host_down_cur) 135 | host_down_cur $2 136 | ;; 137 | host_down_tot) 138 | host_down_tot $2 139 | ;; 140 | host_uptime_cur) 141 | host_uptime_cur $2 142 | ;; 143 | *) 144 | echo "Useage $0 {host_status|host_qcur|host_qmax|host_scur|host_smax|host_stot|host_bytes_in|host_bytes_out|host_err_conn|host_err_resp|host_warn_retr|host_warn_redis|host_down_cur|host_down_tot|host_uptime_cur} " 145 | ;; 146 | esac 147 | # Clean up 148 | #/bin/rm $FILE 149 | 150 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/haproxy_main_status: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Script to fetch haproxy statuses for tribily monitoring systems 3 | # Author: krish@tribily.com 4 | # License: GPLv2 5 | 6 | # Set Variables 7 | IPADDR="www.itnihao.com" 8 | PORT="80" 9 | DATE=`date +%Y%m%d` 10 | #http://www.itnihao.com/backend/haproxy-stats;csv 11 | cd /tmp/ 12 | wget --http-user=itnihao --http-password=itnihao $IPADDR:$PORT/backend/haproxy-stats\;csv -O haproxy_stats_$DATE.main.csv -o /dev/null 13 | FILE="/tmp/haproxy_stats_$DATE.main.csv" 14 | 15 | # Write the functions 16 | 17 | # Status of Servers 18 | function fend_status { 19 | grep "$1," $FILE | grep FRONTEND | cut -f18 -d, 20 | } 21 | function bend_status { 22 | grep "$1," $FILE | grep BACKEND | cut -f18 -d, 23 | } 24 | 25 | # Queue Informations 26 | function bend_qcur { 27 | grep "$1," $FILE | grep BACKEND | cut -f3 -d, 28 | } 29 | function bend_qmax { 30 | grep "$1," $FILE | grep BACKEND | cut -f4 -d, 31 | } 32 | 33 | # Session Informations 34 | function fend_scur { 35 | grep "$1," $FILE | grep FRONTEND | cut -f5 -d, 36 | } 37 | function fend_smax { 38 | grep "$1," $FILE | grep FRONTEND | cut -f6 -d, 39 | } 40 | function bend_scur { 41 | grep "$1," $FILE | grep BACKEND | cut -f5 -d, 42 | } 43 | function bend_smax { 44 | grep "$1," $FILE | grep BACKEND | cut -f6 -d, 45 | } 46 | function fend_stot { 47 | grep "$1," $FILE | grep FRONTEND | cut -f8 -d, 48 | } 49 | function bend_stot { 50 | grep "$1," $FILE | grep BACKEND | cut -f8 -d, 51 | } 52 | # Traffic Information 53 | function fend_bytes_in { 54 | grep "$1," $FILE | grep FRONTEND | cut -f9 -d, 55 | } 56 | function fend_bytes_out { 57 | grep "$1," $FILE | grep FRONTEND | cut -f10 -d, 58 | } 59 | function bend_bytes_in { 60 | grep "$1," $FILE | grep BACKEND | cut -f9 -d, 61 | } 62 | function bend_bytes_out { 63 | grep "$1," $FILE | grep BACKEND | cut -f10 -d, 64 | } 65 | 66 | # Error Information 67 | function fend_err_req { 68 | grep "$1," $FILE | grep FRONTEND | cut -f13 -d, 69 | } 70 | function bend_err_conn { 71 | grep "$1," $FILE | grep BACKEND | cut -f14 -d, 72 | } 73 | function bend_err_resp { 74 | grep "$1," $FILE | grep BACKEND | cut -f15 -d, 75 | } 76 | # Warning Information 77 | function bend_warn_retr { 78 | grep "$1," $FILE | grep BACKEND | cut -f16 -d, 79 | } 80 | function bend_warn_redis { 81 | grep "$1," $FILE | grep BACKEND | cut -f17 -d, 82 | } 83 | # Downtime Information 84 | function bend_down_cur { 85 | STATUS=$(grep "$1," $FILE | grep BACKEND | cut -f18 -d,) 86 | if [ "$STATUS" == "DOWN" ] 87 | then 88 | grep "$1," $FILE | grep BACKEND | cut -f24 -d, 89 | else 90 | echo "0" 91 | fi 92 | } 93 | function bend_down_tot { 94 | grep "$1," $FILE | grep BACKEND | cut -f25 -d, 95 | } 96 | 97 | # Uptime Information 98 | function bend_uptime_cur { 99 | STATUS=`grep "$1," $FILE | grep BACKEND | cut -f18 -d,` 100 | if [ "$STATUS" == "UP" ] 101 | then 102 | grep "$1," $FILE | grep BACKEND | cut -f24 -d, 103 | else 104 | echo "0" 105 | fi 106 | } 107 | 108 | # Version Information 109 | # Donot edit this section ever 110 | function tribily_ver { 111 | VERSION="1.0" 112 | echo ${VERSION} 113 | } 114 | 115 | 116 | 117 | # Run the requested function 118 | case "$1" in 119 | fend_status) 120 | fend_status $2 121 | ;; 122 | bend_status) 123 | bend_status $2 124 | ;; 125 | bend_qcur) 126 | bend_qcur $2 127 | ;; 128 | bend_qmax) 129 | bend_qmax $2 130 | ;; 131 | fend_scur) 132 | fend_scur $2 133 | ;; 134 | fend_smax) 135 | fend_smax $2 136 | ;; 137 | bend_scur) 138 | bend_scur $2 139 | ;; 140 | bend_smax) 141 | bend_smax $2 142 | ;; 143 | fend_stot) 144 | fend_stot $2 145 | ;; 146 | bend_stot) 147 | bend_stot $2 148 | ;; 149 | fend_bytes_in) 150 | fend_bytes_in $2 151 | ;; 152 | fend_bytes_out) 153 | fend_bytes_out $2 154 | ;; 155 | bend_bytes_in) 156 | bend_bytes_in $2 157 | ;; 158 | bend_bytes_out) 159 | bend_bytes_out $2 160 | ;; 161 | fend_err_req) 162 | fend_err_req $2 163 | ;; 164 | bend_err_conn) 165 | bend_err_conn $2 166 | ;; 167 | bend_err_resp) 168 | bend_err_resp $2 169 | ;; 170 | bend_warn_retr) 171 | bend_warn_retr $2 172 | ;; 173 | bend_warn_redis) 174 | bend_warn_redis $2 175 | ;; 176 | bend_down_cur) 177 | bend_down_cur $2 178 | ;; 179 | bend_down_tot) 180 | bend_down_tot $2 181 | ;; 182 | bend_uptime_cur) 183 | bend_uptime_cur $2 184 | ;; 185 | *) 186 | echo "Useage $0 {fend_status|bend_status|bend_qcur|bend_qmax|fend_scur|fend_smax|bend_scur|bend_smax|fend_stot|bend_stot|fend_bytes_in|fend_bytes_out|bend_bytes_in|bend_bytes_out|fend_err_req|bend_err_conn|bend_err_resp|bend_warn_retr|bend_warn_redis|bend_down_cur|bend_down_tot|bend_uptime_cur} " 187 | ;; 188 | esac 189 | # Clean up 190 | #/bin/rm $FILE 191 | 192 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/haproxy_status_discovery: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # function:monitor tcp connect status from zabbix 4 | # License: GPL 5 | # mail:itnihao@163.com 6 | # version:1.0 date:2013-01-17 7 | source /etc/bashrc >/dev/null 2>&1 8 | source /etc/profile >/dev/null 2>&1 9 | 10 | IPADDR="www.itnihao.com" 11 | PORT="80" 12 | DATE=`date +%Y%m%d` 13 | cd /tmp/ 14 | wget --http-user=itnihao --http-password=itnihao $IPADDR:$PORT/backend/haproxy-stats\;csv -O haproxy_stats_$DATE.discovery.csv -o /dev/null 15 | FILE="/tmp/haproxy_stats_$DATE.discovery.csv" 16 | 17 | haproxy_front_discovery () { 18 | FRONTEND=($(awk -F"," '/FRONTEND/ {print $1}' ${FILE})) 19 | printf '{\n' 20 | printf '\t"data":[\n' 21 | for((i=0;i<${#FRONTEND[@]};++i)) 22 | { 23 | num=$(echo $((${#FRONTEND[@]}-1))) 24 | if [ "$i" != ${num} ]; 25 | then 26 | printf "\t\t{ \n" 27 | printf "\t\t\t\"{#FRONTEND}\":\"${FRONTEND[$i]}\"},\n" 28 | else 29 | printf "\t\t{ \n" 30 | printf "\t\t\t\"{#FRONTEND}\":\"${FRONTEND[$num]}\"}]}\n" 31 | fi 32 | } 33 | } 34 | 35 | haproxy_backend_discovery () { 36 | BACKEND=($(awk -F"," '/BACKEND/ {print $1}' ${FILE})) 37 | printf '{\n' 38 | printf '\t"data":[\n' 39 | for((i=0;i<${#BACKEND[@]};++i)) 40 | { 41 | num=$(echo $((${#BACKEND[@]}-1))) 42 | if [ "$i" != ${num} ]; 43 | then 44 | printf "\t\t{ \n" 45 | printf "\t\t\t\"{#BACKEND}\":\"${BACKEND[$i]}\"},\n" 46 | else 47 | printf "\t\t{ \n" 48 | printf "\t\t\t\"{#BACKEND}\":\"${BACKEND[$num]}\"}]}\n" 49 | fi 50 | } 51 | } 52 | haproxy_backendhost_discovery () { 53 | BACKENDHOST=($(awk -F"," '($2 !~ /BACKEND|FRONTEND/ && $1 !~ /#/) {print $2}' ${FILE}|sort|uniq)) 54 | printf '{\n' 55 | printf '\t"data":[\n' 56 | for((i=0;i<${#BACKENDHOST[@]};++i)) 57 | { 58 | num=$(echo $((${#BACKENDHOST[@]}-1))) 59 | if [ "$i" != ${num} ]; 60 | then 61 | printf "\t\t{ \n" 62 | printf "\t\t\t\"{#BACKENDHOST}\":\"${BACKENDHOST[$i]}\"},\n" 63 | else 64 | printf "\t\t{ \n" 65 | printf "\t\t\t\"{#BACKENDHOST}\":\"${BACKENDHOST[$num]}\"}]}\n" 66 | fi 67 | } 68 | } 69 | 70 | case "$1" in 71 | haproxy_front_discovery) 72 | haproxy_front_discovery 73 | ;; 74 | haproxy_backend_discovery) 75 | haproxy_backend_discovery 76 | ;; 77 | haproxy_backendhost_discovery) 78 | haproxy_backendhost_discovery 79 | ;; 80 | *) 81 | echo "Usage:$0 {haproxy_front_discovery|haproxy_backend_discovery|haproxy_backendhost_discovery}" 82 | ;; 83 | esac 84 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/ipvs_monitor: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # function:monitor lvs connect status from zabbix 3 | # License: GPL 4 | # mail:admin@itnihao.com 5 | # version:1.0 date:2013-01-22 6 | 7 | ActiveConn () { 8 | awk '/->/ {sum+=$5} END { print sum-1}' /proc/net/ip_vs 9 | } 10 | InActConn () { 11 | awk '/->/ {sum+=$6} END { print sum-1}' /proc/net/ip_vs 12 | } 13 | HostNum () { 14 | LVSLOG=$(mktemp /var/log/zabbix/lvs.XXXXXX) 15 | for name in $(awk '/->/ {print $2}' /proc/net/ip_vs|sort|uniq) 16 | do 17 | echo $name | awk '{for(i=1;i<=NF;i++) $i=strtonum("0x"$i);print}' FIELDWIDTHS="2 2 2 2" OFS="." >>${LVSLOG} 18 | done 19 | 20 | sort ${LVSLOG}|uniq|wc -l 21 | rm ${LVSLOG} 22 | } 23 | VipPortNum () { 24 | awk -F" |:" '/TCP/ {print $4}' /proc/net/ip_vs|sort|uniq|wc -l 25 | } 26 | UsedHostNum () { 27 | awk '/->/ && ($2 ~ "[0-9]") && ($5 !~ 0) {print $0}' /proc/net/ip_vs|wc -l 28 | } 29 | case "$1" in 30 | ActiveConn) 31 | ActiveConn 32 | ;; 33 | InActConn) 34 | InActConn 35 | ;; 36 | HostNum) 37 | HostNum 38 | ;; 39 | VipPortNum) 40 | VipPortNum 41 | ;; 42 | UsedHostNum) 43 | UsedHostNum 44 | ;; 45 | *) 46 | echo "Usage $0 {ActiveConn|InActConn|host_num|vip_port_num}" 47 | esac 48 | 49 | 50 | 51 | #awk '/->/ ($2 != RemoteAddress) {sum+=$4} END { print "Sum = ",sum}' /proc/net/ip_vs 52 | #echo '101.64.178.198' | awk -F'.' '{ for(i=1;i<=NF;i++){printf("%X", $i);if(i!=NF){printf("")}} }' 53 | #echo "6540B2C6" | awk '{for(i=1;i<=NF;i++) $i=strtonum("0x"$i);print}' FIELDWIDTHS="2 2 2 2" OFS="." 54 | 55 | 56 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/monitor_phpfpm_status: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # function:monitor php-fpm status from zabbix 4 | # License: GPL 5 | # mail:admin@itnihao.com 6 | # date:2013-05-30 7 | 8 | source /etc/bashrc >/dev/null 2>&1 9 | source /etc/profile >/dev/null 2>&1 10 | 11 | LOG_FILE=/var/log/zabbix/phpfpmstatus.log 12 | curl http://127.0.0.1/phpfpmstatus >${LOG_FILE} 2>&1 13 | 14 | pool(){ 15 | awk '/pool/ {print $NF}' ${LOG_FILE} 16 | } 17 | process_manager() { 18 | awk '/process manager/ {print $NF}' ${LOG_FILE} 19 | } 20 | 21 | start_since(){ 22 | awk '/^start since:/ {print $NF}' ${LOG_FILE} 23 | } 24 | accepted_conn(){ 25 | awk '/^accepted conn:/ {print $NF}' ${LOG_FILE} 26 | } 27 | listen_queue(){ 28 | awk '/^listen queue:/ {print $NF}' ${LOG_FILE} 29 | } 30 | max_listen_queue(){ 31 | awk '/^max listen queue:/ {print $NF}' ${LOG_FILE} 32 | } 33 | listen_queue_len(){ 34 | awk '/^listen queue len:/ {print $NF}' ${LOG_FILE} 35 | } 36 | idle_processes(){ 37 | awk '/^idle processes:/ {print $NF}' ${LOG_FILE} 38 | } 39 | active_processes(){ 40 | awk '/^active processes:/ {print $NF}' ${LOG_FILE} 41 | } 42 | total_processes(){ 43 | awk '/^total processes:/ {print $NF}' ${LOG_FILE} 44 | } 45 | max_active_processes(){ 46 | awk '/^max active processes:/ {print $NF}' ${LOG_FILE} 47 | } 48 | max_children_reached(){ 49 | awk '/^max children reached:/ {print $NF}' ${LOG_FILE} 50 | } 51 | 52 | 53 | case "$1" in 54 | pool) 55 | pool 56 | ;; 57 | process_manager) 58 | process_manager 59 | ;; 60 | start_since) 61 | start_since 62 | ;; 63 | accepted_conn) 64 | accepted_conn 65 | ;; 66 | listen_queue) 67 | listen_queue 68 | ;; 69 | max_listen_queue) 70 | max_listen_queue 71 | ;; 72 | listen_queue_len) 73 | listen_queue_len 74 | ;; 75 | idle_processes) 76 | idle_processes 77 | ;; 78 | active_processes) 79 | active_processes 80 | ;; 81 | total_processes) 82 | total_processes 83 | ;; 84 | max_active_processes) 85 | max_active_processes 86 | ;; 87 | max_children_reached) 88 | max_children_reached 89 | ;; 90 | *) 91 | echo "Usage: $0 {pool|process_manager|start_since|accepted_conn|listen_queue|max_listen_queue|listen_queue_len|idle_processes|active_processes|total_processes|max_active_processes|max_children_reached}" 92 | esac 93 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/monitor_website_status.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf8 3 | # Filename: monitor_idc.py 4 | # Last modified: 2013-04-23 16:54 5 | # Author: itnihao 6 | # Mail: admin@itnihao.com 7 | # Description: 8 | 9 | import urllib, urllib2,sys,re 10 | 11 | monitor_item = sys.argv[1] 12 | idc = sys.argv[2] 13 | url = "http://www.iqm.cn/index.php/Member/RTTask/getmonitorInfoByAjax" 14 | page_url = "http://www.iqm.cn/index.php/Member/RTTask" 15 | web_monitor = "http://testidc.orshsoft.com" 16 | data = "monitorip="+idc + "&url="+web_monitor+"&host=0.0.0.0&bandwidth=512&task_type=get" 17 | data = data.encode("utf8") 18 | 19 | def web_site_status(): 20 | request = urllib2.Request(url,data) 21 | opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) 22 | response = opener.open(request) 23 | the_page = response.read() 24 | values = eval(the_page) 25 | #for v in values: 26 | # for i in v: 27 | # print i, "-------------",v[i] 28 | for v in values: 29 | code=v["time"] 30 | pat = re.compile(r'HTTP.+?OK') 31 | code_status= re.findall(pat, code) 32 | if monitor_item == "status": 33 | print str(code_status)[13:16] 34 | else: 35 | print v[monitor_item] 36 | 37 | 38 | 39 | def idc_site(): 40 | s=urllib2.urlopen(page_url).read() 41 | pat=re.compile(r'type="checkbox" value=".+?[0-9]+" id=') 42 | urls= re.findall(pat, s) 43 | for i in urls: 44 | i=i.replace('type="checkbox" value="', '') 45 | idc= i.replace('" id=', '') 46 | print idc 47 | 48 | 49 | #idc_site() 50 | web_site_status() 51 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/monitor_website_status.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/SaltStack/srv/salt/zabbix/scripts/monitor_website_status.pyc -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/monitor_website_status.pyo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/SaltStack/srv/salt/zabbix/scripts/monitor_website_status.pyo -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/mysql.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | #File:mysql_status.py 4 | import MySQLdb,sys 5 | #your 6 | user = 'zabbix' 7 | passwd = 'zabbix' 8 | status = sys.argv[1] 9 | try: 10 | conn = MySQLdb.connect(host = 'localhost',user = user,passwd = passwd,connect_timeout = 2) 11 | cursor = conn.cursor() 12 | sql = "SHOW STATUS" 13 | cursor.execute(sql) 14 | alldata = cursor.fetchall() 15 | for data in alldata: 16 | if data[0] == status : 17 | #print data[0],data[1] 18 | print data[1] 19 | break 20 | cursor.close() 21 | conn.close() 22 | except Exception, e: 23 | print e 24 | sys.exit() 25 | 26 | ''' 27 | Open_tables 28 | Opened_tables 29 | Max_used_connections 30 | Threads_connected 31 | Qcache_free_blocks 32 | Qcache_total_blocks 33 | Handler_read_first 34 | Handler_read_key 35 | Handler_read_rnd_next 36 | Slow_queries 37 | ''' 38 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/mysql.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/SaltStack/srv/salt/zabbix/scripts/mysql.pyc -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/mysql.pyo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/SaltStack/srv/salt/zabbix/scripts/mysql.pyo -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/nginx_status: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/SaltStack/srv/salt/zabbix/scripts/nginx_status -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/redis: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # function:monitor redisstatus from zabbix 3 | # License: GPL 4 | # mail:admin@itnihao.com 5 | # version:1.0 date:2013-02-04 6 | 7 | redis_discovery () { 8 | port=($(/bin/netstat -nlput|awk -F":" '/redis/ {print $0}'|awk -F: '{print $2}'|awk '{print $1}'|grep -v "^$")) 9 | [ "${port[0]}" == "" ] && exit 10 | printf '{\n' 11 | printf '\t"data":[\n' 12 | for((i=0;i<${#port[@]};++i)) 13 | { 14 | num=$(echo $((${#port[@]}-1))) 15 | if [ "$i" != ${num} ]; 16 | then 17 | printf "\t\t{ \n" 18 | printf "\t\t\t\"{#REDISPORT}\":\"${port[$i]}\"},\n" 19 | else 20 | printf "\t\t{ \n" 21 | printf "\t\t\t\"{#REDISPORT}\":\"${port[$num]}\"}]}\n" 22 | fi 23 | } 24 | } 25 | 26 | redis_monitor() { 27 | PORT=$(/bin/netstat -nlput|awk -F":" '/redis/ {print $0}'|grep "$1"|awk -F: '{print $2}'|awk '{print $1}') 28 | if [ "$PORT" != "$1" ] 29 | then 30 | echo 0 31 | elif 32 | [ "$PORT" == "$1" ] 33 | then 34 | echo 1 35 | else 36 | echo 2 37 | fi 38 | } 39 | 40 | case "$1" in 41 | redis_discovery) 42 | redis_discovery 43 | ;; 44 | redis_monitor) 45 | redis_monitor $2 46 | ;; 47 | *) 48 | echo "Usage: $0 {redis_discovery}" 49 | ;; 50 | esac 51 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/tcp_connect: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # function:monitor tcp connect status from zabbix 4 | # License: GPL 5 | # mail:admin@itnihao.com 6 | # version:1.0 date:2012-12-09 7 | # version:1.1 date:2013-01-15 8 | 9 | source /etc/bashrc >/dev/null 2>&1 10 | source /etc/profile >/dev/null 2>&1 11 | LOG_FILE=/var/log/zabbix/tcp_connect.log 12 | 13 | netstat -n|awk '/^tcp/ {++S[$NF]} END {for (a in S) print a,S[a]}'>${LOG_FILE} 14 | Permission=$(ls -l ${LOG_FILE} |awk '{print $3}') 15 | [ "$Permission" != zabbix ] && chown zabbix.zabbix /var/log/zabbix/* 16 | 17 | #Functions to return tcp connect status 18 | 19 | established () { 20 | VALUE=$(awk '/ESTABLISHED/ {print $2}' ${LOG_FILE}) 21 | [ "${VALUE}" != "" ] && echo ${VALUE}|| echo 0 22 | } 23 | listen () { 24 | VALUE=$(awk '/LISTEN/ {print $2}' ${LOG_FILE}) 25 | [ "${VALUE}" != "" ] && echo ${VALUE}|| echo 0 26 | } 27 | timewait () { 28 | VALUE=$(awk '/TIME_WAIT/ {print $2}' ${LOG_FILE}) 29 | [ "${VALUE}" != "" ] && echo ${VALUE}|| echo 0 30 | } 31 | timeclose () { 32 | VALUE=$(awk '/TIME_CLOSE/ {print $2}' ${LOG_FILE}) 33 | [ "${VALUE}" != "" ] && echo ${VALUE}|| echo 0 34 | } 35 | finwait1 () { 36 | VALUE=$(awk '/FIN_WAIT1/ {print $2}' ${LOG_FILE}) 37 | [ "${VALUE}" != "" ] && echo ${VALUE}|| echo 0 38 | } 39 | 40 | finwait2 () { 41 | VALUE=$(awk '/FIN_WAIT2/ {print $2}' ${LOG_FILE}) 42 | [ "${VALUE}" != "" ] && echo ${VALUE}|| echo 0 43 | } 44 | 45 | synsent () { 46 | VALUE=$(awk '/SYN_SENT/ {print $2}' ${LOG_FILE}) 47 | [ "${VALUE}" != "" ] && echo ${VALUE}|| echo 0 48 | } 49 | synrecv () { 50 | VALUE=$(awk '/SYN_RECV/ {print $2}' ${LOG_FILE}) 51 | [ "${VALUE}" != "" ] && echo ${VALUE}|| echo 0 52 | } 53 | closewait () { 54 | VALUE=$(awk '/CLOSE_WAIT/ {print $2}' ${LOG_FILE}) 55 | [ "${VALUE}" != "" ] && echo ${VALUE}|| echo 0 56 | } 57 | 58 | # Run the requested function 59 | case "$1" in 60 | established) 61 | established 62 | ;; 63 | listen) 64 | listen 65 | ;; 66 | timewait) 67 | timewait 68 | ;; 69 | timeclose) 70 | timeclose 71 | ;; 72 | finwait1) 73 | finwait1 74 | ;; 75 | finwait2) 76 | finwait2 77 | ;; 78 | synsent) 79 | synsent 80 | ;; 81 | synrecv) 82 | synrecv 83 | ;; 84 | closewait) 85 | closewait 86 | ;; 87 | *) 88 | echo "Usage: $0 { established|listen|timewait|timeclose|finwait1|finwait2|synsent|synrecv|closewait}" 89 | ;; 90 | esac 91 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/web_discovery_low.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf8 3 | # Last modified: 2013-04-12 14:47 4 | # Author: itnihao 5 | # Mail: admin@itnihao.com 6 | 7 | import os 8 | import json 9 | 10 | r=open('WEB.txt','r').read().split() 11 | devices = [] 12 | 13 | for devpath in r: 14 | device = os.path.basename(devpath) 15 | devices += [{'{#SITENAME}':device}] 16 | 17 | print json.dumps({'data':devices},sort_keys=True,indent=7,separators=(',',':')) 18 | 19 | -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/web_discovery_low.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/SaltStack/srv/salt/zabbix/scripts/web_discovery_low.pyc -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/web_discovery_low.pyo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/SaltStack/srv/salt/zabbix/scripts/web_discovery_low.pyo -------------------------------------------------------------------------------- /09-chapter/SaltStack/srv/salt/zabbix/scripts/web_site_code_status: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # function:monitor tcp connect status from zabbix 4 | # License: GPL 5 | # mail:admin@itnihao.com 6 | # version:1.0 date:2013-01-16 7 | 8 | source /etc/bashrc >/dev/null 2>&1 9 | source /etc/profile >/dev/null 2>&1 10 | [ -f /etc/zabbix/scripts/WEB.txt ] 11 | [ "$?" != 0 ] && touch /etc/zabbix/scripts/WEB.txt 12 | 13 | #/usr/bin/curl -o /dev/null -s -w %{http_code} http://$1/ 14 | WEB_SITE_discovery () { 15 | WEB_SITE=($(cat /etc/zabbix/scripts/WEB.txt|grep -v "^#")) 16 | printf '{\n' 17 | printf '\t"data":[\n' 18 | for((i=0;i<${#WEB_SITE[@]};++i)) 19 | { 20 | num=$(echo $((${#WEB_SITE[@]}-1))) 21 | if [ "$i" != ${num} ]; 22 | then 23 | printf "\t\t{ \n" 24 | printf "\t\t\t\"{#SITENAME}\":\"${WEB_SITE[$i]}\"},\n" 25 | else 26 | printf "\t\t{ \n" 27 | printf "\t\t\t\"{#SITENAME}\":\"${WEB_SITE[$num]}\"}]}\n" 28 | fi 29 | } 30 | } 31 | web_site_code () { 32 | /usr/bin/curl -o /dev/null -s -w %{http_code} http://$1/ 33 | } 34 | case "$1" in 35 | web_site_discovery) 36 | WEB_SITE_discovery 37 | ;; 38 | web_site_code) 39 | web_site_code $2 40 | ;; 41 | *) 42 | echo "Usage:$0 {web_site_discovery|web_site_code [URL]}" 43 | ;; 44 | esac 45 | -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/low_level_discovery/bind_file_system_not_display/001.png -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/README.md: -------------------------------------------------------------------------------- 1 | #解决的问题 2 | Zabbix对文件系统的监控,是通过LLD来自动添加实现的,在通过Zabbix监控bind服务器的文件系统时,当bind启用了chroot,会把chroot的目录给监控上,但这个目录是虚拟的,不具备参考意义,所以需要重新定义LLD的规则(把原先的文件系统LLD规则停用) 3 | #用法 4 | ##1.脚本的存放位置 5 | ``` 6 | shell# tree /etc/zabbix/ 7 | /etc/zabbix/ 8 | ├── scripts 9 | │   ├── \ 10 | │   └── fileSystemDiscoveryNotBind.py #权限775 11 | ├── zabbix_agentd.conf 12 | └── zabbix_agentd.d 13 | ├── fileSystemDiscoveryNotBind.conf 14 | └── userparameter_mysql.conf 15 | ``` 16 | 如图所示 17 | ![图1](img/000-2.png) 18 | 19 | ##2.测试 20 | shell# zabbix_get -s 127.0.0.1 -k bind.vfs.fs.discovery 21 | ``` 22 | { 23 | "data":[ 24 | { 25 | "{#FSNAME}":"/", 26 | "{#FSTYPE}":"rootfs" 27 | }, 28 | { 29 | "{#FSNAME}":"/proc", 30 | "{#FSTYPE}":"proc" 31 | }, 32 | { 33 | "{#FSNAME}":"/sys", 34 | "{#FSTYPE}":"sysfs" 35 | }, 36 | { 37 | "{#FSNAME}":"/dev", 38 | "{#FSTYPE}":"devtmpfs" 39 | }, 40 | { 41 | "{#FSNAME}":"/dev/pts", 42 | "{#FSTYPE}":"devpts" 43 | }, 44 | { 45 | "{#FSNAME}":"/dev/shm", 46 | "{#FSTYPE}":"tmpfs" 47 | }, 48 | { 49 | "{#FSNAME}":"/", 50 | "{#FSTYPE}":"ext4" 51 | }, 52 | { 53 | "{#FSNAME}":"/proc/bus/usb", 54 | "{#FSTYPE}":"usbfs" 55 | }, 56 | { 57 | "{#FSNAME}":"/boot", 58 | "{#FSTYPE}":"ext4" 59 | }, 60 | { 61 | "{#FSNAME}":"/data", 62 | "{#FSTYPE}":"ext4" 63 | }, 64 | { 65 | "{#FSNAME}":"/proc/sys/fs/binfmt_misc", 66 | "{#FSTYPE}":"binfmt_misc" 67 | } 68 | ] 69 | } 70 | ``` 71 | ##3.导入模板 72 | Configration-Templates-Import-选择zbx_export_templates_not_bind_dir_LLD.xml 73 | ##创建Discovery rule (模板里面已经存在) 74 | ![图1](img/000-0.png) 75 | ##创建Item prototypes (模板里面已经存在) 76 | ![图1](img/000-1.png) 77 | ### 78 | ##4.将模板Template OS Linux not bind dir链接到bind所在的主机 79 | 注意:需要将Template OS Linux去掉(Unlink and clear) 80 | 81 | #现象以及原因的深度剖析 82 | ### 83 | 现在,我们有个需求,就是要去掉对bind-chroot目录的监控,即以下的目录 84 | ``` 85 | /var/named/chroot/etc/named 86 | /var/named/chroot/var/named 87 | /var/named/chroot/etc/named.conf 88 | /var/named/chroot/etc/named.rfc1912.zones 89 | /var/named/chroot/etc/rndc.key 90 | /var/named/chroot/usr/lib64/bind 91 | /var/named/chroot/etc/named.iscdlv.key 92 | /var/named/chroot/etc/named.root.key 93 | ``` 94 | 95 | ### 在Zabbix的Web界面,可以看到LLD添加的bind-chroot分区监控 96 | ![图1](img/001.png) 97 | 98 | 99 | ![图2](img/002.png) 100 | 101 | 102 | ![图3](img/003.png) 103 | 104 | 105 | ###从代码分析 106 | shell#vim zabbix-2.2.4/src/libs/zbxsysinfo/linux/diskspace.c 107 | ``` 108 | int VFS_FS_DISCOVERY(AGENT_REQUEST *request, AGENT_RESULT *result) 109 | { 110 | int ret = SYSINFO_RET_FAIL; 111 | char line[MAX_STRING_LEN], *p, *mpoint, *mtype; 112 | FILE *f; 113 | struct zbx_json j; 114 | zbx_json_init(&j, ZBX_JSON_STAT_BUF_LEN); 115 | zbx_json_addarray(&j, ZBX_PROTO_TAG_DATA); 116 | if (NULL != (f = fopen("/proc/mounts", "r"))) 117 | { 118 | while (NULL != fgets(line, sizeof(line), f)) 119 | { 120 | if (NULL == (p = strchr(line, ' '))) 121 | continue; 122 | mpoint = ++p; 123 | if (NULL == (p = strchr(mpoint, ' '))) 124 | continue; 125 | *p = '\0'; 126 | mtype = ++p; 127 | if (NULL == (p = strchr(mtype, ' '))) 128 | continue; 129 | *p = '\0'; 130 | zbx_json_addobject(&j, NULL); 131 | zbx_json_addstring(&j, "{#FSNAME}", mpoint, ZBX_JSON_TYPE_STRING); 132 | zbx_json_addstring(&j, "{#FSTYPE}", mtype, ZBX_JSON_TYPE_STRING); 133 | zbx_json_close(&j); 134 | } 135 | zbx_fclose(f); 136 | ret = SYSINFO_RET_OK; 137 | } 138 | ``` 139 | 140 | ![图4](img/004.png) 141 | 142 | ![图5](img/005.png) 143 | -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/img/000-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/low_level_discovery/bind_file_system_not_display/img/000-0.png -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/img/000-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/low_level_discovery/bind_file_system_not_display/img/000-1.png -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/img/000-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/low_level_discovery/bind_file_system_not_display/img/000-2.png -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/img/001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/low_level_discovery/bind_file_system_not_display/img/001.png -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/img/002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/low_level_discovery/bind_file_system_not_display/img/002.png -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/img/003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/low_level_discovery/bind_file_system_not_display/img/003.png -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/img/004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/low_level_discovery/bind_file_system_not_display/img/004.png -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/img/005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/09-chapter/low_level_discovery/bind_file_system_not_display/img/005.png -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/scripts/\: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf8 3 | # Last modified: 2013-04-12 14:47 # Author: itnihao 4 | # Mail: itnihao@qq.com 5 | import os 6 | import json 7 | r=open('/proc/mounts','r').read().split("\n") 8 | devices = [] 9 | for i in r: 10 | if len(i) > 0: 11 | d=i.split() 12 | print d 13 | result=d[1].find('chroot') 14 | print d[1] 15 | if result != 0: 16 | devices += [{"{#FSNAME}":d[1],"{#FSTYPE}":d[2]}] 17 | #for devpath in r: 18 | # device = os.path.basename(devpath) 19 | # devices += [{'{#SITENAME}':device}] 20 | 21 | #print json.dumps({'data':devices},sort_keys=True,indent=7,separators=(',',':')) 22 | 23 | 24 | 25 | #{"{#FSNAME}":"\/var\/named\/chroot\/etc\/named.root.key","{#FSTYPE}":"ext4"} 26 | -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/scripts/fileSystemDiscoveryNotBind.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf8 3 | # Last modified: 2014-08-02 14:11 4 | # Author: itnihao 5 | # Mail: itnihao@qq.com 6 | import json 7 | devices_arry = [] 8 | 9 | f=open('/proc/mounts','r') 10 | mounts_arry=f.read().split("\n") 11 | 12 | for line in mounts_arry: 13 | if len(line) > 0: 14 | fs_arry=line.split() 15 | result=fs_arry[1].find('chroot') 16 | if result == -1: 17 | devices_arry += [{"{#FSNAME}":fs_arry[1],"{#FSTYPE}":fs_arry[2]}] 18 | 19 | print json.dumps({'data':devices_arry},sort_keys=True,indent=7,separators=(',',':')) 20 | -------------------------------------------------------------------------------- /09-chapter/low_level_discovery/bind_file_system_not_display/zabbix_agentd.d/fileSystemDiscoveryNotBind.conf: -------------------------------------------------------------------------------- 1 | UserParameter=bind.vfs.fs.discovery,python /etc/zabbix/scripts/fileSystemDiscoveryNotBind.py 2 | -------------------------------------------------------------------------------- /11-chapter/Dell-Hardware-monitor/OMSA/readme.md: -------------------------------------------------------------------------------- 1 | omsa安装参考 2 | http://linux.dell.com/repo/hardware/omsa.html 3 | -------------------------------------------------------------------------------- /11-chapter/Dell-Hardware-monitor/OMSA/userparameter_dell_hardware.conf: -------------------------------------------------------------------------------- 1 | UserParameter=omreport-system, /opt/dell/srvadmin/bin/omreport system -fmt ssv | grep "Main System Chassis" | cut -d ";" -f 1 | grep -ic "Ok" 2 | UserParameter=omreport-storage[*], /opt/dell/srvadmin/bin/omreport storage $1 | grep ^Status | cut -d ":" -f 2 | grep -vic Ok 3 | UserParameter=omreport-storage-controller, /opt/dell/srvadmin/bin/omreport storage controller | grep "^Status" | egrep -ivc "OK|Non-Critical" 4 | UserParameter=omreport-storage-battery, /opt/dell/srvadmin/bin/omreport storage battery | grep -e Status -e State | cut -d ":" -f 2 | grep -ic -e Ok -e Charging 5 | UserParameter=omreport-chassis[*],/opt/dell/srvadmin/bin/omreport chassis -fmt ssv | grep "$1" | cut -d ";" -f 1 | grep -ic "Ok" 6 | UserParameter=omreport-chassis-pwrmonitoring, /opt/dell/srvadmin/bin/omreport chassis pwrmonitoring | grep "Status" | cut -d ":" -f 2 | grep -ic "Ok" 7 | UserParameter=omreport-chassis-pwrusage, /opt/dell/srvadmin/bin/omreport chassis pwrmonitoring | grep Reading | head -1 | cut -d ":" -f 2 | tr -d " A-Z" 8 | UserParameter=omreport-chassis-hwperformance, /opt/dell/srvadmin/bin/omreport chassis hwperformance | grep "Status" | cut -d ":" -f 2 | grep -ic "Normal" 9 | UserParameter=omreport-chassis-firmware, /opt/dell/srvadmin/bin/omreport chassis firmware -fmt ssv | grep DRAC | cut -d ";" -f 2 10 | UserParameter=omreport-chassis-bios, /opt/dell/srvadmin/bin/omreport chassis bios -fmt ssv | grep Version | cut -d ";" -f 2 11 | UserParameter=omreport-storage-pdisk-status, /opt/dell/srvadmin/bin/omreport storage pdisk controller=0 | grep "^Status" | egrep -ivc "OK|Non-Critical" 12 | UserParameter=omreport-storage-pdisk-state, /opt/dell/srvadmin/bin/omreport storage pdisk controller=0 | grep "^State" | egrep -ivc "Online|Ready|Non-RAID" 13 | UserParameter=omreport-tag, /opt/dell/srvadmin/bin/omreport system summary | grep 'Chassis Service Tag' | awk -F ': ' '{ print $2}' 14 | UserParameter=omreport-hardware, /opt/dell/srvadmin/bin/omreport system summary | grep 'Chassis Model' | awk -F ': ' '{ print $2}' 15 | -------------------------------------------------------------------------------- /11-chapter/doc/redis_monitor.md: -------------------------------------------------------------------------------- 1 | 关于Redis的监控,请参考 2 | http://redis.readthedocs.org/en/latest/server/info.html 3 | ###INFO [section] 4 | 以一种易于解释(parse)且易于阅读的格式,返回关于 Redis 服务器的各种信息和统计数值。 5 | 通过给定可选的参数 section ,可以让命令只返回某一部分的信息: 6 | ``` 7 | server : 一般 Redis 服务器信息,包含以下域: 8 | 9 | redis_version : Redis 服务器版本 10 | redis_git_sha1 : Git SHA1 11 | redis_git_dirty : Git dirty flag 12 | os : Redis 服务器的宿主操作系统 13 | arch_bits : 架构(32 或 64 位) 14 | multiplexing_api : Redis 所使用的事件处理机制 15 | gcc_version : 编译 Redis 时所使用的 GCC 版本 16 | process_id : 服务器进程的 PID 17 | run_id : Redis 服务器的随机标识符(用于 Sentinel 和集群) 18 | tcp_port : TCP/IP 监听端口 19 | uptime_in_seconds : 自 Redis 服务器启动以来,经过的秒数 20 | uptime_in_days : 自 Redis 服务器启动以来,经过的天数 21 | lru_clock : 以分钟为单位进行自增的时钟,用于 LRU 管理 22 | clients : 已连接客户端信息,包含以下域: 23 | 24 | connected_clients : 已连接客户端的数量(不包括通过从属服务器连接的客户端) 25 | client_longest_output_list : 当前连接的客户端当中,最长的输出列表 26 | client_longest_input_buf : 当前连接的客户端当中,最大输入缓存 27 | blocked_clients : 正在等待阻塞命令(BLPOP、BRPOP、BRPOPLPUSH)的客户端的数量 28 | memory : 内存信息,包含以下域: 29 | 30 | used_memory : 由 Redis 分配器分配的内存总量,以字节(byte)为单位 31 | used_memory_human : 以人类可读的格式返回 Redis 分配的内存总量 32 | used_memory_rss : 从操作系统的角度,返回 Redis 已分配的内存总量(俗称常驻集大小)。这个值和 top 、 ps 等命令的输出一致。 33 | used_memory_peak : Redis 的内存消耗峰值(以字节为单位) 34 | used_memory_peak_human : 以人类可读的格式返回 Redis 的内存消耗峰值 35 | used_memory_lua : Lua 引擎所使用的内存大小(以字节为单位) 36 | mem_fragmentation_ratio : used_memory_rss 和 used_memory 之间的比率 37 | mem_allocator : 在编译时指定的, Redis 所使用的内存分配器。可以是 libc 、 jemalloc 或者 tcmalloc 。 38 | 在理想情况下, used_memory_rss 的值应该只比 used_memory 稍微高一点儿。 39 | 当 rss > used ,且两者的值相差较大时,表示存在(内部或外部的)内存碎片。 40 | 内存碎片的比率可以通过 mem_fragmentation_ratio 的值看出。 41 | 当 used > rss 时,表示 Redis 的部分内存被操作系统换出到交换空间了,在这种情况下,操作可能会产生明显的延迟。 42 | Because Redis does not have control over how its allocations are mapped to memory pages, high used_memory_rss is often the result of a spike in memory usage. 43 | 44 | 当 Redis 释放内存时,分配器可能会,也可能不会,将内存返还给操作系统。 45 | 如果 Redis 释放了内存,却没有将内存返还给操作系统,那么 used_memory 的值可能和操作系统显示的 Redis 内存占用并不一致。 46 | 查看 used_memory_peak 的值可以验证这种情况是否发生。 47 | persistence : RDB 和 AOF 的相关信息 48 | 49 | stats : 一般统计信息 50 | replication : 主/从复制信息 51 | cpu : CPU 计算量统计信息 52 | commandstats : Redis 命令统计信息 53 | cluster : Redis 集群信息 54 | keyspace : 数据库相关的统计信息 55 | 56 | 除上面给出的这些值以外,参数还可以是下面这两个: 57 | all : 返回所有信息 58 | default : 返回默认选择的信息 59 | 当不带参数直接调用 INFO 命令时,使用 default 作为默认参数。 60 | 61 | 不同版本的 Redis 可能对返回的一些域进行了增加或删减。 62 | 因此,一个健壮的客户端程序在对 INFO 命令的输出进行分析时,应该能够跳过不认识的域,并且妥善地处理丢失不见的域。 63 | 64 | 可用版本: 65 | >= 1.0.0 66 | 时间复杂度: 67 | O(1) 68 | 返回值: 69 | ``` 70 | 具体请参见下面的测试代码。 71 | ``` 72 | redis-cli -p 6383 73 | 127.0.0.1:6383> info 74 | # Server 75 | redis_version:2.8.8 76 | redis_git_sha1:00000000 77 | redis_git_dirty:0 78 | redis_build_id:bafd09db0ea64ad0 79 | redis_mode:standalone 80 | os:Linux 3.11.0-24-generic x86_64 81 | arch_bits:64 82 | multiplexing_api:epoll 83 | gcc_version:4.6.3 84 | process_id:13724 85 | run_id:05f48727373c94eae75b2634eb6cd99ff04c5592 86 | tcp_port:6383 87 | uptime_in_seconds:1329486 88 | uptime_in_days:15 89 | hz:10 90 | lru_clock:2881420 91 | config_file:/etc/redis/6383.conf 92 | 93 | # Clients 94 | connected_clients:267 95 | client_longest_output_list:0 96 | client_biggest_input_buf:0 97 | blocked_clients:0 98 | 99 | # Memory 100 | used_memory:2597003592 101 | used_memory_human:2.42G 102 | used_memory_rss:3247697920 103 | used_memory_peak:5300846120 104 | used_memory_peak_human:4.94G 105 | used_memory_lua:29696 106 | mem_fragmentation_ratio:1.25 107 | mem_allocator:jemalloc-3.2.0 108 | 109 | # Persistence 110 | loading:0 111 | rdb_changes_since_last_save:1408782845 112 | rdb_bgsave_in_progress:0 113 | rdb_last_save_time:1410866014 114 | rdb_last_bgsave_status:ok 115 | rdb_last_bgsave_time_sec:33 116 | rdb_current_bgsave_time_sec:-1 117 | aof_enabled:0 118 | aof_rewrite_in_progress:0 119 | aof_rewrite_scheduled:0 120 | aof_last_rewrite_time_sec:-1 121 | aof_current_rewrite_time_sec:-1 122 | aof_last_bgrewrite_status:ok 123 | aof_last_write_status:ok 124 | 125 | # Stats 126 | total_connections_received:13209166 127 | total_commands_processed:10099828580 128 | instantaneous_ops_per_sec:2837 129 | rejected_connections:36242 130 | sync_full:0 131 | sync_partial_ok:0 132 | sync_partial_err:0 133 | expired_keys:16591179 134 | evicted_keys:0 135 | keyspace_hits:2077408344 136 | keyspace_misses:2433838286 137 | pubsub_channels:0 138 | pubsub_patterns:0 139 | latest_fork_usec:97455 140 | 141 | # Replication 142 | role:master 143 | connected_slaves:0 144 | master_repl_offset:0 145 | repl_backlog_active:0 146 | repl_backlog_size:1048576 147 | repl_backlog_first_byte_offset:0 148 | repl_backlog_histlen:0 149 | 150 | # CPU 151 | used_cpu_sys:88227.02 152 | used_cpu_user:74898.65 153 | used_cpu_sys_children:6.00 154 | used_cpu_user_children:47.59 155 | 156 | # Keyspace 157 | db0:keys=594128,expires=578561,avg_ttl=74150277 158 | db5:keys=755192,expires=144,avg_ttl=63212667 159 | db12:keys=6,expires=0,avg_ttl=0 160 | ``` 161 | -------------------------------------------------------------------------------- /11-chapter/linux_disk_io_monitor/README.md: -------------------------------------------------------------------------------- 1 | #scripts and conf 2 | ``` 3 | #/etc/zabbix/scripts/check_harddisk.sh 4 | #/etc/zabbix/zabbix_agentd.conf.d/userparameter_harddisk.conf 5 | chown zabbix.zabbix /etc/zabbix/scripts/check_harddisk.sh 6 | chmod 755 /etc/zabbix/scripts/check_harddisk.sh 7 | ``` 8 | #template 9 | import-inux_disk_io_template.xml 10 | -------------------------------------------------------------------------------- /11-chapter/linux_disk_io_monitor/check_harddisk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # function:monitor redisstatus from zabbix 3 | # License: GPL 4 | # mail:admin@itnihao.com 5 | # version:1.0 date:2013-02-04 6 | 7 | diskname_discovery () { 8 | HardDisk=($(grep '\b[a-z][a-z][a-z]\+\b' /proc/diskstats|awk '{print $3}')) 9 | [ "${HardDisk[0]}" == "" ] && exit 10 | printf '{\n' 11 | printf '\t"data":[\n' 12 | for((i=0;i<${#HardDisk[@]};++i)) 13 | { 14 | num=$(echo $((${#HardDisk[@]}-1))) 15 | if [ "$i" != ${num} ]; 16 | then 17 | printf "\t\t{ \n" 18 | printf "\t\t\t\"{#DISKNAME}\":\"${HardDisk[$i]}\"},\n" 19 | else 20 | printf "\t\t{ \n" 21 | printf "\t\t\t\"{#DISKNAME}\":\"${HardDisk[$num]}\"}]}\n" 22 | fi 23 | } 24 | } 25 | 26 | case "$1" in 27 | diskname_discovery) 28 | diskname_discovery 29 | ;; 30 | *) 31 | echo "Usage: $0 {diskname_discovery}" 32 | ;; 33 | esac 34 | -------------------------------------------------------------------------------- /11-chapter/linux_disk_io_monitor/userparameter_harddisk.conf: -------------------------------------------------------------------------------- 1 | #discovery hard disk 2 | UserParameter=custom.vfs.discovery.diskname,/etc/zabbix/scripts/check_harddisk.sh diskname_discovery 3 | #disk status 4 | # See https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats 5 | # reads completed successfully 6 | UserParameter=custom.vfs.dev.read.ops[*],egrep $1 /proc/diskstats | head -1 | awk '{print $$4}' 7 | # sectors read 8 | UserParameter=custom.vfs.dev.read.sectors[*],egrep $1 /proc/diskstats | head -1 | awk '{print $$6}' 9 | # time spent reading (ms) 10 | UserParameter=custom.vfs.dev.read.ms[*],egrep $1 /proc/diskstats | head -1 | awk '{print $$7}' 11 | # writes completed 12 | UserParameter=custom.vfs.dev.write.ops[*],egrep $1 /proc/diskstats | head -1 | awk '{print $$8}' 13 | # sectors written 14 | UserParameter=custom.vfs.dev.write.sectors[*],egrep $1 /proc/diskstats | head -1 | awk '{print $$10}' 15 | # time spent writing (ms) 16 | UserParameter=custom.vfs.dev.write.ms[*],egrep $1 /proc/diskstats | head -1 | awk '{print $$11}' 17 | # I/Os currently in progress 18 | UserParameter=custom.vfs.dev.io.active[*],egrep $1 /proc/diskstats | head -1 | awk '{print $$12}' 19 | # time spent doing I/Os (ms) 20 | UserParameter=custom.vfs.dev.io.ms[*],egrep $1 /proc/diskstats | head -1 | awk '{print $$13}' 21 | -------------------------------------------------------------------------------- /11-chapter/mysql_monitor/check_mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #author:itnihao 3 | #mail:itnihao@qq.com 4 | #date 2013-12-18 5 | #version v1.0 6 | #function:use zabbix monitor mysql status 7 | mysql=$(which mysql) 8 | zabbix_sender=$(which zabbix_sender) 9 | #注意,如果你的mysql是非标准安装,请写mysql的绝对路径 10 | #mysql=/usr/bin/mysql 11 | var=$2 12 | MYSQL_USER=$3 13 | MYSQL_PASSWORD=$4 14 | MYSQL_Host=$5 15 | [ "${MYSQL_USER}" = '' ] && MYSQL_USER=itnihao 16 | [ "${MYSQL_PASSWORD}" = '' ] && MYSQL_PASSWORD=www.itnihao.com 17 | [ "${MYSQL_Host}" = '' ] && MYSQL_Host=localhost 18 | 19 | #zabbix-server IP address 20 | Zabbix_Server=$(awk -F"," '/Server=/ {print $2}' /etc/zabbix/zabbix_agentd.conf|egrep -v "(^$)") 21 | #hostname in zabbix-server web (Hostname) 22 | Hostname=$(egrep "\bHostname=\b" /etc/zabbix/zabbix_agentd.conf|awk -F"=" '{print $2}') 23 | 24 | 25 | function status { 26 | [ "${var}" = '' ] && echo ""||${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e 'show status'|grep -v Variable_name|grep "\b${var}\b"|awk '{print $2}' 27 | } 28 | 29 | function ping { 30 | /usr/bin/mysqladmin -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} ping|grep alive|wc -l 31 | } 32 | function version { 33 | ${mysql} -V | cut -f6 -d" " | sed 's/,//' 34 | } 35 | 36 | function slave_delay { 37 | info=$(${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e "show slave status\G;" | grep -E "Seconds_Behind_Master:[ ]*[0-9]+" | wc -l) 38 | if [ $info -eq 0 ]; then 39 | echo 99999 40 | exit 0 41 | else 42 | ${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e "show slave status\G;" | grep "Seconds_Behind_Master" | cut -d':' -f 2|sed "s/^ //g" 43 | fi 44 | } 45 | function slave_running_status { 46 | status=$(${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e "show slave status\G;") 47 | if [ "${status}" == "" ];then 48 | echo 0 49 | fi 50 | Slave_IO_Running="$(${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e "show slave status\G;" | grep "\bSlave_IO_Running\b"|column -t|awk '{print $2}'|sed "s/ //g")" 51 | Slave_SQL_Running="$(${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e "show slave status\G;" | grep "\bSlave_SQL_Running\b"|column -t|awk '{print $2}'|sed "s/ //g")" 52 | Slave_Last_IO_Error=$(${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e "show slave status\G;" | grep -E "\bLast_IO_Error\b"|column -t|sed "s/Last_IO_Error://g") 53 | Slave_Last_SQL_Error=$(${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e "show slave status\G;" | grep -E "\bLast_SQL_Error\b"|column -t|sed "s/Last_SQL_Error://g") 54 | Slave_Last_IO_Error_Timestamp=$(${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e "show slave status\G;" |column -t| grep -E "\bLast_IO_Error_Timestamp\b") 55 | Slave_Last_SQL_Error_Timestamp=$(${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_Host} -e "show slave status\G;" |column -t| grep -E "\bLast_SQL_Error_Timestamp\b") 56 | 57 | if [ "${Slave_Last_IO_Error}" != "" -o "${Slave_Last_SQL_Error}" != "" ];then 58 | msg="Slave_Last_IO_Error_Timestamp:=== ${Slave_Last_IO_Error_Timestamp}\n Slave_Last_IO_Error:=== "${Slave_Last_IO_Error}"\n${Slave_Last_SQL_Error_Timestamp}\nSlave_Last_SQL_Error:=== "${Slave_Last_SQL_Error}"" 59 | ${zabbix_sender} -z ${Zabbix_Server} -p 10051 -s "${Hostname}" -k mysql_slave_error -o "${msg}" -vv 60 | elif [ "${Slave_IO_Running}" != "YES" -a "${Slave_SQL_Running}" != "YES" ];then 61 | echo 0 62 | elif [ "${Slave_IO_Running}" == "NO" ];then 63 | echo 1 64 | elif [ "${Slave_SQL_Running}" == "NO" ];then 65 | echo 2 66 | else 67 | echo 3 68 | fi 69 | 70 | } 71 | case "$1" in 72 | status) 73 | status 74 | ;; 75 | ping) 76 | ping 77 | ;; 78 | version) 79 | version 80 | ;; 81 | slave_delay) 82 | slave_delay 83 | ;; 84 | slave_running_status) 85 | slave_running_status 86 | ;; 87 | *) 88 | echo "Usage: $0 {status| ping | version |slave_running_status}" 89 | esac 90 | -------------------------------------------------------------------------------- /11-chapter/mysql_monitor/userparameter_mysql.conf: -------------------------------------------------------------------------------- 1 | UserParameter=mysql.status[*],/etc/zabbix/scripts/check_mysql.sh status $1 $2 $3 $4 2 | UserParameter=mysql.slave_delay[*],/etc/zabbix/scripts/check_mysql.sh slave_delay $1 $2 $3 $4 3 | UserParameter=mysql.slave_running_status[*],/etc/zabbix/scripts/check_mysql.sh slave_running_status $1 $2 $3 $4 4 | UserParameter=mysql.ping[*],/etc/zabbix/scripts/check_mysql.sh ping $1 $2 $3 $4 5 | UserParameter=mysql.versions[*],/etc/zabbix/scripts/check_mysql.sh version $1 $2 $3 $4 6 | -------------------------------------------------------------------------------- /11-chapter/nginx_monitor/scripts/nginx_status: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # function:monitor nginx from zabbix 4 | # License: GPL 5 | # mail:admin@itnihao.com 6 | # version 1.0 date:2012-12-09 7 | # version 1.0 date:2013-01-15 8 | # version 1.1 date:2014-09-05 9 | 10 | 11 | #nginx.conf 12 | ###################################################################### 13 | # server { 14 | # listen 127.0.0.1:80; 15 | # server_name 127.0.0.1; 16 | # location /nginxstatus { 17 | # stub_status on; 18 | # access_log off; 19 | # allow 127.0.0.1; 20 | # allow 192.168.11.0/24; 21 | # deny all; 22 | # } 23 | # location ~ ^/(phpfpmstatus)$ { 24 | # include fastcgi_params; 25 | # fastcgi_pass unix:/tmp/fpm.sock; 26 | # fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; 27 | # } 28 | # } 29 | ###################################################################### 30 | 31 | 32 | source /etc/bashrc >/dev/null 2>&1 33 | source /etc/profile >/dev/null 2>&1 34 | nginxstatus=http://127.0.0.1/nginxstatus 35 | 36 | 37 | # Functions to return nginx stats 38 | function checkavailable { 39 | code=$(curl -o /dev/null -s -w %{http_code} ${nginxstatus}) 40 | if [ "${code}" == "200" ] 41 | then 42 | return 1 43 | else 44 | echo 0 45 | fi 46 | } 47 | function active { 48 | checkavailable|| curl -s "${nginxstatus}" | grep 'Active' | awk '{print $3}' 49 | } 50 | function reading { 51 | checkavailable|| curl -s "${nginxstatus}" | grep 'Reading' | awk '{print $2}' 52 | } 53 | function writing { 54 | checkavailable|| curl -s "${nginxstatus}" | grep 'Writing' | awk '{print $4}' 55 | } 56 | function waiting { 57 | checkavailable|| curl -s "${nginxstatus}" | grep 'Waiting' | awk '{print $6}' 58 | } 59 | function accepts { 60 | checkavailable|| curl -s "${nginxstatus}" | awk NR==3 | awk '{print $1}' 61 | } 62 | function handled { 63 | checkavailable|| curl -s "${nginxstatus}" | awk NR==3 | awk '{print $2}' 64 | } 65 | function requests { 66 | checkavailable|| curl -s "${nginxstatus}" | awk NR==3 | awk '{print $3}' 67 | } 68 | 69 | 70 | 71 | case "$1" in 72 | nginx_site_dicovery) 73 | nginx_site_dicovery 74 | ;; 75 | active) 76 | active 77 | ;; 78 | reading) 79 | reading 80 | ;; 81 | writing) 82 | writing 83 | ;; 84 | waiting) 85 | waiting 86 | ;; 87 | accepts) 88 | accepts 89 | ;; 90 | handled) 91 | handled 92 | ;; 93 | requests) 94 | requests 95 | ;; 96 | *) 97 | echo "Usage: $0 {active |reading |writing |waiting |accepts |handled |requests }" 98 | esac 99 | -------------------------------------------------------------------------------- /11-chapter/nginx_monitor/zabbix_agentd.d/userparameter_nginx.conf: -------------------------------------------------------------------------------- 1 | UserParameter=nginx.accepts,/etc/zabbix/scripts/nginx_status accepts 2 | UserParameter=nginx.handled,/etc/zabbix/scripts/nginx_status handled 3 | UserParameter=nginx.requests,/etc/zabbix/scripts/nginx_status requests 4 | UserParameter=nginx.connections.active,/etc/zabbix/scripts/nginx_status active 5 | UserParameter=nginx.connections.reading,/etc/zabbix/scripts/nginx_status reading 6 | UserParameter=nginx.connections.writing,/etc/zabbix/scripts/nginx_status writing 7 | UserParameter=nginx.connections.waiting,/etc/zabbix/scripts/nginx_status waiting 8 | -------------------------------------------------------------------------------- /11-chapter/php-fpm_monitor/scripts/monitor_phpfpm_status: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # function:monitor php-fpm status from zabbix 4 | # License: GPL 5 | # mail:itnihao@qq.com 6 | # date:2013-05-30 7 | 8 | source /etc/bashrc >/dev/null 2>&1 9 | source /etc/profile >/dev/null 2>&1 10 | 11 | LOG_FILE=/var/log/zabbix/phpfpmstatus.log 12 | curl http://127.0.0.1/phpfpmstatus >${LOG_FILE} 2>&1 13 | 14 | pool(){ 15 | awk '/pool/ {print $NF}' ${LOG_FILE} 16 | } 17 | process_manager() { 18 | awk '/process manager/ {print $NF}' ${LOG_FILE} 19 | } 20 | 21 | start_since(){ 22 | awk '/^start since:/ {print $NF}' ${LOG_FILE} 23 | } 24 | accepted_conn(){ 25 | awk '/^accepted conn:/ {print $NF}' ${LOG_FILE} 26 | } 27 | listen_queue(){ 28 | awk '/^listen queue:/ {print $NF}' ${LOG_FILE} 29 | } 30 | max_listen_queue(){ 31 | awk '/^max listen queue:/ {print $NF}' ${LOG_FILE} 32 | } 33 | listen_queue_len(){ 34 | awk '/^listen queue len:/ {print $NF}' ${LOG_FILE} 35 | } 36 | idle_processes(){ 37 | awk '/^idle processes:/ {print $NF}' ${LOG_FILE} 38 | } 39 | active_processes(){ 40 | awk '/^active processes:/ {print $NF}' ${LOG_FILE} 41 | } 42 | total_processes(){ 43 | awk '/^total processes:/ {print $NF}' ${LOG_FILE} 44 | } 45 | max_active_processes(){ 46 | awk '/^max active processes:/ {print $NF}' ${LOG_FILE} 47 | } 48 | max_children_reached(){ 49 | awk '/^max children reached:/ {print $NF}' ${LOG_FILE} 50 | } 51 | 52 | 53 | case "$1" in 54 | pool) 55 | pool 56 | ;; 57 | process_manager) 58 | process_manager 59 | ;; 60 | start_since) 61 | start_since 62 | ;; 63 | accepted_conn) 64 | accepted_conn 65 | ;; 66 | listen_queue) 67 | listen_queue 68 | ;; 69 | max_listen_queue) 70 | max_listen_queue 71 | ;; 72 | listen_queue_len) 73 | listen_queue_len 74 | ;; 75 | idle_processes) 76 | idle_processes 77 | ;; 78 | active_processes) 79 | active_processes 80 | ;; 81 | total_processes) 82 | total_processes 83 | ;; 84 | max_active_processes) 85 | max_active_processes 86 | ;; 87 | max_children_reached) 88 | max_children_reached 89 | ;; 90 | *) 91 | echo "Usage: $0 {pool|process_manager|start_since|accepted_conn|listen_queue|max_listen_queue|listen_queue_len|idle_processes|active_processes|total_processes|max_active_processes|max_children_reached}" 92 | esac 93 | -------------------------------------------------------------------------------- /11-chapter/php-fpm_monitor/zabbix_agentd.d/monitor_phpfpm_status.conf: -------------------------------------------------------------------------------- 1 | UserParameter=phpfpm.status.pool,/etc/zabbix/scripts/monitor_phpfpm_status pool 2 | UserParameter=phpfpm.status.process.manager,/etc/zabbix/scripts/monitor_phpfpm_status process_manager 3 | UserParameter=phpfpm.status.start.since,/etc/zabbix/scripts/monitor_phpfpm_status start_since 4 | UserParameter=phpfpm.status.accepted.conn,/etc/zabbix/scripts/monitor_phpfpm_status accepted_conn 5 | UserParameter=phpfpm.status.listen.queue,/etc/zabbix/scripts/monitor_phpfpm_status listen_queue 6 | UserParameter=phpfpm.status.max.listen.queue,/etc/zabbix/scripts/monitor_phpfpm_status max_listen_queue 7 | UserParameter=phpfpm.status.listen.queue.len,/etc/zabbix/scripts/monitor_phpfpm_status listen_queue_len 8 | UserParameter=phpfpm.status.idle.processes,/etc/zabbix/scripts/monitor_phpfpm_status idle_processes 9 | UserParameter=phpfpm.status.active.processes,/etc/zabbix/scripts/monitor_phpfpm_status active_processes 10 | UserParameter=phpfpm.status.total.processes,/etc/zabbix/scripts/monitor_phpfpm_status total_processes 11 | UserParameter=phpfpm.status.max.active.processes,/etc/zabbix/scripts/monitor_phpfpm_status max_active_processes 12 | UserParameter=phpfpm.status.max.children.reached,/etc/zabbix/scripts/monitor_phpfpm_status max_children_reached 13 | #php-fpm.conf里面添加如下 14 | ############################################################################### 15 | #pm.status_path = /phpfpmstatus 16 | ############################################################################### 17 | #nginx.conf配置如下 18 | ############################################################################### 19 | #http{ 20 | #.................. 21 | #server { 22 | # listen 127.0.0.1:80; 23 | # server_name 127.0.0.1; 24 | # location ~ ^/(phpfpmstatus)$ { 25 | # include fastcgi_params; 26 | # fastcgi_pass unix:/tmp/fpm.sock; 27 | # #fastcgi_pass 127.0.0.1:9000; 28 | # fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; 29 | # } 30 | #} 31 | #................ 32 | #} 33 | ############################################################################### 34 | -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/cx_Oracle-5.1.2-11g-py26-1.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/11-chapter/py_oracle_zabbix/cx_Oracle-5.1.2-11g-py26-1.x86_64.rpm -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/install_oracle.sh: -------------------------------------------------------------------------------- 1 | # assuming python and pip are already installed 2 | # installing the instantclient is usually where problems happen 3 | 4 | # download the following files from oracle 5 | # 6 | # oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm 7 | # oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm 8 | # oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm 9 | 10 | # install the rpms 11 | rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm 12 | rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm 13 | rpm -ivh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm 14 | 15 | # the sqlplus package isn't specifically needed, but is usually useful for testing and command line sql connections 16 | 17 | # configure oracle env (modify exact path based on version of rpm you download) 18 | vim /etc/profile.d/oracle 19 | 20 | #!/bin/bash 21 | LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/lib:${LD_LIBRARY_PATH}" 22 | export LD_LIBRARY_PATH 23 | TNS_ADMIN="/etc/oracle" 24 | export TNS_ADMIN 25 | ORACLE_HOME="/usr/lib/oracle/11.2/client64/lib" 26 | export ORACLE_HOME 27 | 28 | # copy/create your tnsnames.ora file 29 | touch /etc/oracle/tnsnames.ora 30 | 31 | # symlink headers to ORACLE_HOME to avoid "cannot locate Oracle include files" error 32 | mkdir /usr/lib/oracle/11.2/client64/lib/sdk 33 | ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/lib/sdk/include 34 | 35 | # done. Install cx_Oracle 36 | pip install cx_Oracle 37 | #https://gist.github.com/jarshwah/3863378 38 | -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/libaio-0.3.107-10.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/11-chapter/py_oracle_zabbix/libaio-0.3.107-10.el6.x86_64.rpm -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/11-chapter/py_oracle_zabbix/oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/11-chapter/py_oracle_zabbix/oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/11-chapter/py_oracle_zabbix/oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/oracle-zabbix-monitor.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/11-chapter/py_oracle_zabbix/oracle-zabbix-monitor.tar.gz -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/oracle.conf: -------------------------------------------------------------------------------- 1 | #/u01/app/oracle/product/11.2.0/db_1/lib/ 2 | /usr/lib/oracle/11.2/client64/lib/ 3 | -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/py_oracle.conf: -------------------------------------------------------------------------------- 1 | UserParameter=pyora[*],/etc/zabbix/scripts/pyora.py --username $1 --password $2 --address $3 --database $4 $5 $6 $7 $8 2 | -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/python-argparse-1.2.1-2.el6.noarch.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/11-chapter/py_oracle_zabbix/python-argparse-1.2.1-2.el6.noarch.rpm -------------------------------------------------------------------------------- /11-chapter/py_oracle_zabbix/readme.txt: -------------------------------------------------------------------------------- 1 | 1.安装oracle的客户端软件包 2 | rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm 3 | rpm -ivh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm 4 | rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm 5 | rpm -ivh cx_Oracle-5.1.2-11g-py26-1.x86_64.rpm 6 | rpm -ivh python-argparse-1.2.1-2.el6.noarch.rpm 7 | 8 | 2.库文件路径 9 | #vim /etc/ld.so.conf.d/oracle.conf #添加如下内容 10 | /usr/lib/oracle/11.2/client64/lib 11 | #ldconfig -v 12 | 13 | 3.脚本配置文件 14 | #cp pyora.py /etc/zabbix/scripts/pyora.py 15 | #cp py_oracle.conf /etc/zabbix/zabbix_agentd.conf.d/oracle.conf 16 | 17 | 4.web导入xml文件ORACLE_zbx_templates.xml 18 | host里面设置宏变量 19 | Macro Value 20 | {$ADDRESS} 192.168.153.153 21 | {$ARCHIVE} VGDATA 22 | {$DATABASE} clouddb 23 | {$PASSWORD} 123456 24 | {$USERNAME} testuser 25 | 26 | 27 | 28 | 出自http://bicofino.io/blog/2013/12/09/monitoring-oracle-with-zabbix/ 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /11-chapter/redis_monitor/check_redis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # function:monitor redisstatus from zabbix 3 | # License: GPL 4 | # mail:admin@itnihao.com 5 | # version:1.0 date:2013-02-04 6 | #chmod 4755 $(which netstat) 7 | 8 | redis_discovery () { 9 | port=($(netstat -nlput|awk -F":" '/redis/ {print $0}'|awk -F: '{print $2}'|awk '{print $1}'|grep -v "^$")) 10 | [ "${port[0]}" == "" ] && exit 11 | printf '{\n' 12 | printf '\t"data":[\n' 13 | for((i=0;i<${#port[@]};++i)) 14 | { 15 | num=$(echo $((${#port[@]}-1))) 16 | if [ "$i" != ${num} ]; 17 | then 18 | printf "\t\t{ \n" 19 | printf "\t\t\t\"{#REDISPORT}\":\"${port[$i]}\"},\n" 20 | else 21 | printf "\t\t{ \n" 22 | printf "\t\t\t\"{#REDISPORT}\":\"${port[$num]}\"}]}\n" 23 | fi 24 | } 25 | } 26 | 27 | 28 | case "$1" in 29 | redis_discovery) 30 | redis_discovery 31 | ;; 32 | *) 33 | echo "Usage: $0 {redis_discovery}" 34 | ;; 35 | esac 36 | -------------------------------------------------------------------------------- /11-chapter/redis_monitor/userparameter_redis.conf: -------------------------------------------------------------------------------- 1 | UserParameter=redis.ping[*],(redis-cli -p $1 ping | grep -i PONG | wc -l) 2 | UserParameter=redis_stats[*],(echo info; sleep 0.01) | telnet 127.0.0.1 $1 2>&1|grep "\b$2\b"|cut -d : -f2 3 | UserParameter=redis.port.discovery,/etc/zabbix/scripts/check_redis.sh redis_discovery 4 | -------------------------------------------------------------------------------- /11-chapter/tcp_connect/zabbix_agentd.d/userparameter_tcp_connect_status.conf: -------------------------------------------------------------------------------- 1 | #UserParameter=tcp_connect.established,var=$(ss state all|awk '/ESTAB/ {++S[$1]} END {for(a in S) {printf " %s", S[a]}}')&& if [ "${var}" != "" ]; then echo ${var};else echo 0;fi 2 | #UserParameter=tcp_connect.syncent, var=$(ss state all|awk '/SYNSENT/ {++S[$1]} END {for(a in S) {printf " %s", S[a]}}')&& if [ "${var}" != "" ]; then echo ${var};else echo 0;fi 3 | UserParameter=tcp_connect.listen, var=$(ss state all|awk '/LISTEN/ {++S[$1]} END {for(a in S) {printf " %s", S[a]}}')&& if [ "${var}" != "" ]; then echo ${var};else echo 0;fi 4 | UserParameter=tcp_connect.timewait, var=$(ss state all|awk '/TIME-WAIT/ {++S[$1]} END {for(a in S) {printf " %s", S[a]}}')&& if [ "${var}" != "" ]; then echo ${var};else echo 0;fi 5 | UserParameter=tcp_connect.timeclose, var=$(ss state all|awk '/TIME-CLOSE/ {++S[$1]} END {for(a in S) {printf " %s", S[a]}}')&& if [ "${var}" != "" ]; then echo ${var};else echo 0;fi 6 | UserParameter=tcp_connect.finwait1, var=$(ss state all|awk '/FIN-WAIT1/ {++S[$1]} END {for(a in S) {printf " %s", S[a]}}')&& if [ "${var}" != "" ]; then echo ${var};else echo 0;fi 7 | UserParameter=tcp_connect.finwait2, var=$(ss state all|awk '/FIN-WAIT2/ {++S[$1]} END {for(a in S) {printf " %s", S[a]}}')&& if [ "${var}" != "" ]; then echo ${var};else echo 0;fi 8 | #UserParameter=tcp_connect.synrecv, var=$(ss state all|awk '/SYNCRECV/ {++S[$1]} END {for(a in S) {printf " %s", S[a]}}')&& if [ "${var}" != "" ]; then echo ${var};else echo 0;fi 9 | UserParameter=tcp_connect.closewait, var=$(ss state all|awk '/CLOSE-WAIT/ {++S[$1]} END {for(a in S) {printf " %s", S[a]}}')&& if [ "${var}" != "" ]; then echo ${var};else echo 0;fi 10 | 11 | UserParameter=tcp_connect.established,ss -s |awk '/estab/ {print $4}'|cut -d',' -f1 12 | UserParameter=tcp_connect.synrecv, ss -s |awk -F"," '/estab/ {print $4}' |cut -d" " -f3 13 | -------------------------------------------------------------------------------- /11-chapter/web_monitor/README.md: -------------------------------------------------------------------------------- 1 | #scripts and conf 2 | ``` 3 | /etc/zabbix/scripts/web_site_code_status 4 | /etc/zabbix/zabbix_agentd.conf.d/web_site_code.conf 5 | mkdir /etc/zabbix/scripts/website/ 6 | touch /etc/zabbix/scripts/website/website.txt 7 | echo "www.baidu.com" >> /etc/zabbix/scripts/website/website.txt 8 | ``` 9 | #template 10 | import-web-monitor.xml 11 | -------------------------------------------------------------------------------- /11-chapter/web_monitor/web-monitor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2.0 4 | 2014-11-24T05:14:16Z 5 | 6 | 7 | Templates 8 | 9 | 10 | 11 | 196 | 197 | 198 | -------------------------------------------------------------------------------- /11-chapter/web_monitor/web_site_code.conf: -------------------------------------------------------------------------------- 1 | UserParameter=web.site.discovery,/etc/zabbix/scripts/web_site_code_status web_site_discovery 2 | UserParameter=web.site.code[*], /etc/zabbix/scripts/web_site_code_status web_site_code $1 3 | -------------------------------------------------------------------------------- /11-chapter/web_monitor/web_site_code_status: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # function:monitor tcp connect status from zabbix 4 | # License: GPL 5 | # mail:admin@itnihao.com 6 | # version:1.0 date:2013-01-16 7 | 8 | source /etc/bashrc >/dev/null 2>&1 9 | source /etc/profile >/dev/null 2>&1 10 | mkdir -p /etc/zabbix/scripts/website 11 | [ -f /etc/zabbix/scripts/WEB.txt ] 12 | [ "$?" != 0 ] && touch /etc/zabbix/scripts/website/website.txt 13 | 14 | #/usr/bin/curl -o /dev/null -s -w %{http_code} http://$1/ 15 | WEB_SITE_discovery () { 16 | WEB_SITE=($(cat /etc/zabbix/scripts/website/website.txt|grep -v "^#")) 17 | printf '{\n' 18 | printf '\t"data":[\n' 19 | for((i=0;i<${#WEB_SITE[@]};++i)) 20 | { 21 | num=$(echo $((${#WEB_SITE[@]}-1))) 22 | if [ "$i" != ${num} ]; 23 | then 24 | printf "\t\t{ \n" 25 | printf "\t\t\t\"{#SITENAME}\":\"${WEB_SITE[$i]}\"},\n" 26 | else 27 | printf "\t\t{ \n" 28 | printf "\t\t\t\"{#SITENAME}\":\"${WEB_SITE[$num]}\"}]}\n" 29 | fi 30 | } 31 | } 32 | web_site_code () { 33 | for i in 1 2 3 34 | do 35 | code=$(/usr/bin/curl -o /dev/null --connect-timeout 0.5 -s -w %{http_code} -A "Zabbix Web Monitor" $1) 36 | if [ ${code} != '000' ];then 37 | break 38 | fi 39 | done 40 | if [ ${code} == '000' ];then 41 | echo 1 42 | else 43 | echo ${code} 44 | fi 45 | } 46 | case "$1" in 47 | web_site_discovery) 48 | WEB_SITE_discovery 49 | ;; 50 | web_site_code) 51 | web_site_code $2 52 | ;; 53 | *) 54 | echo "Usage:$0 {web_site_discovery|web_site_code [URL]}" 55 | ;; 56 | esac 57 | -------------------------------------------------------------------------------- /13-chapter/zabbix-api-example/12.3.6-zabbixhostget.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding=utf-8 3 | 4 | #导入模块,urllib2是一个模拟浏览器HTTP方法的模块 5 | import json 6 | import urllib2 7 | import sys 8 | from urllib2 import Request, urlopen, URLError, HTTPError 9 | 10 | #url and url header 11 | #zabbix的api 地址,用户名,密码,这里修改为自己实际的参数 12 | zabbix_url="http://zabbix-gui.itnihao.com/api_jsonrpc.php" 13 | zabbix_header = {"Content-Type":"application/json"} 14 | zabbix_user = "admin" 15 | zabbix_pass = "zabbix" 16 | auth_code = "" 17 | 18 | #auth user and password 19 | #用户认证信息的部分,最终的目的是得到一个SESSIONID 20 | #这里是生成一个json格式的数据,用户名和密码 21 | auth_data = json.dumps( 22 | { 23 | "jsonrpc":"2.0", 24 | "method":"user.login", 25 | "params": 26 | { 27 | "user":zabbix_user, 28 | "password":zabbix_pass 29 | }, 30 | "id":0 31 | }) 32 | 33 | # create request object 34 | request = urllib2.Request(zabbix_url,auth_data) 35 | for key in zabbix_header: 36 | request.add_header(key,zabbix_header[key]) 37 | 38 | #auth and get authid 39 | try: 40 | result = urllib2.urlopen(request) 41 | #对于出错新的处理 42 | except HTTPError, e: 43 | print 'The server couldn\'t fulfill the request, Error code: ', e.code 44 | except URLError, e: 45 | print 'We failed to reach a server.Reason: ', e.reason 46 | else: 47 | response=json.loads(result.read()) 48 | result.close() 49 | #判断SESSIONID是否在返回的数据中 50 | if 'result' in response: 51 | auth_code=response['result'] 52 | else: 53 | print response['error']['data'] 54 | 55 | # request json 56 | json_data={ 57 | "method":"host.get", 58 | "params":{ 59 | "output": "extend", 60 | } 61 | } 62 | json_base={ 63 | "jsonrpc":"2.0", 64 | "auth":auth_code, 65 | "id":1 66 | } 67 | json_data.update(json_base) 68 | #用得到的SESSIONID去通过验证,获取主机的信息(用http.get方法) 69 | if len(auth_code) == 0: 70 | sys.exit(1) 71 | if len(auth_code) != 0: 72 | get_host_data = json.dumps(json_data) 73 | 74 | # create request object 75 | request = urllib2.Request(zabbix_url,get_host_data) 76 | for key in zabbix_header: 77 | request.add_header(key,zabbix_header[key]) 78 | 79 | # get host list 80 | try: 81 | result = urllib2.urlopen(request) 82 | except URLError as e: 83 | if hasattr(e, 'reason'): 84 | print 'We failed to reach a server.' 85 | print 'Reason: ', e.reason 86 | elif hasattr(e, 'code'): 87 | print 'The server could not fulfill the request.' 88 | print 'Error code: ', e.code 89 | else: 90 | response = json.loads(result.read()) 91 | result.close() 92 | 93 | #将所有的主机信息显示出来 94 | print response 95 | #显示主机的个数 96 | print "Number Of Hosts: ", len(response['result']) 97 | -------------------------------------------------------------------------------- /13-chapter/zabbix-api-example/12.3.7-zabbixhostcreate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding=utf-8 3 | 4 | #导入模块,urllib2是一个模拟浏览器HTTP方法的模块 5 | import json 6 | import urllib2 7 | import sys 8 | from urllib2 import Request, urlopen, URLError, HTTPError 9 | 10 | #url and url header 11 | #zabbix的api 地址,用户名,密码,这里修改为自己实际的参数 12 | zabbix_url="http://zabbix-gui.itnihao.com/api_jsonrpc.php" 13 | zabbix_header = {"Content-Type":"application/json"} 14 | zabbix_user = "admin" 15 | zabbix_pass = "zabbix" 16 | auth_code = "" 17 | 18 | #auth user and password 19 | #用户认证信息的部分,最终的目的是得到一个SESSIONID 20 | #这里是生成一个json格式的数据,用户名和密码 21 | auth_data = json.dumps( 22 | { 23 | "jsonrpc":"2.0", 24 | "method":"user.login", 25 | "params": 26 | { 27 | "user":zabbix_user, 28 | "password":zabbix_pass 29 | }, 30 | "id":0 31 | }) 32 | 33 | # create request object 34 | request = urllib2.Request(zabbix_url,auth_data) 35 | for key in zabbix_header: 36 | request.add_header(key,zabbix_header[key]) 37 | 38 | #auth and get authid 39 | try: 40 | result = urllib2.urlopen(request) 41 | #对于出错新的处理 42 | except HTTPError, e: 43 | print 'The server couldn\'t fulfill the request, Error code: ', e.code 44 | except URLError, e: 45 | print 'We failed to reach a server.Reason: ', e.reason 46 | else: 47 | response=json.loads(result.read()) 48 | result.close() 49 | #判断SESSIONID是否在返回的数据中 50 | if 'result' in response: 51 | auth_code=response['result'] 52 | else: 53 | print response['error']['data'] 54 | 55 | # request json 56 | json_data={ 57 | "method": "host.create", 58 | "params": { 59 | "host": "Web Linux server", 60 | "interfaces": [ 61 | { 62 | "type": 1, 63 | "main": 1, 64 | "useip": 1, 65 | "ip": "192.168.8.1", 66 | "dns": "", 67 | "port": "10050" 68 | } 69 | ], 70 | "groups": [ 71 | { 72 | "groupid": "12" 73 | } 74 | ], 75 | "templates": [ 76 | { 77 | "templateid": "10001" 78 | } 79 | ], 80 | "inventory": { 81 | "macaddress_a": "01234", 82 | "macaddress_b": "56768" 83 | } 84 | } 85 | } 86 | json_base={ 87 | "jsonrpc":"2.0", 88 | "auth":auth_code, 89 | "id":1 90 | } 91 | json_data.update(json_base) 92 | print json_data 93 | #用得到的SESSIONID去通过验证,获取主机的信息(用http.get方法) 94 | if len(auth_code) == 0: 95 | sys.exit(1) 96 | if len(auth_code) != 0: 97 | get_host_data = json.dumps(json_data) 98 | 99 | # create request object 100 | request = urllib2.Request(zabbix_url,get_host_data) 101 | for key in zabbix_header: 102 | request.add_header(key,zabbix_header[key]) 103 | 104 | # get host list 105 | try: 106 | result = urllib2.urlopen(request) 107 | except URLError as e: 108 | if hasattr(e, 'reason'): 109 | print 'We failed to reach a server.' 110 | print 'Reason: ', e.reason 111 | elif hasattr(e, 'code'): 112 | print 'The server could not fulfill the request.' 113 | print 'Error code: ', e.code 114 | else: 115 | response = json.loads(result.read()) 116 | result.close() 117 | 118 | #将所有的主机信息显示出来 119 | print response 120 | #显示主机的个数 121 | print "Number Of Hosts: ", len(response['result']) 122 | -------------------------------------------------------------------------------- /13-chapter/zabbix-api-example/12.3.8-zabbixhostdelete.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding=utf-8 3 | 4 | #导入模块,urllib2是一个模拟浏览器HTTP方法的模块 5 | import json 6 | import urllib2 7 | import sys 8 | from urllib2 import Request, urlopen, URLError, HTTPError 9 | 10 | #url and url header 11 | #zabbix的api 地址,用户名,密码,这里修改为自己实际的参数 12 | zabbix_url="http://zabbix-gui.itnihao.com/api_jsonrpc.php" 13 | zabbix_header = {"Content-Type":"application/json"} 14 | zabbix_user = "admin" 15 | zabbix_pass = "zabbix" 16 | auth_code = "" 17 | 18 | #auth user and password 19 | #用户认证信息的部分,最终的目的是得到一个SESSIONID 20 | #这里是生成一个json格式的数据,用户名和密码 21 | auth_data = json.dumps( 22 | { 23 | "jsonrpc":"2.0", 24 | "method":"user.login", 25 | "params": 26 | { 27 | "user":zabbix_user, 28 | "password":zabbix_pass 29 | }, 30 | "id":0 31 | }) 32 | 33 | # create request object 34 | request = urllib2.Request(zabbix_url,auth_data) 35 | for key in zabbix_header: 36 | request.add_header(key,zabbix_header[key]) 37 | 38 | #auth and get authid 39 | try: 40 | result = urllib2.urlopen(request) 41 | #对于出错新的处理 42 | except HTTPError, e: 43 | print 'The server couldn\'t fulfill the request, Error code: ', e.code 44 | except URLError, e: 45 | print 'We failed to reach a server.Reason: ', e.reason 46 | else: 47 | response=json.loads(result.read()) 48 | result.close() 49 | #判断SESSIONID是否在返回的数据中 50 | if 'result' in response: 51 | auth_code=response['result'] 52 | else: 53 | print response['error']['data'] 54 | 55 | # request json 56 | json_data={ 57 | "method":"host.delete", 58 | "params":['10113'] 59 | } 60 | json_base={ 61 | "jsonrpc":"2.0", 62 | "auth":auth_code, 63 | "id":1 64 | } 65 | json_data.update(json_base) 66 | #用得到的SESSIONID去通过验证,获取主机的信息(用http.get方法) 67 | if len(auth_code) == 0: 68 | sys.exit(1) 69 | if len(auth_code) != 0: 70 | get_host_data = json.dumps(json_data) 71 | 72 | # create request object 73 | request = urllib2.Request(zabbix_url,get_host_data) 74 | for key in zabbix_header: 75 | request.add_header(key,zabbix_header[key]) 76 | 77 | # get host list 78 | try: 79 | result = urllib2.urlopen(request) 80 | except URLError as e: 81 | if hasattr(e, 'reason'): 82 | print 'We failed to reach a server.' 83 | print 'Reason: ', e.reason 84 | elif hasattr(e, 'code'): 85 | print 'The server could not fulfill the request.' 86 | print 'Error code: ', e.code 87 | else: 88 | response = json.loads(result.read()) 89 | result.close() 90 | 91 | #将所有的主机信息显示出来 92 | print response 93 | #显示主机的个数 94 | print "Number Of Hosts: ", len(response['result']) 95 | -------------------------------------------------------------------------------- /14-chapter/zabbix-get.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import socket 4 | import optparse 5 | import sys 6 | import struct 7 | 8 | 9 | class ZBXDProtocol(): 10 | MAX_KEY_LENGTH = 65536 11 | HEADER = b'ZBXD\1' 12 | HEADER_LENGTH = 5 13 | EXPECTED_LENGTH_SIZE = 8 14 | RESPONSE_FORMAT = "<5sq{data_length}s" 15 | 16 | def receive_value(self, client): 17 | """ 18 | Receives key and returns it 19 | 20 | Expects to receive header followed by the length of the key 21 | followed by the key. 22 | """ 23 | received = client.recv(self.HEADER_LENGTH) 24 | if received == self.HEADER: 25 | expected_length = struct.unpack( 26 | 'q', client.recv(self.EXPECTED_LENGTH_SIZE) 27 | )[0] 28 | key = client.recv(expected_length) 29 | else: 30 | if '\n' in received: 31 | key = received 32 | else: 33 | key = received + client.recv(self.MAX_KEY_LENGTH) 34 | return key.decode('utf-8') 35 | 36 | def send_value(self, client, value): 37 | """ 38 | Formats value according to protocol and sends it to client 39 | """ 40 | message = self._calculate_message(value) 41 | client.sendall(message) 42 | 43 | def _calculate_message(self, value): 44 | formatted_value = self._format(value) 45 | data_length = len(formatted_value) 46 | response = struct.pack( 47 | self.RESPONSE_FORMAT.format(data_length=data_length), 48 | self.HEADER, 49 | data_length, 50 | formatted_value 51 | ) 52 | return response 53 | 54 | def _format(self, value): 55 | if isinstance(value, float): 56 | formatted_value = '{0:.4f}'.format(value) 57 | else: 58 | formatted_value = str(value) 59 | return formatted_value 60 | 61 | 62 | option_parser = optparse.OptionParser() 63 | option_parser.add_option('-s', '--host', default='127.0.0.1', 64 | help='host name or IP address of a host') 65 | option_parser.add_option('-p', '--port', type=int, default=10052, 66 | help='port number of agent running on the host') 67 | option_parser.add_option('-t', '--timeout', type=float, default=1.0, 68 | help='socket timeout') 69 | 70 | options, arguments = option_parser.parse_args() 71 | 72 | if len(arguments) == 0: 73 | print("You must provide key") 74 | sys.exit() 75 | 76 | key = arguments[0] 77 | 78 | client_socket = None 79 | try: 80 | client_socket = socket.create_connection((options.host, options.port), 81 | options.timeout) 82 | 83 | protocol = ZBXDProtocol() 84 | protocol.send_value(client_socket, key) 85 | 86 | print(protocol.receive_value(client_socket)) 87 | except Exception as e: 88 | print("Unable to receive data from agent: {0}".format(e)) 89 | 90 | finally: 91 | if client_socket is not None: 92 | client_socket.close() 93 | -------------------------------------------------------------------------------- /14-chapter/zabbix_sender.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import socket 4 | import struct 5 | import simplejson 6 | 7 | class ZabbixSender: 8 | 9 | zbx_header = 'ZBXD' 10 | zbx_version = 1 11 | zbx_sender_data = {u'request': u'sender data', u'data': []} 12 | send_data = '' 13 | 14 | def __init__(self, server_host, server_port = 10051): 15 | self.server_ip = socket.gethostbyname(server_host) 16 | self.server_port = server_port 17 | 18 | def AddData(self, host, key, value, clock = None): 19 | add_data = {u'host': host, u'key': key, u'value': value} 20 | if clock != None: 21 | add_data[u'clock'] = clock 22 | self.zbx_sender_data['data'].append(add_data) 23 | return self.zbx_sender_data 24 | 25 | def ClearData(self): 26 | self.zbx_sender_data['data'] = [] 27 | return self.zbx_sender_data 28 | 29 | def __MakeSendData(self): 30 | zbx_sender_json = simplejson.dumps(self.zbx_sender_data, separators=(',', ':'), ensure_ascii=False).encode('utf-8') 31 | json_byte = len(zbx_sender_json) 32 | self.send_data = struct.pack("<4sBq" + str(json_byte) + "s", self.zbx_header, self.zbx_version, json_byte, zbx_sender_json) 33 | 34 | def Send(self): 35 | self.__MakeSendData() 36 | so = socket.socket() 37 | so.connect((self.server_ip, self.server_port)) 38 | wobj = so.makefile(u'wb') 39 | wobj.write(self.send_data) 40 | wobj.close() 41 | robj = so.makefile(u'rb') 42 | recv_data = robj.read() 43 | robj.close() 44 | so.close() 45 | tmp_data = struct.unpack("<4sBq" + str(len(recv_data) - struct.calcsize("<4sBq")) + "s", recv_data) 46 | recv_json = simplejson.loads(tmp_data[3]) 47 | return recv_data 48 | 49 | if __name__ == '__main__': 50 | sender = ZabbixSender(u'127.0.0.1') 51 | for num in range(0,2): 52 | sender.AddData(u'Zabbix server', u'test', u'sent data' + str(num)) 53 | res = sender.Send() 54 | print sender.send_data 55 | print res 56 | -------------------------------------------------------------------------------- /16-chapter/keepalived/conf/chk_zabbix_server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # 4 | status1=$(ps aux|grep "/usr/sbin/zabbix_server" | grep -v grep | grep -v bash | wc -l) 5 | 6 | if [ "${status1}" = "0" ]; then 7 | 8 | /etc/init.d/zabbix-server start 9 | sleep 3 10 | 11 | status2=$(ps aux|grep zabbix_server | grep -v grep | grep -v bash |wc -l) 12 | if [ "${status2}" = "0" ]; then 13 | /etc/init.d/keepalived stop 14 | fi 15 | fi 16 | -------------------------------------------------------------------------------- /16-chapter/keepalived/conf/keepalived.conf: -------------------------------------------------------------------------------- 1 | global_defs { 2 | notification_email { 3 | admin@itnihao.com 4 | } 5 | notification_email_from zabbix-master@itnihao.com 6 | smtp_server 127.0.0.1 7 | smtp_connect_timeout 30 8 | router_id LVS_DEVEL 9 | } 10 | 11 | 12 | vrrp_script chk_zabbix_server { 13 | script "/etc/keepalived/chk_zabbix_server.sh" 14 | interval 30 15 | weight 2 16 | } 17 | 18 | vrrp_instance VI_1 { 19 | state MASTER 20 | #state BACKUP 21 | interface eth0 22 | virtual_router_id 51 23 | priority 111 24 | #priority 100 #BACKUP 25 | advert_int 1 26 | mcast_src_ip 192.168.0.3 27 | 28 | authentication { 29 | auth_type PASS 30 | auth_pass ZabbixMonitor 31 | } 32 | 33 | track_script { 34 | chk_zabbix_server 35 | } 36 | 37 | #VIP 38 | virtual_ipaddress { 39 | 192.168.0.5 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /16-chapter/keepalived/keepalived-1.2.7-3.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/16-chapter/keepalived/keepalived-1.2.7-3.el6.x86_64.rpm -------------------------------------------------------------------------------- /17-chapter/zabbix-database-1.8-2.0-2.2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/17-chapter/zabbix-database-1.8-2.0-2.2.xlsx -------------------------------------------------------------------------------- /NMP/README.md: -------------------------------------------------------------------------------- 1 | =============== 2 | 1.本RPM包,只支持centos6.X RHEL6.X,如果其他版本系统,需自行rpmbuild. 3 | 4 | php安装之前需卸载系统自带的php版本 5 | 卸载命令为:rpm -qa|grep php|xargs rpm -e 6 | rpm -ivh \ 7 | libicu-4.2.1-9.1.el6_2.x86_64.rpm \ 8 | libmcrypt-2.5.8-9.el6.x86_64.rpm \ 9 | libjpeg-turbo-1.2.1-1.el6.x86_64.rpm \ 10 | libtidy-0.99.0-19.20070615.1.el6.x86_64.rpm \ 11 | php-5.4.25-1.el6.x86_64.rpm 12 | 13 | 默认已开启php-fpm服务(service php-fpm start) 14 | 默认让php-fpm用sock方式,sock文件路径为/var/run/php/php-fpm.sock 15 | 16 | 以下软件为依赖包,在RHEL系统中需要额外下载 17 | libicu-4.2.1-9.1.el6_2.x86_64.rpm 18 | libmcrypt-2.5.8-9.el6.x86_64.rpm 19 | libjpeg-turbo-1.2.1-1.el6.x86_64.rpm 20 | libtidy-0.99.0-19.20070615.1.el6.x86_64.rpm 21 | -------------------------------------------------------------------------------- /NMP/SPECS/php-5.4.25.spec: -------------------------------------------------------------------------------- 1 | Name: php 2 | Version: 5.4.25 3 | Release: 1%{?dist} 4 | Summary: PHP is a widely-used general-purpose scripting language. 5 | 6 | Group: Development/Languages 7 | License: PHP License v3.01 8 | URL: http://www.php.net 9 | Source0: http://www.php.net/distributions/php-%{version}.tar.gz 10 | #Source1: %{name}.conf 11 | #Source2: %{name}.ini 12 | #Source3: %{name}-fpm.conf 13 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot 14 | Vendor: admin@itnihao.com 15 | Obsoletes: php 16 | 17 | BuildRequires: make 18 | BuildRequires: bzip2 >= 1.0.2-4 19 | BuildRequires: libcurl-devel >= 7.19.7 20 | BuildRequires: gd-devel >= 2.0.35 21 | BuildRequires: libicu-devel >= 4.0 22 | BuildRequires: libtidy-devel >= 0.9 23 | BuildRequires: libmcrypt-devel >= 2.5.8-2 24 | BuildRequires: glibc-common >= 2.12 25 | #BuildRequires: mhash-devel >= 0.9 26 | BuildRequires: mcrypt >= 2.6 27 | BuildRequires: libtool-ltdl-devel >= 1.5.26-1 28 | BuildRequires: libxml2-devel >= 2.6.32-2 29 | BuildRequires: openldap-devel >= 2.4.23 30 | BuildRequires: openssl-devel >= 0.9.8 31 | BuildRequires: pcre-devel >= 7.8-2 32 | BuildRequires: t1lib-devel >= 5.1.2-1 33 | BuildRequires: zlib-devel >= 1.2.3-3 34 | BuildRequires: bzip2-devel 35 | 36 | Requires: openssl-devel 37 | Requires: pcre-devel 38 | Requires(pre): shadow-utils 39 | Requires(post): chkconfig 40 | 41 | %description 42 | PHP is a widely-used general-purpose scripting language that is especially 43 | suited for Web development and can be embedded into HTML. 44 | 45 | %prep 46 | %setup -q -n %{name}-%{version} 47 | %build 48 | EXTENSION_DIR=%{_libdir}/php/modules; export EXTENSION_DIR 49 | %configure --with-layout=GNU --with-libdir=lib64 --enable-fpm --with-gd --enable-intl --enable-exif --enable-bcmath --enable-mbstring --enable-pcntl --enable-json --enable-soap --enable-sockets --enable-sqlite-utf8 --enable-zip --enable-shmop --enable-pdo --with-zlib --with-bz2 --with-curl --with-curlwrappers --with-jpeg-dir --with-freetype-dir --with-png-dir --with-iconv --with-xpm-dir --with-zlib-dir --with-gettext --with-pcre-regex --with-mcrypt --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --with-pdo-sqlite --with-tidy=/usr --with-pear=%{_datadir}/php/pear --with-icu-dir=/usr --with-config-file-scan-dir=%{_sysconfdir}/php.d --disable-debug --disable-ipv6 50 | 51 | make %{?_smp_mflags} 52 | 53 | %install 54 | [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} 55 | mkdir -p %{buildroot}%{_initrddir} 56 | mkdir -p %{buildroot}%{_sysconfdir}/php.d 57 | install -Dp -m0755 sapi/fpm/init.d.php-fpm.in %{buildroot}%{_initrddir}/php-fpm 58 | install -m 644 php.ini-development $RPM_BUILD_ROOT%{_sysconfdir}/php.ini 59 | %{__make} install INSTALL_ROOT="%{buildroot}" 60 | %{__install} -m 755 sapi/fpm/init.d.php-fpm $RPM_BUILD_ROOT%{_initrddir}/php-fpm 61 | %{__cp} $RPM_BUILD_ROOT%{_sysconfdir}/php-fpm.conf.default $RPM_BUILD_ROOT%{_sysconfdir}/php-fpm.conf 62 | %clean 63 | [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} 64 | 65 | %post 66 | sed -i "/;date.timezone =/adate.timezone = Asia\/Shanghai" /etc/php.ini 67 | sed -i "s/listen = 127.0.0.1:9000/;listen = 127.0.0.1:9000/g" /etc/php-fpm.conf 68 | mkdir /var/run/php/ 69 | grep "listen = /var/run/php/php-fpm.sock" /etc/php-fpm.conf 70 | [ "$?" != 0 ] && sed -i "/;listen = 127.0.0.1:9000/alisten = /var/run/php/php-fpm.sock\n" /etc/php-fpm.conf 71 | /sbin/chkconfig --add php-fpm 72 | /sbin/chkconfig --level 2345 php-fpm on 73 | /sbin/service php-fpm start 74 | 75 | %preun 76 | if [ "$1" = 0 ] ; then 77 | /sbin/service php-fpm stop > /dev/null 2>&1 78 | /sbin/chkconfig --del php-fpm 79 | fi 80 | exit 0 81 | 82 | %postun 83 | if [ "$1" -ge 1 ]; then 84 | /sbin/service php-fpm condrestart > /dev/null 2>&1 85 | fi 86 | exit 0 87 | 88 | %files 89 | %defattr(-,root,root,-) 90 | %{_bindir}/* 91 | %{_sbindir}/* 92 | %{_includedir}/* 93 | %{_libdir}/* 94 | %{_mandir}/man1/php* 95 | %{_sysconfdir}/* 96 | %{_sysconfdir}/php.d 97 | %{_datadir}/* 98 | %{_initrddir}/* 99 | %exclude /.channels 100 | %exclude /.depdb 101 | %exclude /.depdblock 102 | %exclude /.filemap 103 | %exclude /.lock 104 | #%config(noreplace) %{_sysconfdir}/php.ini 105 | 106 | 107 | %changelog 108 | * Sun Feb 23 2014 itnihao - 5.4.35 109 | - updated to 5.4.25 110 | 111 | * Fri Jul 5 2013 Itnihao build - 5.3.26-1 112 | - php 5.3.26.1 release 113 | 114 | * Fri Jan 25 2013 Itnihao build - 5.3.21-1 115 | 116 | * Wed Dec 21 2011 Mike Willbanks - 5.3.8-1 117 | - Updated to 5.3.8 118 | * Tue Feb 23 2011 Mike Willbanks - 5.3.5-1 119 | - Initial Package 120 | -------------------------------------------------------------------------------- /NMP/SRPM/nginx-1.4.5-1.el6.ngx.src.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/SRPM/nginx-1.4.5-1.el6.ngx.src.rpm -------------------------------------------------------------------------------- /NMP/SRPM/php-5.4.25-1.el6.src.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/SRPM/php-5.4.25-1.el6.src.rpm -------------------------------------------------------------------------------- /NMP/SRPM/zabbix-2.2.2-0.el6.zbx.src.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/SRPM/zabbix-2.2.2-0.el6.zbx.src.rpm -------------------------------------------------------------------------------- /NMP/conf/zabbix-apache-web.conf: -------------------------------------------------------------------------------- 1 | #author itnihao@qq.com 2 | #blog http://itnihao.blog.51cto.com 3 | #GPL 4 | # Zabbix monitoring system php web frontend 5 | # 6 | 7 | Alias /zabbix /usr/share/zabbix 8 | 9 | 10 | Options FollowSymLinks 11 | AllowOverride None 12 | 13 | 14 | # Apache 2.4 15 | Require all granted 16 | 17 | 18 | 19 | # Apache 2.2 20 | Order allow,deny 21 | Allow from all 22 | 23 | 24 | #php value 25 | php_value date.timezone Asia/Shanghai 26 | php_value max_execution_time 300 27 |   php_value post_max_size 16M 28 | php_value max_input_time 300 29 | php_value memory_limit 128M 30 | php_value upload_max_filesize 2M 31 | 32 | 33 | 34 | 35 | 36 | # Apache 2.4 37 | Require all denied 38 | 39 | 40 | 41 | # Apache 2.2 42 | Order deny,allow 43 | Deny from all 44 | 45 | 46 | 47 | 48 | # Apache 2.4 49 | Require all denied 50 | 51 | 52 | 53 | Order deny,allow 54 | Deny from all 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /NMP/conf/zabbix-nginx-web.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name localhost; 4 | charset utf-8; 5 | index index.htm index.html index.php; 6 | access_log /var/log/nginx/zabbix.access.log main; 7 | error_log /var/log/nginx/zabbix.error.log; 8 | root /usr/share/zabbix; 9 | 10 | location ~ (/.svn/|etc/passwd|etc/shadow|etc/group|etc/gshadow|etc/sudoers|nginx/nginx.conf|etc/my.cnf|sshd_config|ifconfig|bin/rm|bin/mkdir|bin/rmdir|bin/touch|usr/bin/vim|rsync.conf|redis.conf) { 11 | deny all; 12 | } 13 | 14 | location / { 15 | index index.html index.htm index.php; 16 | if (!-f $request_filename){ 17 | rewrite ^(.*)$ http://$http_host/index.html last; 18 | break; 19 | } 20 | if ($http_user_agent ~ (curl|wget|LWP::Simple|winhttp|clshttp|HTTrack|harvest|nsauditor|dirbuster|pangolin|nmap|sqlninja|grendel-scan|hydra|perl|HTMLParser|libwww|BBBike|sqlmap|w3af|owasp|Nikto|fimap|havij|PycURL|sae|zmeu|BabyKrokodil|python|netsparker|httperf|ApacheBench|webbench|JoeDog)) 21 | { 22 | return 443; 23 | } 24 | 25 | } 26 | 27 | error_page 500 502 503 504 /50x.html; 28 | location = /50x.html { 29 | root /usr/share/nginx/html; 30 | } 31 | 32 | location ~ .*\.(php|php5)?$ 33 | { 34 | #fastcgi_pass 127.0.0.1:9000; 35 | fastcgi_pass unix:/var/run/php/php-fpm.sock; 36 | fastcgi_index index.php; 37 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 38 | include fastcgi_params; 39 | } 40 | 41 | location /nginxstatus { 42 | stub_status on; 43 | access_log off; 44 | allow 127.0.0.1; 45 | deny all; 46 | } 47 | 48 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 49 | { 50 | expires 10d; 51 | } 52 | 53 | location ~ .*\.(js|css|txt|xml|html|htm)?$ 54 | { 55 | expires 12h; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /NMP/mysql-install-readme.md: -------------------------------------------------------------------------------- 1 | #Percona-Server数据库的二进制安装方法 2 | 3 | #下载文件 4 | ``` 5 | #wget http://www.percona.com/redir/downloads/Percona-Server-5.6/LATEST/binary/linux/x86_64/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64.tar.gz 6 | #tar xf Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64.tar.gz 7 | #mv Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64 /usr/local/ 8 | #cd /usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/ 9 | #cp support-files/mysql.server /etc/init.d/mysqld 10 | ``` 11 | #建立用户 12 | ``` 13 | #groupadd -g 27 mysql 14 | #useradd -g 27 -s /sbin/nologin mysql 15 | ``` 16 | #改变权限 17 | ``` 18 | #chown -R mysql.mysql /usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/ 19 | ``` 20 | #配置环境变量 21 | ``` 22 | #vim ~/.bash_profile 23 | PATH=PATH:HOME/bin:/usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/bin 24 | ``` 25 | 提示:如果路径不为/usr/local,则需要修改启动脚本/etc/init.d/mysqld 26 | #启动percona-server服务 27 | 注意不能存在文件/etc/my.cnf,否则,由于my.cnf里的不正确配置而导致mysql不能正常启动,因为mysqld脚本里面默认路径会去找/etc/my.cnf这个文件。 28 | ``` 29 | #mysqld --verbose --help|grep my.cnf 30 | my.cnf将会存在于以下路径,依次为优先级匹配。 31 | /etc/my.cnf 32 | /etc/mysql/my.cnf 33 | /usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/etc/my.cnf 34 | ~/.my.cnf 35 | ``` 36 | 但在测试的时候,发现并未读取 37 | ``` 38 | /usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/etc/my.cnf 39 | ``` 40 | #配置my.cnf文件 41 | ``` 42 | # cat /usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/etc/my.cnf 43 | [mysqld] 44 | datadir=/usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/data 45 | socket=/usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/var/run/mysql.sock 46 | user=mysql 47 | # Disabling symbolic-links is recommended to prevent assorted security risks 48 | symbolic-links=0 49 | character-set-server=utf8 50 | innodb_file_per_table=1 51 | 52 | [mysqld_safe] 53 | log-error=/usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/var/log/mysqld.log 54 | pid-file=/usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/var/run/mysqld/mysqld.pid 55 | ``` 56 | 以上my.cnf为简单的参数配置,后期还需要对此进行调整 57 | ``` 58 | #mkdir -p /usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/var/run 59 | #mkdir -p /usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/var/log 60 | #mkdir -p /usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/etc 61 | ``` 62 | #初始化mysql 63 | ``` 64 | #mkdir /opt/bak 65 | #mv /etc/my.cnf /opt/bak 66 | #./scripts/mysql_install_db \ 67 | --user=mysql \ 68 | --basedir=/usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/ \ 69 | --datadir=/usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/data/ 70 | #./bin/mysqld_safe & 71 | 72 | #改变权限 73 | ``` 74 | #chown -R mysql.mysql /usr/local/Percona-Server-5.6.15-rel63.0-519-static-openssl-1.0.1e.Linux.x86_64/ 75 | ``` 76 | 77 | #chkconfig mysqld on 78 | #/etc/init.d/mysqld start 79 | ``` 80 | 81 | 82 | -------------------------------------------------------------------------------- /NMP/nginx/nginx-1.4.5-1.el6.ngx.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/nginx/nginx-1.4.5-1.el6.ngx.x86_64.rpm -------------------------------------------------------------------------------- /NMP/php/php-5.4.25-1.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/php/php-5.4.25-1.el6.x86_64.rpm -------------------------------------------------------------------------------- /NMP/php/require-rpm/libicu-4.2.1-9.1.el6_2.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/php/require-rpm/libicu-4.2.1-9.1.el6_2.x86_64.rpm -------------------------------------------------------------------------------- /NMP/php/require-rpm/libjpeg-turbo-1.2.1-1.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/php/require-rpm/libjpeg-turbo-1.2.1-1.el6.x86_64.rpm -------------------------------------------------------------------------------- /NMP/php/require-rpm/libmcrypt-2.5.8-9.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/php/require-rpm/libmcrypt-2.5.8-9.el6.x86_64.rpm -------------------------------------------------------------------------------- /NMP/php/require-rpm/libtidy-0.99.0-19.20070615.1.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/php/require-rpm/libtidy-0.99.0-19.20070615.1.el6.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/require-rpm/OpenIPMI-devel-2.0.16-12.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/require-rpm/OpenIPMI-devel-2.0.16-12.el6.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/require-rpm/fping-2.4b2-10.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/require-rpm/fping-2.4b2-10.el6.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/require-rpm/libssh2-1.2.2-7.el6_2.3.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/require-rpm/libssh2-1.2.2-7.el6_2.3.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/require-rpm/libssh2-devel-1.2.2-7.el6_2.3.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/require-rpm/libssh2-devel-1.2.2-7.el6_2.3.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/require-rpm/php-bcmath-5.3.3-3.el6_2.8.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/require-rpm/php-bcmath-5.3.3-3.el6_2.8.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/require-rpm/php-mbstring-5.3.3-3.el6_2.8.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/require-rpm/php-mbstring-5.3.3-3.el6_2.8.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/zabbix-agent-2.2.2-0.el6.zbx.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/zabbix-agent-2.2.2-0.el6.zbx.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/zabbix-java-gateway-2.2.2-0.el6.zbx.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/zabbix-java-gateway-2.2.2-0.el6.zbx.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/zabbix-mysql-2.2.2-0.el6.zbx.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/zabbix-mysql-2.2.2-0.el6.zbx.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/zabbix-proxy-2.2.2-0.el6.zbx.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/zabbix-proxy-2.2.2-0.el6.zbx.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/zabbix-server-2.2.2-0.el6.zbx.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/zabbix-server-2.2.2-0.el6.zbx.x86_64.rpm -------------------------------------------------------------------------------- /NMP/zabbix/zabbix-web-apache-2.2.2-0.el6.zbx.noarch.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/zabbix-web-apache-2.2.2-0.el6.zbx.noarch.rpm -------------------------------------------------------------------------------- /NMP/zabbix/zabbix-web-nginx-2.2.2-0.el6.zbx.noarch.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/NMP/zabbix/zabbix-web-nginx-2.2.2-0.el6.zbx.noarch.rpm -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##《Zabbix企业级分布式监控系统》 2 | 本项目是《Zabbix企业级分布式监控系统》一书的附件部分(不仅限于附件,还有扩充内容),该书可在各大网站买到。 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
网站名称链接
亚马逊http://www.amazon.cn/3/dp/B00MN6QEYK
china-pubhttp://product.china-pub.com/4275086
京东http://t.cn/RPY5JtR
当当http://t.cn/RPHauKF
官方收录地址http://www.zabbix.com/documentation.php
30 | 31 | ##### QQ交流群 32 | ``` 33 | 本书的读者QQ群【Zabbix群加群验证信息:Zabbix监控】 : 34 | Zabbix企业级分布式监控 2群 189342378(500人可加) 35 | Zabbix企业级分布式监控 1群 271659981(1000人已满) 36 | ``` 37 | ![图1](static/img/zabbix-QQ-group-1.jpeg) 38 | 39 | ### 勘误列表 40 | ``` 41 | https://github.com/itnihao/zabbix-book/blob/master/error-fix/README.md 42 | ``` 43 | 44 | ### 该书的目录如下: 45 | 46 | 第一部分Zabbix基础 47 | 48 | 第一章,监控系统简介 49 | ==================================== 50 | ``` 51 | 1.1为何需要监控系统 52 | 1.2监控系统的实现 53 | 1.3监控系统的开源软件现状 54 | 1.3.1 MRTG 55 | 1.3.2 Cacti 56 | 1.3.3 SmokePing 57 | 1.3.4 Graphite 58 | 1.3.5 Nagios 59 | 1.3.6 Zenoss Core 60 | 1.3.7 Ganglia 61 | 1.3.8 OpenTSDB 62 | 1.3.9 Zabbix 63 | 1.4监控系统的原理探究 64 | ``` 65 | 第二章,Zabbix简介 66 | == 67 | ``` 68 | 2.1 Zabbix的客户 69 | 2.2 使用Zabbix的准备 70 | 2.3 Zabbix为何物 71 | 2.4 选择Zabbix的理由 72 | 2.5 Zabbix的架构 73 | 2.6 zabbix运行流程 74 | 2.7 Zabbix功能特性 75 | ``` 76 | 第三章,安装部署 77 | == 78 | ``` 79 | 3.1 安装环境概述 80 | 3.1.1 硬件条件 81 | 3.1.2 软件条件 82 | 3.1.3 部署环境的考虑 83 | 3.2 zabbix_server服务端的安装 84 | 3.2.1 安装 Zabbix-Server 85 | 3.2.2 安装 MySQL 数据库服务 86 | 3.2.3 配置 zabbix_server.conf 87 | 3.2.4 防火墙、Selinux 和权限的设置 88 | 3.2.5 配置 Web 界面 89 | 3.2.6 故障处理 .... 90 | 3.3 zabbix-agent客户端的安装 91 | 3.3.1 安装 Zabbix-Agent 92 | 3.3.2 防火墙的设置 93 | 3.3.3 配置 zabbix_agentd.conf 94 | 3.4 snmp监控方式的安装配置 95 | 3.5 Windows上安装zabbix-agent 96 | 3.6 其他平台的安装 97 | 3.7 zabbix_get的使用 98 | 3.8 zabbix术语(命令)相关 99 | 3.9 Zabbix-server对数据的存储 100 | 3.9.1 Zabbix 对数据存储 101 | 3.9.2 MySQL 表分区实例 102 | 3.10 Zabbix init脚本解释 103 | 3.11安全和高可用 104 | 3.12zabbix数据库的备份 105 | ``` 106 | 第四章,快速配置使用 107 | == 108 | ``` 109 | 4.1配置流程 110 | 4.2主机组的添加 111 | 4.3模板的添加 112 | 4.4添加主机 113 | 4.5 Graphs的配置 114 | 4.6 screen的配置 115 | 4.7 Slide shows的配置 116 | 4.8 zatree的使用 117 | 4.9 map的配置 118 | 4.10 WEB监控 119 | 4.10.1 Web 监控的原理 120 | 4.10.2 Web 监控指标 121 | 4.10.3 Zabbix 中 Web 监控的配置 122 | 4.10.4 认证的支持 123 | 4.10.5 触发器的设置 124 | 4.10.6 排错 125 | 4.11 IT服务 126 | 4.12报表 127 | 4.13资产管理 128 | ``` 129 | 第五章,深入配置使用 130 | == 131 | ``` 132 | 5.1 Items的添加 133 | 5.1.1 Items 的含义 134 | 5.1.2 如何添加 Items 135 | 5.2 Items key的添加 136 | 5.3 ITEMS的类型 137 | 5.3.1 Zabbix-Agent 138 | 5.3.2 Simple check 139 | 5.3.3 日志监控方式 140 | 5.3.4 监控项计算(Calculated) 141 | 5.3.5 聚合检测(Aggregate) 142 | 5.3.6 内部检测(Internal) 143 | 5.3.7 SSH、Telnet 和扩展检测 . 144 | 5.4宏的配置 145 | 5.5维护时间 146 | 5.6事件确认 147 | 5.7数据的导入导出配置 148 | ``` 149 | 第六章 ,告警的配置 150 | == 151 | ``` 152 | 6.1 告警的概述 153 | 6.2Trigger的配置 154 | 6.2.1 Trigger 的状态 155 | 6.2.2 Trigger 的配置步骤 156 | 6.2.3 Trigger 告警依赖 157 | 6.2.4 Trigger 正则中的单位 158 | 6.2.5 Trigger 表达式举例 159 | 6.2.6 Trigger 函数 160 | 6.3添加 Actions 161 | 6.3.1 Actions 概述 162 | 6.3.2 Actions 的配置 163 | 6.3.3 Conditions 的配置 164 | 6.3.4 Operations 的功能 165 | 6.3.5 告警消息发送的配置 166 | 6.3.6 执行远程命令的配置 167 | 6.4邮件告警配置实例 168 | 6.4.1 创建 Media 169 | 6.4.2 创建用户 170 | 6.4.3 创建 Actions 171 | 6.4.2创建用户 172 | 6.5自定义脚本告警 173 | 6.6邮件告警脚本的配置实例 174 | 6.7告警升级的机制 175 | 6.8告警配置故障排查 176 | ``` 177 | 178 | 第二部分,zabbix中级部分 179 | = 180 | 第七章,监控方式剖析 181 | == 182 | ``` 183 | 7.1 Zabbix支持的监控方式 184 | 7.2 Zabbix监控方式的逻辑 185 | 7.3 agent监控方式 186 | 7.4 Trapper监控方式 187 | 7.4.1 Trapper 的配置步骤 188 | 7.4.2 Trapper 的配置示例 189 | 7.4.3 使用 zabbix-sender 发送数据 190 | 7.5 SNMP监控方式 191 | 7.5.1 SNMP 概述 192 | 7.5.2 SNMP 协议的运行 193 | 7.5.3 SNMP 协议原理 194 | 7.5.4 MIB 简 195 | 7.5.5 SNMP 的相关术语 196 | 7.5.6 配置 Zabbix 以 SNMP 方式监控 197 | 7.6 IPMI监控方式 198 | 7.7 JMX监控方式 199 | 7.7.1 JMX 在 Zabbix 中的运行流程 200 | 7.7.2 配置 JMX 监控的步骤 201 | 7.7.3 安装 Zabbix-Java-Gateway 202 | 7.7.4 配置 Zabbix-Java-Gateway 203 | 7.7.5 监控 Java 应用程序 204 | 7.7.6 自定义 JMX 的 Key 205 | 7.7.7 监控 Tomcat 206 | 7.7.8 Weblogic 的监控 207 | 7.8命令执行 208 | ``` 209 | 第八章,分布式监控 210 | == 211 | ``` 212 | 8.1代理架构 213 | 8.2节点架构 214 | 8.3主动模式和被动模式 215 | 8.3.1 被动模式 216 | 8.3.2 主动模式 217 | ``` 218 | 第九章,Zabbix与自动化运维 219 | == 220 | ``` 221 | 9.1监控自动化 222 | 9.2网络发现 223 | 9.3主动方式的自动注册 224 | 9.3.1 功能概述 225 | 9.3.2 主动方式自动注册的配置 226 | 9.3.3 使用 Host metadata 227 | 9.3.4 关于自动注册的注意事项 228 | 9.4 low level discovery 229 | 9.4.1 现实案例需求 230 | 9.4.2 Zabbix 客户端配置 231 | 9.4.3 Low level discovery 自动发现脚本编写 232 | 9.4.4 自定义 Key 配置文件 233 | 9.4.5 Web 页面添加 Low level discovery . 234 | 9.5 Zabbix在自动化运维工具的使用 235 | ``` 236 | 第十章,使用的经验技巧 237 | == 238 | ``` 239 | 10.1如何有效的设置监控告警 240 | 10.2监控项的使用技巧 241 | 10.3触发器的使用技巧 242 | 10.4触发器配置 243 | 10.5谷歌浏览器告警插件 244 | 10.6数据图断图的原因 245 | ``` 246 | 第十一章,监控案例 247 | == 248 | ``` 249 | 11.1监控tcp连接数 250 | 11.2监控nginx 251 | 11.3监控php-fpm 252 | 11.4监控mysql 253 | 11.4.1 用自带的模板监控 MySQL 254 | 11.4.2 用 Percona Monitoring Plugins 监控 MySQL . 255 | 11.5监控tomcat,weblogic 256 | 11.6监控dell服务器 257 | 11.7监控Cisco路由器 258 | 11.8监控VMware 259 | 11.9 hadoop监控 260 | 11.10 更多监控 261 | ``` 262 | 263 | 第三部分Zabbix高级部分 264 | = 265 | 第十二章,性能优化 266 | == 267 | ``` 268 | 12.1Zabbix的性能优化的概述 269 | 12.2Zabbix的性能优化的依据 270 | 12.3配置文件的参数优化 271 | 12.4 Zabbix的架构优化 272 | 12.5 Zabbix的items中工作模式以及Trigger的优化 273 | 12.6 Zabbix的数据库优化 274 | 12.7其他方面的 275 | ``` 276 | 第十三章,Zabbix API的使用 277 | == 278 | ``` 279 | 13.1 Zabbix API简介 280 | 13.2什么是json-rpc 281 | 12.3Zabbix API的使用流程 282 | 13.3.1 使用 API 的基本步骤 283 | 13.3.2 如何使用官方文档获取帮助 284 | 13.3.3 用 CURL 模拟 API 的使用 285 | 13.3.4 HTTP 头部 Content-Type 设置 286 | 13.3.5 关于用户认证 287 | 13.3.6 获取主机信息(用 Python 写的示例) 288 | 13.3.7 添加 Host 289 | 13.3.8 删除 Host 290 | 13.4第三方zabbixAPI模块 291 | ``` 292 | 第十四章,使用Zabbix协议 293 | == 294 | ``` 295 | 14.1 Zabbix协议概述 296 | 14.2 Zabbix sender协议 297 | 14.2.1 Sender 数据发送 298 | 14.2.2 Server 对数据响应的处理 299 | 14.2.3 Zabbix-Sender 的实例 300 | 14.2 Zabbix get协议 301 | 14.2 Zabbix agent协议 302 | ``` 303 | 第十五章,定制Zabbix安装包 304 | == 305 | ``` 306 | 15.1为什么需要定制安装包 307 | 15.2如何定制安装包 308 | ``` 309 | 第十六章,大型分布式监控案例 310 | == 311 | ``` 312 | 16.1监控系统构建的概述 313 | 16.2监控环境架构图 314 | 16.3架构实现的过程 315 | 16.3.1 硬件和软件需求 316 | 16.3.2 Zabbix DB 的安装 317 | 16.3.3 安装 Zabbix-Server 318 | 16.3.4 安装 Zabbix-GUI 319 | 16.3.5 安装 Zabbix-Proxy 320 | 16.3.6 配置 Zabbix-Agent 321 | 16.4业务相关的配置 322 | 16.4.1 用户的配置 323 | 16.4.2 业务组的配置 324 | 16.4.3 监控模板的定制 325 | 16.4.4 自动发现的配置 326 | 16.5其他需求 327 | ``` 328 | 329 | 第四部分 附录 330 | = 331 | 第十七章,源码安装及相关配置 332 | == 333 | ``` 334 | 17.1安装zabbix-server 335 | 17.2 Zabbix-agent的安装 336 | 17.3 关于zabbix的升级 337 | ``` 338 | === 339 | 开源文档 340 | ``` 341 | 《Zabbix使用手册V2.0》下载地址http://pan.baidu.com/s/1qWDHXkK 提取密码为8kq4 342 | ``` 343 | -------------------------------------------------------------------------------- /error-fix/README.md: -------------------------------------------------------------------------------- 1 | ##《Zabbix企业级分布式监控系统》勘误列表 2 | 3 | 前言 陈益超改为陈艺超 4 | 5 | P22 362+67+4=433 @一期一会 6 | P40 /etc/snmp/snmpd.conf 7 | P47 trends_unit(存储非符号的整数)更正为trends_uint表。 8 | P56 将在(16.3)节中 9 | P62 图web app少了下划线 10 | P72 只有部分触发器(函数) 11 | P102 表 5-1 Name 选项,**$1、$2…$9** 指的是 Item Key 的第 **1、2…9** 个参数,原文说是「Item 名称」的参数。 12 | P103 表 5-1 Units 选项,与时间相关的单位 **unixtime**、**uptime**、**s** 全部是小写字母。首字母大写导致显示时不能正常转换。 13 | P124 开始部分应该概述功能,第二版增加 14 | P143 '15'(天)代表'86400s'(秒)更正为'1d'(天)代表'86400s'(秒)。@jun-东莞-运维 15 | P153 表6-5 Recovery message写了两遍 @Miku酱 16 | P161 表6-7的Description应该为Name @cexpert 17 | P202 缺少proxy的数据同步参数,第二版增加 18 | P203 创建的数据库名称应该为 19 | ``` 20 | shell# service mysqld start 21 | shell# mysql -uroot -p 22 | mysql> use zabbix_proxy; 23 | mysql> create database zabbix_proxy character set utf8; 24 | mysql> grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'zabbix'; 25 | mysql> flush privileges; 26 | ``` 27 | @唐文军 28 | P255 nginx监控脚本已经调整,见github-book 11章 fix 29 | P256 黑体字是一行的 30 | P265 使用的MySQL脚本需要改变,即261页的MySQL脚本需要改变,见github-book 11章 fix 31 | 32 | -------------------------------------------------------------------------------- /static/img/zabbix-QQ-group-1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhausong/zabbix-book/94ec20171d1ad3f690b2f2ee1f480e0bb1b763dd/static/img/zabbix-QQ-group-1.jpeg -------------------------------------------------------------------------------- /tools/screen_create/README.md: -------------------------------------------------------------------------------- 1 | 2 | 概述 3 | == 4 | screen_create是一个批量创建screen的工具。 5 | 功能: 6 | == 7 | 支持分组创建screen 8 | 支持单个主机创建所有screen 9 | 用法 10 | == 11 | 可以用如下脚本创建一个分组的screen,包括 CPU TCP LOAD指标的screen,如需添加更多图,可以自行添加即可 12 | ``` 13 | #!/bin/bash 14 | for group in Zabbix-Server 15 | do 16 | 17 | for items in "Memory usage" "CPU utilization" "Network TCP Connect status" "CPU load" 18 | do 19 | k=$(echo ${items}|sed "s/ /_/g") 20 | python screen_creator.py -c config --add-all-group ${group} "${items}" --hsize=2 --vsize=11 --width=500 --height=100 "${group}_${k}" 21 | done 22 | done 23 | ``` 24 | -------------------------------------------------------------------------------- /tools/screen_create/add.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for group in Zabbix-Server 4 | do 5 | 6 | for items in "Memory usage" "CPU utilization" "Network TCP Connect status" "CPU load" 7 | do 8 | k=$(echo ${items}|sed "s/ /_/g") 9 | python screen_creator.py -c config --add-all-group ${group} "${items}" --hsize=2 --vsize=11 --width=500 --height=100 "${group}_${k}" 10 | done 11 | done 12 | -------------------------------------------------------------------------------- /tools/screen_create/config: -------------------------------------------------------------------------------- 1 | [zabbix] 2 | username='user' 3 | password='passwd' 4 | url='http://zabbix.itnihao.com' 5 | -------------------------------------------------------------------------------- /zabbix-conf/zabbix_agent.conf: -------------------------------------------------------------------------------- 1 | # This is a config file for Zabbix internet service daemon agent 2 | # To get more information about Zabbix visit http://www.zabbix.com 3 | 4 | ### Option: Server 5 | # IP address of Zabbix server 6 | # Zabbix serverd的IP地址 7 | # Connections from other hosts will be denied 8 | # 如果从其他非Zabbix server的IP地址来访问将会被拒绝 9 | # If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally. 10 | # 11 | # Mandatory: yes 12 | # Default: 13 | # Server= 14 | 15 | Server=127.0.0.1 16 | #如果有多个Zabbix server的地址,这里可以写为Server=127.0.0.1,X.X.X.X,Y.Y.Y.Y (注意,这里的X,Y分别代表需要 17 | #连接到这个agent所在的机器IP地址) 18 | 19 | ############ ADVANCED PARAMETERS ################# 20 | 21 | ### Option: Alias 22 | # Sets an alias for an item key. It can be used to substitute long and complex item key with a smaller and simpler one. 23 | # Multiple Alias parameters may be present. Multiple parameters with the same Alias key are not allowed. 24 | # Different Alias keys may reference the same item key. 25 | # For example, to retrieve the ID of user 'zabbix': 26 | # Alias=zabbix.userid:vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1] 27 | # Now shorthand key zabbix.userid may be used to retrieve data. 28 | # 29 | # Mandatory: no 30 | # Range: 31 | # Default: 32 | 33 | ### Option: Timeout 34 | # Spend no more than Timeout seconds on processing 35 | # 设置处理进程的超时时间 36 | # 37 | # Mandatory: no 38 | # Range: 1-30 39 | # Default: 40 | # Timeout=3 41 | 42 | ### Option: Include 43 | # You may include individual files or all files in a directory in the configuration file. 44 | # Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. 45 | # 46 | # Mandatory: no 47 | # Default: 48 | # Include= 49 | 50 | # 子配置文件的路径 51 | # Include=/usr/local/etc/zabbix_agent.userparams.conf 52 | # Include=/usr/local/etc/zabbix_agent.conf.d/ 53 | 54 | ####### USER-DEFINED MONITORED PARAMETERS ####### 55 | 56 | ### Option: UnsafeUserParameters 57 | # Allow all characters to be passed in arguments to user-defined parameters. 58 | # 允许特殊字符的使用 0-不允许,1-允许,默认不允许 59 | # 0 - do not allow 60 | # 1 - allow 61 | # 62 | # Mandatory: no 63 | # Default: 64 | # UnsafeUserParameters=0 65 | 66 | ### Option: UserParameter 67 | # 用户自定义参数 68 | # User-defined parameter to monitor. There can be several user-defined parameters. 69 | # Format: UserParameter=, 70 | # See 'zabbix_agentd' directory for examples. 71 | # 72 | # Mandatory: no 73 | # Default: 74 | # UserParameter= 75 | 76 | ####### LOADABLE MODULES ####### 77 | 78 | ### Option: LoadModulePath 79 | # 动态加载模块路径 80 | # Full path to location of agent modules. 81 | # Default depends on compilation options. 82 | # 83 | # Mandatory: no 84 | # Default: 85 | # LoadModulePath=${libdir}/modules 86 | 87 | ### Option: LoadModule 88 | # 动态加载模块 89 | # Module to load at agent startup. Modules are used to extend functionality of the agent. 90 | # Format: LoadModule= 91 | # The modules must be located in directory specified by LoadModulePath. 92 | # It is allowed to include multiple LoadModule parameters. 93 | # 94 | # Mandatory: no 95 | # Default: 96 | # LoadModule= 97 | -------------------------------------------------------------------------------- /zabbix-conf/zabbix_agentd.conf: -------------------------------------------------------------------------------- 1 | # This is a config file for the Zabbix agent daemon (Unix) 2 | # To get more information about Zabbix, visit http://www.zabbix.com 3 | 4 | ############ GENERAL PARAMETERS ################# 5 | 6 | ### Option: PidFile 7 | # Name of PID file. 8 | #PID文件的路径,注意需要路径具有Zabbix的用户权限,如路径为/var/run/zabbix,则需要chown -R zabbix.zabbix /var/run/zabbix 9 | # 10 | # Mandatory: no 11 | # Default: 12 | # PidFile=/tmp/zabbix_agentd.pid 13 | 14 | ### Option: LogFile 15 | # Name of log file. 16 | # If not set, syslog is used. 17 | # Log文件的路径,如果没有设置,将会使用syslog,和PID一样,需要注意权限问题,如路径为/var/log/zabbix,则需 18 | # 要chown -R zabbix.zabbix /var/log/zabbix 19 | # 20 | # Mandatory: no 21 | # Default: 22 | # LogFile= 23 | 24 | LogFile=/tmp/zabbix_agentd.log 25 | 26 | ### Option: LogFileSize 27 | # Maximum size of log file in MB. 28 | # 0 - disable automatic log rotation. 29 | # 日志文件的大小,大小为MB,0为关闭自动日志切割轮询,默认为1M,即日志轮询 30 | # 31 | # Mandatory: no 32 | # Range: 0-1024 33 | # Default: 34 | # LogFileSize=1 35 | 36 | ### Option: DebugLevel 37 | # Specifies debug level 38 | # 0 - no debug 39 | # 1 - critical information 40 | # 2 - error information 41 | # 3 - warnings 42 | # 4 - for debugging (produces lots of information) 43 | # 开启日志的级别,默认为3,如需开启Debugging,则设置为4,可以看到更多调试的功能 44 | # 45 | # Mandatory: no 46 | # Range: 0-4 47 | # Default: 48 | # DebugLevel=3 49 | 50 | ### Option: SourceIP 51 | # Source IP address for outgoing connections. 52 | # 设置出口的IP连接地址,这个参数适用于一个服务器有多个网卡且存在多个IP地址的情况,指定出口IP地址 53 | # 54 | # Mandatory: no 55 | # Default: 56 | # SourceIP= 57 | 58 | ### Option: EnableRemoteCommands 59 | # Whether remote commands from Zabbix server are allowed. 60 | # 0 - not allowed 61 | # 1 - allowed 62 | # 63 | # 是否开启远程命令执行功能,0为不允许,1为允许,此功能属于危险功能,需要控制好访问权限,对于Action中的远程命令执行功能 64 | # 则需要开启此参数为1 65 | # Mandatory: no 66 | # Default: 67 | # EnableRemoteCommands=0 68 | 69 | ### Option: LogRemoteCommands 70 | # Enable logging of executed shell commands as warnings. 71 | # 0 - disabled 72 | # 1 - enabled 73 | # 74 | # Mandatory: no 75 | # Default: 76 | # LogRemoteCommands=0 77 | 78 | ##### Passive checks related 79 | 80 | ### Option: Server 81 | # List of comma delimited IP addresses (or hostnames) of Zabbix servers. 82 | # Incoming connections will be accepted only from the hosts listed here. 83 | # If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally. 84 | # 85 | # Mandatory: no 86 | # Default: 87 | # Server= 88 | # Zabbix Server的IP地址,如有多个Server端需要连接此agent,可以设置多个IP,中间用逗号隔开 89 | Server=127.0.0.1 90 | 91 | ### Option: ListenPort 92 | # Agent will listen on this port for connections from the server. 93 | # 服务监听的端口,用于server向agent连接 94 | # 95 | # Mandatory: no 96 | # Range: 1024-32767 97 | # Default: 98 | # ListenPort=10050 99 | 100 | ### Option: ListenIP 101 | # List of comma delimited IP addresses that the agent should listen on. 102 | # First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks. 103 | # 104 | # 监听的IP地址,用于一台服务器上面有多个IP存在的情况,当使用主动模式的时候,为第一个IP去连接Zabbix server的IP地址 105 | # Mandatory: no 106 | # Default: 107 | # ListenIP=0.0.0.0 108 | 109 | ### Option: StartAgents 110 | # Number of pre-forked instances of zabbix_agentd that process passive checks. 111 | # If set to 0, disables passive checks and the agent will not listen on any TCP port. 112 | # 113 | # 启动的进程数量,用于被动方式,如果设置为0,将会关闭被动方式,同时,不会有端口监听 114 | # Mandatory: no 115 | # Range: 0-100 116 | # Default: 117 | # StartAgents=3 118 | 119 | ##### Active checks related 120 | 121 | ### Option: ServerActive 122 | # List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks. 123 | # If port is not specified, default port is used. 124 | # IPv6 addresses must be enclosed in square brackets if port for that host is specified. 125 | # If port is not specified, square brackets for IPv6 addresses are optional. 126 | # If this parameter is not specified, active checks are disabled. 127 | # Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1] 128 | # 129 | # 用于主动工作模式,表示Zabbix server所在服务器的IP地址,如果没有设置端口,将会使用默认的Server端口10051,支持多个IP 130 | # Mandatory: no 131 | # Default: 132 | # ServerActive= 133 | 134 | ServerActive=127.0.0.1 135 | 136 | ### Option: Hostname 137 | # Unique, case sensitive hostname. 138 | # Required for active checks and must match hostname as configured on the server. 139 | # Value is acquired from if undefined. 140 | # 141 | # hostname,必须要全局唯一,在agent处于主动模式的时候,必须和Zabbix Web UI 里面配置的hostname是一致的,同时需要 142 | # Zabbix server能够解析这个主机名,如果这里没有设置,将会使用HostnameItem这个参数的值 143 | # Mandatory: no 144 | # Default: 145 | # Hostname= 146 | 147 | Hostname=Zabbix server 148 | 149 | ### Option: HostnameItem 150 | # Item used for generating Hostname if it is undefined. Ignored if Hostname is defined. 151 | # Does not support UserParameters or aliases. 152 | # 如果上面没有定义hostname,将会使用此参数来收集主机名,不支持自定义参数和别名,后面为agent自带的内置key 153 | # 154 | # Mandatory: no 155 | # Default: 156 | # HostnameItem=system.hostname 157 | 158 | ### Option: HostMetadata 159 | # Optional parameter that defines host metadata. 160 | # Host metadata is used at host auto-registration process. 161 | # An agent will issue an error and not start if the value is over limit of 255 characters. 162 | # If not defined, value will be acquired from HostMetadataItem. 163 | # 164 | # 用户自己定义的字符串,如果没有配置,将会使用HostMetadataItem 165 | # Mandatory: no 166 | # Range: 0-255 characters 167 | # Default: 168 | # HostMetadata= 169 | 170 | ### Option: HostMetadataItem 171 | # Optional parameter that defines an item used for getting host metadata. 172 | # Host metadata is used at host auto-registration process. 173 | # During an auto-registration request an agent will log a warning message if 174 | # the value returned by specified item is over limit of 255 characters. 175 | # This option is only used when HostMetadata is not defined. 176 | # 177 | # Mandatory: no 178 | # Default: 179 | # HostMetadataItem= 180 | 181 | ### Option: RefreshActiveChecks 182 | # How often list of active checks is refreshed, in seconds. 183 | # 184 | # 用于主动工作模式,多久去Server刷新一次主动检测的列表,如果失败,会有60秒的重试时间 185 | # Mandatory: no 186 | # Range: 60-3600 187 | # Default: 188 | # RefreshActiveChecks=120 189 | 190 | ### Option: BufferSend 191 | # Do not keep data longer than N seconds in buffer. 192 | # 193 | # Mandatory: no 194 | # Range: 1-3600 195 | # Default: 196 | # BufferSend=5 197 | 198 | ### Option: BufferSize 199 | # Maximum number of values in a memory buffer. The agent will send 200 | # all collected data to Zabbix Server or Proxy if the buffer is full. 201 | # 202 | # Mandatory: no 203 | # Range: 2-65535 204 | # Default: 205 | # BufferSize=100 206 | 207 | ### Option: MaxLinesPerSecond 208 | # Maximum number of new lines the agent will send per second to Zabbix Server 209 | # or Proxy processing 'log' and 'logrt' active checks. 210 | # The provided value will be overridden by the parameter 'maxlines', 211 | # provided in 'log' or 'logrt' item keys. 212 | # 213 | # Mandatory: no 214 | # Range: 1-1000 215 | # Default: 216 | # MaxLinesPerSecond=100 217 | 218 | ############ ADVANCED PARAMETERS ################# 219 | 220 | ### Option: Alias 221 | # Sets an alias for an item key. It can be used to substitute long and complex item key with a smaller and simpler one. 222 | # Multiple Alias parameters may be present. Multiple parameters with the same Alias key are not allowed. 223 | # Different Alias keys may reference the same item key. 224 | # For example, to retrieve the ID of user 'zabbix': 225 | # Alias=zabbix.userid:vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1] 226 | # Now shorthand key zabbix.userid may be used to retrieve data. 227 | # Aliases can be used in HostMetadataItem but not in HostnameItem parameters. 228 | # 229 | # Mandatory: no 230 | # Range: 231 | # Default: 232 | 233 | ### Option: Timeout 234 | # Spend no more than Timeout seconds on processing 235 | # 236 | # Mandatory: no 237 | # Range: 1-30 238 | # Default: 239 | # Timeout=3 240 | 241 | ### Option: AllowRoot 242 | # Allow the agent to run as 'root'. If disabled and the agent is started by 'root', the agent 243 | # will try to switch to user 'zabbix' instead. Has no effect if started under a regular user. 244 | # 0 - do not allow 245 | # 1 - allow 246 | # 247 | # Mandatory: no 248 | # Default: 249 | # AllowRoot=0 250 | 251 | ### Option: Include 252 | # You may include individual files or all files in a directory in the configuration file. 253 | # Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. 254 | # 255 | # Mandatory: no 256 | # Default: 257 | # Include= 258 | 259 | # Include=/usr/local/etc/zabbix_agentd.userparams.conf 260 | # Include=/usr/local/etc/zabbix_agentd.conf.d/ 261 | 262 | ####### USER-DEFINED MONITORED PARAMETERS ####### 263 | 264 | ### Option: UnsafeUserParameters 265 | # Allow all characters to be passed in arguments to user-defined parameters. 266 | # 0 - do not allow 267 | # 1 - allow 268 | # 269 | # Mandatory: no 270 | # Range: 0-1 271 | # Default: 272 | # UnsafeUserParameters=0 273 | 274 | ### Option: UserParameter 275 | # User-defined parameter to monitor. There can be several user-defined parameters. 276 | # Format: UserParameter=, 277 | # See 'zabbix_agentd' directory for examples. 278 | # 279 | # Mandatory: no 280 | # Default: 281 | # UserParameter= 282 | 283 | ####### LOADABLE MODULES ####### 284 | 285 | ### Option: LoadModulePath 286 | # Full path to location of agent modules. 287 | # Default depends on compilation options. 288 | # 289 | # Mandatory: no 290 | # Default: 291 | # LoadModulePath=${libdir}/modules 292 | 293 | ### Option: LoadModule 294 | # Module to load at agent startup. Modules are used to extend functionality of the agent. 295 | # Format: LoadModule= 296 | # The modules must be located in directory specified by LoadModulePath. 297 | # It is allowed to include multiple LoadModule parameters. 298 | # 299 | # Mandatory: no 300 | # Default: 301 | # LoadModule= 302 | -------------------------------------------------------------------------------- /zabbix-conf/zabbix_agentd.win.conf: -------------------------------------------------------------------------------- 1 | # This is a config file for the Zabbix agent daemon (Windows) 2 | # To get more information about Zabbix, go to http://www.zabbix.com 3 | 4 | ############ GENERAL PARAMETERS ################# 5 | 6 | ### Option: LogFile 7 | # Name of log file. 8 | # If not set, Windows Event Log is used. 9 | # 10 | # Mandatory: no 11 | # Default: 12 | # LogFile= 13 | 14 | LogFile=c:\zabbix_agentd.log 15 | 16 | ### Option: LogFileSize 17 | # Maximum size of log file in MB. 18 | # 0 - disable automatic log rotation. 19 | # 20 | # Mandatory: no 21 | # Range: 0-1024 22 | # Default: 23 | # LogFileSize=1 24 | 25 | ### Option: DebugLevel 26 | # Specifies debug level 27 | # 0 - no debug 28 | # 1 - critical information 29 | # 2 - error information 30 | # 3 - warnings 31 | # 4 - for debugging (produces lots of information) 32 | # 33 | # Mandatory: no 34 | # Range: 0-4 35 | # Default: 36 | # DebugLevel=3 37 | 38 | ### Option: SourceIP 39 | # Source IP address for outgoing connections. 40 | # 41 | # Mandatory: no 42 | # Default: 43 | # SourceIP= 44 | 45 | ### Option: EnableRemoteCommands 46 | # Whether remote commands from Zabbix server are allowed. 47 | # 0 - not allowed 48 | # 1 - allowed 49 | # 50 | # Mandatory: no 51 | # Default: 52 | # EnableRemoteCommands=0 53 | 54 | ### Option: LogRemoteCommands 55 | # Enable logging of executed shell commands as warnings. 56 | # 0 - disabled 57 | # 1 - enabled 58 | # 59 | # Mandatory: no 60 | # Default: 61 | # LogRemoteCommands=0 62 | 63 | ##### Passive checks related 64 | 65 | ### Option: Server 66 | # List of comma delimited IP addresses (or hostnames) of Zabbix servers. 67 | # Incoming connections will be accepted only from the hosts listed here. 68 | # If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally. 69 | # 70 | # Mandatory: no 71 | # Default: 72 | # Server= 73 | 74 | Server=127.0.0.1 75 | 76 | ### Option: ListenPort 77 | # Agent will listen on this port for connections from the server. 78 | # 79 | # Mandatory: no 80 | # Range: 1024-32767 81 | # Default: 82 | # ListenPort=10050 83 | 84 | ### Option: ListenIP 85 | # List of comma delimited IP addresses that the agent should listen on. 86 | # First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks. 87 | # 88 | # Mandatory: no 89 | # Default: 90 | # ListenIP=0.0.0.0 91 | 92 | ### Option: StartAgents 93 | # Number of pre-forked instances of zabbix_agentd that process passive checks. 94 | # If set to 0, disables passive checks and the agent will not listen on any TCP port. 95 | # 96 | # Mandatory: no 97 | # Range: 0-100 98 | # Default: 99 | # StartAgents=3 100 | 101 | ##### Active checks related 102 | 103 | ### Option: ServerActive 104 | # List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks. 105 | # If port is not specified, default port is used. 106 | # IPv6 addresses must be enclosed in square brackets if port for that host is specified. 107 | # If port is not specified, square brackets for IPv6 addresses are optional. 108 | # If this parameter is not specified, active checks are disabled. 109 | # Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1] 110 | # 111 | # Mandatory: no 112 | # Default: 113 | # ServerActive= 114 | 115 | ServerActive=127.0.0.1 116 | 117 | ### Option: Hostname 118 | # Unique, case sensitive hostname. 119 | # Required for active checks and must match hostname as configured on the server. 120 | # Value is acquired from HostnameItem if undefined. 121 | # 122 | # Mandatory: no 123 | # Default: 124 | # Hostname= 125 | 126 | Hostname=Windows host 127 | 128 | ### Option: HostnameItem 129 | # Item used for generating Hostname if it is undefined. Ignored if Hostname is defined. 130 | # Does not support UserParameters or aliases. 131 | # 132 | # Mandatory: no 133 | # Default: 134 | # HostnameItem=system.hostname 135 | 136 | ### Option: HostMetadata 137 | # Optional parameter that defines host metadata. 138 | # Host metadata is used at host auto-registration process. 139 | # An agent will issue an error and not start if the value is over limit of 255 characters. 140 | # If not defined, value will be acquired from HostMetadataItem. 141 | # 142 | # Mandatory: no 143 | # Range: 0-255 characters 144 | # Default: 145 | # HostMetadata= 146 | 147 | ### Option: HostMetadataItem 148 | # Optional parameter that defines an item used for getting host metadata. 149 | # Host metadata is used at host auto-registration process. 150 | # During an auto-registration request an agent will log a warning message if 151 | # the value returned by specified item is over limit of 255 characters. 152 | # This option is only used when HostMetadata is not defined. 153 | # 154 | # Mandatory: no 155 | # Default: 156 | # HostMetadataItem= 157 | 158 | ### Option: RefreshActiveChecks 159 | # How often list of active checks is refreshed, in seconds. 160 | # 161 | # Mandatory: no 162 | # Range: 60-3600 163 | # Default: 164 | # RefreshActiveChecks=120 165 | 166 | ### Option: BufferSend 167 | # Do not keep data longer than N seconds in buffer. 168 | # 169 | # Mandatory: no 170 | # Range: 1-3600 171 | # Default: 172 | # BufferSend=5 173 | 174 | ### Option: BufferSize 175 | # Maximum number of values in a memory buffer. The agent will send 176 | # all collected data to Zabbix server or Proxy if the buffer is full. 177 | # 178 | # Mandatory: no 179 | # Range: 2-65535 180 | # Default: 181 | # BufferSize=100 182 | 183 | ### Option: MaxLinesPerSecond 184 | # Maximum number of new lines the agent will send per second to Zabbix Server 185 | # or Proxy processing 'log', 'logrt' and 'eventlog' active checks. 186 | # The provided value will be overridden by the parameter 'maxlines', 187 | # provided in 'log', 'logrt' or 'eventlog' item keys. 188 | # 189 | # Mandatory: no 190 | # Range: 1-1000 191 | # Default: 192 | # MaxLinesPerSecond=100 193 | 194 | ############ ADVANCED PARAMETERS ################# 195 | 196 | ### Option: Alias 197 | # Sets an alias for an item key. It can be used to substitute long and complex item key with a smaller and simpler one. 198 | # Multiple Alias parameters may be present. Multiple parameters with the same Alias key are not allowed. 199 | # Different Alias keys may reference the same item key. 200 | # For example, to retrieve paging file usage in percents from the server: 201 | # Alias=pg_usage:perf_counter[\Paging File(_Total)\% Usage] 202 | # Now shorthand key pg_usage may be used to retrieve data. 203 | # Aliases can be used in HostMetadataItem but not in HostnameItem or PerfCounter parameters. 204 | # 205 | # Mandatory: no 206 | # Range: 207 | # Default: 208 | 209 | ### Option: Timeout 210 | # Spend no more than Timeout seconds on processing 211 | # 212 | # Mandatory: no 213 | # Range: 1-30 214 | # Default: 215 | # Timeout=3 216 | 217 | ### Option: PerfCounter 218 | # Syntax: ,"", 219 | # Defines new parameter which is an average value for system performance counter for the specified time period (in seconds). 220 | # For example, if you wish to receive average number of processor interrupts per second for last minute, you can define new parameter "interrupts" as following: 221 | # PerfCounter = interrupts,"\Processor(0)\Interrupts/sec",60 222 | # Please note double quotes around performance counter path. 223 | # Samples for calculating average value will be taken every second. 224 | # You may run "typeperf -qx" to get list of all performance counters available in Windows. 225 | # 226 | # Mandatory: no 227 | # Range: 228 | # Default: 229 | 230 | ### Option: Include 231 | # You may include individual files in the configuration file. 232 | # 233 | # Mandatory: no 234 | # Default: 235 | # Include= 236 | 237 | # Include=c:\zabbix\zabbix_agentd.userparams.conf 238 | 239 | ####### USER-DEFINED MONITORED PARAMETERS ####### 240 | 241 | ### Option: UnsafeUserParameters 242 | # Allow all characters to be passed in arguments to user-defined parameters. 243 | # 0 - do not allow 244 | # 1 - allow 245 | # 246 | # Mandatory: no 247 | # Range: 0-1 248 | # Default: 249 | # UnsafeUserParameters=0 250 | 251 | ### Option: UserParameter 252 | # User-defined parameter to monitor. There can be several user-defined parameters. 253 | # Format: UserParameter=, 254 | # 255 | # Mandatory: no 256 | # Default: 257 | # UserParameter= 258 | -------------------------------------------------------------------------------- /zabbix-conf/zabbix_proxy.conf: -------------------------------------------------------------------------------- 1 | # This is a configuration file for Zabbix Proxy process 2 | # To get more information about Zabbix, 3 | # visit http://www.zabbix.com 4 | 5 | ############ GENERAL PARAMETERS ################# 6 | 7 | ### Option: ProxyMode 8 | # Proxy operating mode 9 | # 0 - proxy in the active mode 10 | # 1 - proxy in the passive mode 11 | # 12 | # Mandatory: no 13 | # Default: 14 | # ProxyMode=0 15 | 16 | ### Option: Server 17 | # IP address (or hostname) of Zabbix server. 18 | # Active proxy will get configuration data from the server. 19 | # For a proxy in the passive mode this parameter will be ignored. 20 | # 21 | # Mandatory: yes (if ProxyMode is set to 0) 22 | # Default: 23 | # Server= 24 | 25 | Server=127.0.0.1 26 | 27 | ### Option: ServerPort 28 | # Port of Zabbix trapper on Zabbix server. 29 | # For a proxy in the passive mode this parameter will be ignored. 30 | # 31 | # Mandatory: no 32 | # Range: 1024-32767 33 | # Default: 34 | # ServerPort=10051 35 | 36 | ### Option: Hostname 37 | # Unique, case sensitive Proxy name. Make sure the Proxy name is known to the server! 38 | # Value is acquired from HostnameItem if undefined. 39 | # 40 | # Mandatory: no 41 | # Default: 42 | # Hostname= 43 | 44 | Hostname=Zabbix proxy 45 | 46 | ### Option: HostnameItem 47 | # Item used for generating Hostname if it is undefined. 48 | # Ignored if Hostname is defined. 49 | # 50 | # Mandatory: no 51 | # Default: 52 | # HostnameItem=system.hostname 53 | 54 | ### Option: ListenPort 55 | # Listen port for trapper. 56 | # 57 | # Mandatory: no 58 | # Range: 1024-32767 59 | # Default: 60 | # ListenPort=10051 61 | 62 | ### Option: SourceIP 63 | # Source IP address for outgoing connections. 64 | # 65 | # Mandatory: no 66 | # Default: 67 | # SourceIP= 68 | 69 | ### Option: LogFile 70 | # Name of log file. 71 | # If not set, syslog is used. 72 | # 73 | # Mandatory: no 74 | # Default: 75 | # LogFile= 76 | 77 | LogFile=/tmp/zabbix_proxy.log 78 | 79 | ### Option: LogFileSize 80 | # Maximum size of log file in MB. 81 | # 0 - disable automatic log rotation. 82 | # 83 | # Mandatory: no 84 | # Range: 0-1024 85 | # Default: 86 | # LogFileSize=1 87 | 88 | ### Option: DebugLevel 89 | # Specifies debug level 90 | # 0 - no debug 91 | # 1 - critical information 92 | # 2 - error information 93 | # 3 - warnings 94 | # 4 - for debugging (produces lots of information) 95 | # 96 | # Mandatory: no 97 | # Range: 0-4 98 | # Default: 99 | # DebugLevel=3 100 | 101 | ### Option: PidFile 102 | # Name of PID file. 103 | # 104 | # Mandatory: no 105 | # Default: 106 | # PidFile=/tmp/zabbix_proxy.pid 107 | 108 | ### Option: DBHost 109 | # Database host name. 110 | # If set to localhost, socket is used for MySQL. 111 | # If set to empty string, socket is used for PostgreSQL. 112 | # 113 | # Mandatory: no 114 | # Default: 115 | # DBHost=localhost 116 | 117 | ### Option: DBName 118 | # Database name. 119 | # For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored. 120 | # Warning: do not attempt to use the same database Zabbix server is using. 121 | # 122 | # Mandatory: yes 123 | # Default: 124 | # DBName= 125 | 126 | DBName=zabbix_proxy 127 | 128 | ### Option: DBSchema 129 | # Schema name. Used for IBM DB2. 130 | # 131 | # Mandatory: no 132 | # Default: 133 | # DBSchema= 134 | 135 | ### Option: DBUser 136 | # Database user. Ignored for SQLite. 137 | # 138 | # Default: 139 | # DBUser= 140 | 141 | DBUser=root 142 | 143 | ### Option: DBPassword 144 | # Database password. Ignored for SQLite. 145 | # Comment this line if no password is used. 146 | # 147 | # Mandatory: no 148 | # Default: 149 | # DBPassword= 150 | 151 | ### Option: DBSocket 152 | # Path to MySQL socket. 153 | # 154 | # Mandatory: no 155 | # Default: 156 | # DBSocket=/tmp/mysql.sock 157 | 158 | # Option: DBPort 159 | # Database port when not using local socket. Ignored for SQLite. 160 | # 161 | # Mandatory: no 162 | # Default (for MySQL): 163 | # DBPort=3306 164 | 165 | ######### PROXY SPECIFIC PARAMETERS ############# 166 | 167 | ### Option: ProxyLocalBuffer 168 | # Proxy will keep data locally for N hours, even if the data have already been synced with the server. 169 | # This parameter may be used if local data will be used by third party applications. 170 | # 171 | # Mandatory: no 172 | # Range: 0-720 173 | # Default: 174 | # ProxyLocalBuffer=0 175 | 176 | ### Option: ProxyOfflineBuffer 177 | # Proxy will keep data for N hours in case if no connectivity with Zabbix Server. 178 | # Older data will be lost. 179 | # 180 | # Mandatory: no 181 | # Range: 1-720 182 | # Default: 183 | # ProxyOfflineBuffer=1 184 | 185 | ### Option: HeartbeatFrequency 186 | # Frequency of heartbeat messages in seconds. 187 | # Used for monitoring availability of Proxy on server side. 188 | # 0 - heartbeat messages disabled. 189 | # For a proxy in the passive mode this parameter will be ignored. 190 | # 191 | # Mandatory: no 192 | # Range: 0-3600 193 | # Default: 194 | # HeartbeatFrequency=60 195 | 196 | ### Option: ConfigFrequency 197 | # How often proxy retrieves configuration data from Zabbix Server in seconds. 198 | # For a proxy in the passive mode this parameter will be ignored. 199 | # 200 | # Mandatory: no 201 | # Range: 1-3600*24*7 202 | # Default: 203 | # ConfigFrequency=3600 204 | 205 | ### Option: DataSenderFrequency 206 | # Proxy will send collected data to the Server every N seconds. 207 | # For a proxy in the passive mode this parameter will be ignored. 208 | # 209 | # Mandatory: no 210 | # Range: 1-3600 211 | # Default: 212 | # DataSenderFrequency=1 213 | 214 | ############ ADVANCED PARAMETERS ################ 215 | 216 | ### Option: StartPollers 217 | # Number of pre-forked instances of pollers. 218 | # 219 | # Mandatory: no 220 | # Range: 0-1000 221 | # Default: 222 | # StartPollers=5 223 | 224 | ### Option: StartIPMIPollers 225 | # Number of pre-forked instances of IPMI pollers. 226 | # 227 | # Mandatory: no 228 | # Range: 0-1000 229 | # Default: 230 | # StartIPMIPollers=0 231 | 232 | ### Option: StartPollersUnreachable 233 | # Number of pre-forked instances of pollers for unreachable hosts (including IPMI). 234 | # 235 | # Mandatory: no 236 | # Range: 0-1000 237 | # Default: 238 | # StartPollersUnreachable=1 239 | 240 | ### Option: StartTrappers 241 | # Number of pre-forked instances of trappers. 242 | # Trappers accept incoming connections from Zabbix sender and active agents. 243 | # 244 | # Mandatory: no 245 | # Range: 0-1000 246 | # Default: 247 | # StartTrappers=5 248 | 249 | ### Option: StartPingers 250 | # Number of pre-forked instances of ICMP pingers. 251 | # 252 | # Mandatory: no 253 | # Range: 0-1000 254 | # Default: 255 | # StartPingers=1 256 | 257 | ### Option: StartDiscoverers 258 | # Number of pre-forked instances of discoverers. 259 | # 260 | # Mandatory: no 261 | # Range: 0-250 262 | # Default: 263 | # StartDiscoverers=1 264 | 265 | ### Option: StartHTTPPollers 266 | # Number of pre-forked instances of HTTP pollers. 267 | # 268 | # Mandatory: no 269 | # Range: 0-1000 270 | # Default: 271 | # StartHTTPPollers=1 272 | 273 | ### Option: JavaGateway 274 | # IP address (or hostname) of Zabbix Java gateway. 275 | # Only required if Java pollers are started. 276 | # 277 | # Mandatory: no 278 | # Default: 279 | # JavaGateway= 280 | 281 | ### Option: JavaGatewayPort 282 | # Port that Zabbix Java gateway listens on. 283 | # 284 | # Mandatory: no 285 | # Range: 1024-32767 286 | # Default: 287 | # JavaGatewayPort=10052 288 | 289 | ### Option: StartJavaPollers 290 | # Number of pre-forked instances of Java pollers. 291 | # 292 | # Mandatory: no 293 | # Range: 0-1000 294 | # Default: 295 | # StartJavaPollers=0 296 | 297 | ### Option: StartVMwareCollectors 298 | # Number of pre-forked vmware collector instances. 299 | # 300 | # Mandatory: no 301 | # Range: 0-250 302 | # Default: 303 | # StartVMwareCollectors=0 304 | 305 | ### Option: VMwareFrequency 306 | # How often Zabbix will connect to VMware service to obtain a new data. 307 | # 308 | # Mandatory: no 309 | # Range: 10-86400 310 | # Default: 311 | # VMwareFrequency=60 312 | 313 | ### Option: VMwareCacheSize 314 | # Size of VMware cache, in bytes. 315 | # Shared memory size for storing VMware data. 316 | # Only used if VMware collectors are started. 317 | # 318 | # Mandatory: no 319 | # Range: 256K-2G 320 | # Default: 321 | # VMwareCacheSize=8M 322 | 323 | ### Option: SNMPTrapperFile 324 | # Temporary file used for passing data from SNMP trap daemon to the proxy. 325 | # Must be the same as in zabbix_trap_receiver.pl or SNMPTT configuration file. 326 | # 327 | # Mandatory: no 328 | # Default: 329 | # SNMPTrapperFile=/tmp/zabbix_traps.tmp 330 | 331 | ### Option: StartSNMPTrapper 332 | # If 1, SNMP trapper process is started. 333 | # 334 | # Mandatory: no 335 | # Range: 0-1 336 | # Default: 337 | # StartSNMPTrapper=0 338 | 339 | ### Option: ListenIP 340 | # List of comma delimited IP addresses that the trapper should listen on. 341 | # Trapper will listen on all network interfaces if this parameter is missing. 342 | # 343 | # Mandatory: no 344 | # Default: 345 | # ListenIP=0.0.0.0 346 | 347 | ### Option: HousekeepingFrequency 348 | # How often Zabbix will perform housekeeping procedure (in hours). 349 | # Housekeeping is removing unnecessary information from history, alert, and alarms tables. 350 | # 351 | # Mandatory: no 352 | # Range: 1-24 353 | # Default: 354 | # HousekeepingFrequency=1 355 | 356 | ### Option: CacheSize 357 | # Size of configuration cache, in bytes. 358 | # Shared memory size, for storing hosts and items data. 359 | # 360 | # Mandatory: no 361 | # Range: 128K-8G 362 | # Default: 363 | # CacheSize=8M 364 | 365 | ### Option: StartDBSyncers 366 | # Number of pre-forked instances of DB Syncers 367 | # 368 | # Mandatory: no 369 | # Range: 1-100 370 | # Default: 371 | # StartDBSyncers=4 372 | 373 | ### Option: HistoryCacheSize 374 | # Size of history cache, in bytes. 375 | # Shared memory size for storing history data. 376 | # 377 | # Mandatory: no 378 | # Range: 128K-2G 379 | # Default: 380 | # HistoryCacheSize=8M 381 | 382 | ### Option: HistoryTextCacheSize 383 | # Size of text history cache, in bytes. 384 | # Shared memory size for storing character, text or log history data. 385 | # 386 | # Mandatory: no 387 | # Range: 128K-2G 388 | # Default: 389 | # HistoryTextCacheSize=16M 390 | 391 | ### Option: Timeout 392 | # Specifies how long we wait for agent, SNMP device or external check (in seconds). 393 | # 394 | # Mandatory: no 395 | # Range: 1-30 396 | # Default: 397 | # Timeout=3 398 | 399 | ### Option: TrapperTimeout 400 | # Specifies how many seconds trapper may spend processing new data. 401 | # 402 | # Mandatory: no 403 | # Range: 1-300 404 | # Default: 405 | # TrapperTimeout=300 406 | 407 | ### Option: UnreachablePeriod 408 | # After how many seconds of unreachability treat a host as unavailable. 409 | # 410 | # Mandatory: no 411 | # Range: 1-3600 412 | # Default: 413 | # UnreachablePeriod=45 414 | 415 | ### Option: UnavailableDelay 416 | # How often host is checked for availability during the unavailability period, in seconds. 417 | # 418 | # Mandatory: no 419 | # Range: 1-3600 420 | # Default: 421 | # UnavailableDelay=60 422 | 423 | ### Option: UnreachableDelay 424 | # How often host is checked for availability during the unreachability period, in seconds. 425 | # 426 | # Mandatory: no 427 | # Range: 1-3600 428 | # Default: 429 | # UnreachableDelay=15 430 | 431 | ### Option: ExternalScripts 432 | # Full path to location of external scripts. 433 | # Default depends on compilation options. 434 | # 435 | # Mandatory: no 436 | # Default: 437 | # ExternalScripts=${datadir}/zabbix/externalscripts 438 | 439 | ### Option: FpingLocation 440 | # Location of fping. 441 | # Make sure that fping binary has root ownership and SUID flag set. 442 | # 443 | # Mandatory: no 444 | # Default: 445 | # FpingLocation=/usr/sbin/fping 446 | 447 | ### Option: Fping6Location 448 | # Location of fping6. 449 | # Make sure that fping6 binary has root ownership and SUID flag set. 450 | # Make empty if your fping utility is capable to process IPv6 addresses. 451 | # 452 | # Mandatory: no 453 | # Default: 454 | # Fping6Location=/usr/sbin/fping6 455 | 456 | ### Option: SSHKeyLocation 457 | # Location of public and private keys for SSH checks and actions. 458 | # 459 | # Mandatory: no 460 | # Default: 461 | # SSHKeyLocation= 462 | 463 | ### Option: LogSlowQueries 464 | # How long a database query may take before being logged (in milliseconds). 465 | # Only works if DebugLevel set to 3 or 4. 466 | # 0 - don't log slow queries. 467 | # 468 | # Mandatory: no 469 | # Range: 1-3600000 470 | # Default: 471 | # LogSlowQueries=0 472 | 473 | ### Option: TmpDir 474 | # Temporary directory. 475 | # 476 | # Mandatory: no 477 | # Default: 478 | # TmpDir=/tmp 479 | 480 | ### Option: AllowRoot 481 | # Allow the proxy to run as 'root'. If disabled and the proxy is started by 'root', the proxy 482 | # will try to switch to user 'zabbix' instead. Has no effect if started under a regular user. 483 | # 0 - do not allow 484 | # 1 - allow 485 | # 486 | # Mandatory: no 487 | # Default: 488 | # AllowRoot=0 489 | 490 | ### Option: Include 491 | # You may include individual files or all files in a directory in the configuration file. 492 | # Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. 493 | # 494 | # Mandatory: no 495 | # Default: 496 | # Include= 497 | 498 | # Include=/usr/local/etc/zabbix_proxy.general.conf 499 | # Include=/usr/local/etc/zabbix_proxy.conf.d/ 500 | 501 | ####### LOADABLE MODULES ####### 502 | 503 | ### Option: LoadModulePath 504 | # Full path to location of proxy modules. 505 | # Default depends on compilation options. 506 | # 507 | # Mandatory: no 508 | # Default: 509 | # LoadModulePath=${libdir}/modules 510 | 511 | ### Option: LoadModule 512 | # Module to load at proxy startup. Modules are used to extend functionality of the proxy. 513 | # Format: LoadModule= 514 | # The modules must be located in directory specified by LoadModulePath. 515 | # It is allowed to include multiple LoadModule parameters. 516 | # 517 | # Mandatory: no 518 | # Default: 519 | # LoadModule= 520 | -------------------------------------------------------------------------------- /zabbix-conf/zabbix_server.conf: -------------------------------------------------------------------------------- 1 | # This is a configuration file for Zabbix Server process 2 | # To get more information about Zabbix, 3 | # visit http://www.zabbix.com 4 | 5 | ############ GENERAL PARAMETERS ################# 6 | 7 | ### Option: NodeID 8 | # Unique NodeID in distributed setup. 9 | # 0 - standalone server 10 | # 11 | # Mandatory: no 12 | # Range: 0-999 13 | # Default: 14 | # NodeID=0 15 | 16 | ### Option: ListenPort 17 | # Listen port for trapper. 18 | # 19 | # Mandatory: no 20 | # Range: 1024-32767 21 | # Default: 22 | # ListenPort=10051 23 | 24 | ### Option: SourceIP 25 | # Source IP address for outgoing connections. 26 | # 27 | # Mandatory: no 28 | # Default: 29 | # SourceIP= 30 | 31 | ### Option: LogFile 32 | # Name of log file. 33 | # If not set, syslog is used. 34 | # 35 | # Mandatory: no 36 | # Default: 37 | # LogFile= 38 | 39 | LogFile=/tmp/zabbix_server.log 40 | 41 | ### Option: LogFileSize 42 | # Maximum size of log file in MB. 43 | # 0 - disable automatic log rotation. 44 | # 45 | # Mandatory: no 46 | # Range: 0-1024 47 | # Default: 48 | # LogFileSize=1 49 | 50 | ### Option: DebugLevel 51 | # Specifies debug level 52 | # 0 - no debug 53 | # 1 - critical information 54 | # 2 - error information 55 | # 3 - warnings 56 | # 4 - for debugging (produces lots of information) 57 | # 58 | # Mandatory: no 59 | # Range: 0-4 60 | # Default: 61 | # DebugLevel=3 62 | 63 | ### Option: PidFile 64 | # Name of PID file. 65 | # 66 | # Mandatory: no 67 | # Default: 68 | # PidFile=/tmp/zabbix_server.pid 69 | 70 | ### Option: DBHost 71 | # Database host name. 72 | # If set to localhost, socket is used for MySQL. 73 | # If set to empty string, socket is used for PostgreSQL. 74 | # 75 | # Mandatory: no 76 | # Default: 77 | # DBHost=localhost 78 | 79 | ### Option: DBName 80 | # Database name. 81 | # For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored. 82 | # 83 | # Mandatory: yes 84 | # Default: 85 | # DBName= 86 | 87 | DBName=zabbix 88 | 89 | ### Option: DBSchema 90 | # Schema name. Used for IBM DB2. 91 | # 92 | # Mandatory: no 93 | # Default: 94 | # DBSchema= 95 | 96 | ### Option: DBUser 97 | # Database user. Ignored for SQLite. 98 | # 99 | # Mandatory: no 100 | # Default: 101 | # DBUser= 102 | 103 | DBUser=root 104 | 105 | ### Option: DBPassword 106 | # Database password. Ignored for SQLite. 107 | # Comment this line if no password is used. 108 | # 109 | # Mandatory: no 110 | # Default: 111 | # DBPassword= 112 | 113 | ### Option: DBSocket 114 | # Path to MySQL socket. 115 | # 116 | # Mandatory: no 117 | # Default: 118 | # DBSocket=/tmp/mysql.sock 119 | 120 | ### Option: DBPort 121 | # Database port when not using local socket. Ignored for SQLite. 122 | # 123 | # Mandatory: no 124 | # Range: 1024-65535 125 | # Default (for MySQL): 126 | # DBPort=3306 127 | 128 | ############ ADVANCED PARAMETERS ################ 129 | 130 | ### Option: StartPollers 131 | # Number of pre-forked instances of pollers. 132 | # 133 | # Mandatory: no 134 | # Range: 0-1000 135 | # Default: 136 | # StartPollers=5 137 | 138 | ### Option: StartIPMIPollers 139 | # Number of pre-forked instances of IPMI pollers. 140 | # 141 | # Mandatory: no 142 | # Range: 0-1000 143 | # Default: 144 | # StartIPMIPollers=0 145 | 146 | ### Option: StartPollersUnreachable 147 | # Number of pre-forked instances of pollers for unreachable hosts (including IPMI). 148 | # 149 | # Mandatory: no 150 | # Range: 0-1000 151 | # Default: 152 | # StartPollersUnreachable=1 153 | 154 | ### Option: StartTrappers 155 | # Number of pre-forked instances of trappers. 156 | # Trappers accept incoming connections from Zabbix sender, active agents, active proxies and child nodes. 157 | # At least one trapper process must be running to display server availability and view queue 158 | # in the frontend. 159 | # 160 | # Mandatory: no 161 | # Range: 0-1000 162 | # Default: 163 | # StartTrappers=5 164 | 165 | ### Option: StartPingers 166 | # Number of pre-forked instances of ICMP pingers. 167 | # 168 | # Mandatory: no 169 | # Range: 0-1000 170 | # Default: 171 | # StartPingers=1 172 | 173 | ### Option: StartDiscoverers 174 | # Number of pre-forked instances of discoverers. 175 | # 176 | # Mandatory: no 177 | # Range: 0-250 178 | # Default: 179 | # StartDiscoverers=1 180 | 181 | ### Option: StartHTTPPollers 182 | # Number of pre-forked instances of HTTP pollers. 183 | # 184 | # Mandatory: no 185 | # Range: 0-1000 186 | # Default: 187 | # StartHTTPPollers=1 188 | 189 | ### Option: StartTimers 190 | # Number of pre-forked instances of timers. 191 | # Timers process time-based trigger functions and maintenance periods. 192 | # Only the first timer process handles the maintenance periods. 193 | # 194 | # Mandatory: no 195 | # Range: 1-1000 196 | # Default: 197 | # StartTimers=1 198 | 199 | ### Option: JavaGateway 200 | # IP address (or hostname) of Zabbix Java gateway. 201 | # Only required if Java pollers are started. 202 | # 203 | # Mandatory: no 204 | # Default: 205 | # JavaGateway= 206 | 207 | ### Option: JavaGatewayPort 208 | # Port that Zabbix Java gateway listens on. 209 | # 210 | # Mandatory: no 211 | # Range: 1024-32767 212 | # Default: 213 | # JavaGatewayPort=10052 214 | 215 | ### Option: StartJavaPollers 216 | # Number of pre-forked instances of Java pollers. 217 | # 218 | # Mandatory: no 219 | # Range: 0-1000 220 | # Default: 221 | # StartJavaPollers=0 222 | 223 | ### Option: StartVMwareCollectors 224 | # Number of pre-forked vmware collector instances. 225 | # 226 | # Mandatory: no 227 | # Range: 0-250 228 | # Default: 229 | # StartVMwareCollectors=0 230 | 231 | ### Option: VMwareFrequency 232 | # How often Zabbix will connect to VMware service to obtain a new data. 233 | # 234 | # Mandatory: no 235 | # Range: 10-86400 236 | # Default: 237 | # VMwareFrequency=60 238 | 239 | ### Option: VMwareCacheSize 240 | # Size of VMware cache, in bytes. 241 | # Shared memory size for storing VMware data. 242 | # Only used if VMware collectors are started. 243 | # 244 | # Mandatory: no 245 | # Range: 256K-2G 246 | # Default: 247 | # VMwareCacheSize=8M 248 | 249 | ### Option: SNMPTrapperFile 250 | # Temporary file used for passing data from SNMP trap daemon to the server. 251 | # Must be the same as in zabbix_trap_receiver.pl or SNMPTT configuration file. 252 | # 253 | # Mandatory: no 254 | # Default: 255 | # SNMPTrapperFile=/tmp/zabbix_traps.tmp 256 | 257 | ### Option: StartSNMPTrapper 258 | # If 1, SNMP trapper process is started. 259 | # 260 | # Mandatory: no 261 | # Range: 0-1 262 | # Default: 263 | # StartSNMPTrapper=0 264 | 265 | ### Option: ListenIP 266 | # List of comma delimited IP addresses that the trapper should listen on. 267 | # Trapper will listen on all network interfaces if this parameter is missing. 268 | # 269 | # Mandatory: no 270 | # Default: 271 | # ListenIP=0.0.0.0 272 | 273 | # ListenIP=127.0.0.1 274 | 275 | ### Option: HousekeepingFrequency 276 | # How often Zabbix will perform housekeeping procedure (in hours). 277 | # Housekeeping is removing unnecessary information from history, alert, and alarms tables. 278 | # To prevent Housekeeper from being overloaded (for example, when history and trend periods 279 | # are greatly reduced), no more than 4xHousekeepingFrequency hours of outdated history are 280 | # deleted in one housekeeping cycle, for each item. 281 | # 282 | # Mandatory: no 283 | # Range: 1-24 284 | # Default: 285 | # HousekeepingFrequency=1 286 | 287 | ### Option: MaxHousekeeperDelete 288 | # The table "housekeeper" contains "tasks" for housekeeping procedure in the format: 289 | # [housekeeperid], [tablename], [field], [value]. 290 | # No more than 'MaxHousekeeperDelete' rows (corresponding to [tablename], [field], [value]) 291 | # will be deleted per one task in one housekeeping cycle. 292 | # SQLite3 does not use this parameter, deletes all corresponding rows without a limit. 293 | # If set to 0 then no limit is used at all. In this case you must know what you are doing! 294 | # 295 | # Mandatory: no 296 | # Range: 0-1000000 297 | # Default: 298 | # MaxHousekeeperDelete=500 299 | 300 | ### Option: SenderFrequency 301 | # How often Zabbix will try to send unsent alerts (in seconds). 302 | # 303 | # Mandatory: no 304 | # Range: 5-3600 305 | # Default: 306 | # SenderFrequency=30 307 | 308 | ### Option: CacheSize 309 | # Size of configuration cache, in bytes. 310 | # Shared memory size for storing host, item and trigger data. 311 | # 312 | # Mandatory: no 313 | # Range: 128K-8G 314 | # Default: 315 | # CacheSize=8M 316 | 317 | ### Option: CacheUpdateFrequency 318 | # How often Zabbix will perform update of configuration cache, in seconds. 319 | # 320 | # Mandatory: no 321 | # Range: 1-3600 322 | # Default: 323 | # CacheUpdateFrequency=60 324 | 325 | ### Option: StartDBSyncers 326 | # Number of pre-forked instances of DB Syncers 327 | # 328 | # Mandatory: no 329 | # Range: 1-100 330 | # Default: 331 | # StartDBSyncers=4 332 | 333 | ### Option: HistoryCacheSize 334 | # Size of history cache, in bytes. 335 | # Shared memory size for storing history data. 336 | # 337 | # Mandatory: no 338 | # Range: 128K-2G 339 | # Default: 340 | # HistoryCacheSize=8M 341 | 342 | ### Option: TrendCacheSize 343 | # Size of trend cache, in bytes. 344 | # Shared memory size for storing trends data. 345 | # 346 | # Mandatory: no 347 | # Range: 128K-2G 348 | # Default: 349 | # TrendCacheSize=4M 350 | 351 | ### Option: HistoryTextCacheSize 352 | # Size of text history cache, in bytes. 353 | # Shared memory size for storing character, text or log history data. 354 | # 355 | # Mandatory: no 356 | # Range: 128K-2G 357 | # Default: 358 | # HistoryTextCacheSize=16M 359 | 360 | ### Option: ValueCacheSize 361 | # Size of history value cache, in bytes. 362 | # Shared memory size for caching item history data requests 363 | # Setting to 0 disables value cache. 364 | # 365 | # Mandatory: no 366 | # Range: 0,128K-64G 367 | # Default: 368 | # ValueCacheSize=8M 369 | 370 | ### Option: NodeNoEvents 371 | # If set to '1' local events won't be sent to master node. 372 | # This won't impact ability of this node to propagate events from its child nodes. 373 | # 374 | # Mandatory: no 375 | # Range: 0-1 376 | # Default: 377 | # NodeNoEvents=0 378 | 379 | ### Option: NodeNoHistory 380 | # If set to '1' local history won't be sent to master node. 381 | # This won't impact ability of this node to propagate history from its child nodes. 382 | # 383 | # Mandatory: no 384 | # Range: 0-1 385 | # Default: 386 | # NodeNoHistory=0 387 | 388 | ### Option: Timeout 389 | # Specifies how long we wait for agent, SNMP device or external check (in seconds). 390 | # 391 | # Mandatory: no 392 | # Range: 1-30 393 | # Default: 394 | # Timeout=3 395 | 396 | ### Option: TrapperTimeout 397 | # Specifies how many seconds trapper may spend processing new data. 398 | # 399 | # Mandatory: no 400 | # Range: 1-300 401 | # Default: 402 | # TrapperTimeout=300 403 | 404 | ### Option: UnreachablePeriod 405 | # After how many seconds of unreachability treat a host as unavailable. 406 | # 407 | # Mandatory: no 408 | # Range: 1-3600 409 | # Default: 410 | # UnreachablePeriod=45 411 | 412 | ### Option: UnavailableDelay 413 | # How often host is checked for availability during the unavailability period, in seconds. 414 | # 415 | # Mandatory: no 416 | # Range: 1-3600 417 | # Default: 418 | # UnavailableDelay=60 419 | 420 | ### Option: UnreachableDelay 421 | # How often host is checked for availability during the unreachability period, in seconds. 422 | # 423 | # Mandatory: no 424 | # Range: 1-3600 425 | # Default: 426 | # UnreachableDelay=15 427 | 428 | ### Option: AlertScriptsPath 429 | # Full path to location of custom alert scripts. 430 | # Default depends on compilation options. 431 | # 432 | # Mandatory: no 433 | # Default: 434 | # AlertScriptsPath=${datadir}/zabbix/alertscripts 435 | 436 | ### Option: ExternalScripts 437 | # Full path to location of external scripts. 438 | # Default depends on compilation options. 439 | # 440 | # Mandatory: no 441 | # Default: 442 | # ExternalScripts=${datadir}/zabbix/externalscripts 443 | 444 | ### Option: FpingLocation 445 | # Location of fping. 446 | # Make sure that fping binary has root ownership and SUID flag set. 447 | # 448 | # Mandatory: no 449 | # Default: 450 | # FpingLocation=/usr/sbin/fping 451 | 452 | ### Option: Fping6Location 453 | # Location of fping6. 454 | # Make sure that fping6 binary has root ownership and SUID flag set. 455 | # Make empty if your fping utility is capable to process IPv6 addresses. 456 | # 457 | # Mandatory: no 458 | # Default: 459 | # Fping6Location=/usr/sbin/fping6 460 | 461 | ### Option: SSHKeyLocation 462 | # Location of public and private keys for SSH checks and actions. 463 | # 464 | # Mandatory: no 465 | # Default: 466 | # SSHKeyLocation= 467 | 468 | ### Option: LogSlowQueries 469 | # How long a database query may take before being logged (in milliseconds). 470 | # Only works if DebugLevel set to 3 or 4. 471 | # 0 - don't log slow queries. 472 | # 473 | # Mandatory: no 474 | # Range: 1-3600000 475 | # Default: 476 | # LogSlowQueries=0 477 | 478 | ### Option: TmpDir 479 | # Temporary directory. 480 | # 481 | # Mandatory: no 482 | # Default: 483 | # TmpDir=/tmp 484 | 485 | ### Option: StartProxyPollers 486 | # Number of pre-forked instances of pollers for passive proxies. 487 | # 488 | # Mandatory: no 489 | # Range: 0-250 490 | # Default: 491 | # StartProxyPollers=1 492 | 493 | ### Option: ProxyConfigFrequency 494 | # How often Zabbix Server sends configuration data to a Zabbix Proxy in seconds. 495 | # This parameter is used only for proxies in the passive mode. 496 | # 497 | # Mandatory: no 498 | # Range: 1-3600*24*7 499 | # Default: 500 | # ProxyConfigFrequency=3600 501 | 502 | ### Option: ProxyDataFrequency 503 | # How often Zabbix Server requests history data from a Zabbix Proxy in seconds. 504 | # This parameter is used only for proxies in the passive mode. 505 | # 506 | # Mandatory: no 507 | # Range: 1-3600 508 | # Default: 509 | # ProxyDataFrequency=1 510 | 511 | ### Option: AllowRoot 512 | # Allow the server to run as 'root'. If disabled and the server is started by 'root', the server 513 | # will try to switch to user 'zabbix' instead. Has no effect if started under a regular user. 514 | # 0 - do not allow 515 | # 1 - allow 516 | # 517 | # Mandatory: no 518 | # Default: 519 | # AllowRoot=0 520 | 521 | ### Option: Include 522 | # You may include individual files or all files in a directory in the configuration file. 523 | # Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. 524 | # 525 | # Mandatory: no 526 | # Default: 527 | # Include= 528 | 529 | # Include=/usr/local/etc/zabbix_server.general.conf 530 | # Include=/usr/local/etc/zabbix_server.conf.d/ 531 | 532 | ####### LOADABLE MODULES ####### 533 | 534 | ### Option: LoadModulePath 535 | # Full path to location of server modules. 536 | # Default depends on compilation options. 537 | # 538 | # Mandatory: no 539 | # Default: 540 | # LoadModulePath=${libdir}/modules 541 | 542 | ### Option: LoadModule 543 | # Module to load at server startup. Modules are used to extend functionality of the server. 544 | # Format: LoadModule= 545 | # The modules must be located in directory specified by LoadModulePath. 546 | # It is allowed to include multiple LoadModule parameters. 547 | # 548 | # Mandatory: no 549 | # Default: 550 | # LoadModule= 551 | --------------------------------------------------------------------------------