首页 > 其他 > 详细

CentOS 7安装部署zabbix3.4

时间:2018-05-25 21:59:46      阅读:260      评论:0      收藏:0      [点我收藏+]
一、zabbix安装配置
1.zabbix简介
基于Web界面的分布式系统监控的企业级开源软件。可以监控各种系统与设备,网络参数,保证服务器设备安全运营;提供灵活的通知机制。
1.1. zabbix的逻辑图
技术分享图片
1.2. zabbix的组件
zabbix-server:Zabbix监控端组件,它是一个服务器端组件
zabbix-agent:被监控端组件,它是一个客户端组件,它主要是监控由Agent所支持的操作系统(简单说如果你要监控OS,就需要在对应的OS上安装Agent程序),而如果要监控一些其他设备,通常需要用ICMP/IPMI/SNMP/JMX协议来实现
zabbix-proxy:Zabbix代理组件,它是实现分布式监控的关键,proxy端收集数据保存在本地,server端定时去proxy将数据取回
zabbix-database:zabbix的数据库组件,zabbix收集到的数据都会存储数据库
zabbix-web:zabbix的web端组件,能够将zabbix-database中的数据提取并展示,同时它又是zabbix的配置接口
zabbix-get:server端向agent端获取数据的组件
zabbix-sender:agent端向server端主动发送收集的数据的组件
1.3. zabbix的常用术语
host:主机,指要监控的网络设备
host group:主机组,指主机的逻辑容器,可以包含主机和模板
item:监控项,指一个特定监控指标的相关数据
trigger:触发器,指一个表达式,用于评估某监控对象的某特定item内所接收到的数据是否在合理范围,即阀值;接收到的数据量大于阀值时,触发器的状态将由"OK"变为"Problem"
event:事件,指发生的一个值得关注的事,例如触发器发生状态改变
action:动作,指对特定事件事先定义的处理方法
escalation:报警升级,指发送警报或执行远程命令的自定义方案,如每隔5分钟发送一次报警,共发送5次
media:媒介,指发送通知的手段或通道,例如Email,Jabber或SMS等等
notification:通知,指通过选定的媒介向用户发送有关某事件的信息
remote command:远程命令,指预定义的命令,可以在被监控主机处于某特定条件下时自动执行
template:模板,用于快速定义被监控主机的预设条目集合,通常包含:item,trigger,graph,screen,application,以及low-level discovery rule;模板可以直接链接至单个主机
application:应用,指一组item的集合
web scennario:web场景,指用于检测web站点可用性的一个或多个HTTP请求
frontend:前端,指zabbix的web接口
1.4. Zabbix-server启动后所涉及的进程
Poller:到被监控对象拉取数据的一个进程,例如基于agent对象,一个基于snmp协议的监控对象,如果我们的监控对象很多,我们可以根据需要启动多个poller
httppoller:监控web页面用到的专用poller
discoverer:zabbix通过你所指定的规则去发现某个范围内的启动了agent的主机,并把它自动添加到监控对象中
alerter:执行报警操作的进程
housekeeper:负责清理数据库里过期的历史数据的进程
watchdog:负责监控zabbix-server所启动的所有进程是否正常工作的进程
escalator:报警升级进程
timer:计时器进程,zabbix的很多功能都严重依赖于时间的
nodewatcher:监控个节点的进程
pinger:通过ping操作来探测节点是否在线的进程
db_config_syncer:数据库的配置同步器,主要是用来完成在分布式场景中实现配置的同步的进程
db_data_syncer:数据库的数据同步器,主要是用来完成在分布式场景中实现数据的同步的进程
2.部署环境
系统: CentOS 7
IP:192.168.2.205(zabbix-server)
IP:192.168.2.204(zabbix-agent,Linux)
IP:192.168.1.59(zabbix-agent,windows)
关闭 selinux 和防火墙(这里暂时关闭iptables,部署完成后再开启)

$ sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
$ sed -i ‘s/SELINUXTYPE=targeted/#&/‘ /etc/selinux/config
$ setenforce 0  # 可以设置配置文件永久关闭
$ systemctl stop iptables.service
$ systemctl stop firewalld.service
$ reboot  # 更改selinux需要重启系统才会生效

#修改字符集,否则可能报 input/output error的问题,因为日志里打印了中文

$ localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8
$ export LC_ALL=zh_CN.UTF-8
$ echo ‘LANG=zh_CN.UTF-8‘ > /etc/locale.conf

3.安装配置zabbix
#安装 MySQL
本教程使用 Mysql 作为数据库,如果不使用 Mysql 可以跳过相关 Mysql 安装和配置

$ yum -y install mariadb mariadb-devel mariadb-server  # centos7下安装的是mariadb
$ systemctl enable mariadb
$ systemctl start mariadb

#设置mysql的root密码
$ mysqladmin -u root -h localhost password ‘xxxxxxxx‘

#创建数据库 zabbix 并授权

$ mysql -uroot -pxxxxxx
> create database zabbix character set utf8 collate utf8_bin;
> grant all privileges on zabbix.* to zabbix@localhost identified by ‘xxxxxxxx‘;
> quit

#安装zabbix-server、zabbix-agent及相关组件

$ rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
$ yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent

#导入zabbix初始化数据
$ zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pxxxxxxxx zabbix

#修改zabbix-server配置文件
$ vim /etc/zabbix/zabbix_server.conf
修改连接数据库的配置
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=xxxxxxxx

#修改PHP时区
$ vim /etc/httpd/conf.d/zabbix.conf
将下面这行修改为亚洲上海
php_value date.timezone Asia/Shanghai

#启动zabbix-server、zabbix-agent、httpd

$ systemctl restart zabbix-server zabbix-agent httpd
$ systemctl enable zabbix-server zabbix-agent httpd

4.配置zabbix前端
打开浏览器,访问http://192.168.2.205/zabbix,会看到如下页面
技术分享图片
点击“Next step”,下一步
技术分享图片
确保PHP所有项目都OK,然后点击“Next step”
技术分享图片
此处为连接mysql的配置,请按照前面安装时的配置填写,然后点击“Next step”
技术分享图片
Name处可以填写网站的名称,然后点击“Next step”
技术分享图片
技术分享图片
根据提示可以看到上面图形界面的操作都写到一个配置文件中,/etc/zabbix/web/zabbix.conf.php,确认无误后,点击“Finish”
技术分享图片
登陆zabbix前端,默认账号为?Admin,默认密码为zabbix
5.配置zabbix中文界面
#修改PHP配置文件
确认zabbix是否开启了中文件支持功能,/usr/share/zabbix/include/locales.inc.php
技术分享图片
浏览器登陆zabbix前端,设置语言为Chinese(zh_CN),然后点击“Update”
技术分享图片
此时刷新一下页面,便可以看到中文了。
6.安装配置iptables
#安装iptables
$ yum -y install iptables iptables-services

#配置iptables
$ vim /etc/sysconfig/iptables # 添加允许访问80端口的策略
技术分享图片
#启动iptables

$ systemctl start iptables.service
$ systemctl enable iptables.service

#查看iptables状态
$ systemctl status iptables.service
二、监控Linux主机
2.1.安装zabbix-agent

$ rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
$ yum install -y zabbix-agent zabbix-get

2.2.配置zabbix-agent
$ vim /etc/zabbix/zabbix_agentd.conf # 修改agent配置文件
Server=192.168.2.205 # zabbix服务端内网IP
ServerActive=192.168.2.205 # zabbix服务端内网IP,Active表示agent主动推送
Hostname=Jump Server # zabbix客户端主机名称,需要和web端添加的名称一致
Include=/etc/zabbix/zabbix_agentd.d/*.conf
2.3.配置iptables
$ vim /etc/sysconfig/iptables # 添加允许访问10050端口的策略
-A INPUT -s 192.168.2.205 -p tcp -m multiport --dports 10050 -j ACCEPT
$ systemctl restart iptables.service # 重启iptables
2.4.Web端添加Linux主机
配置-主机-创建主机,按下图配置好后点击“更新”
技术分享图片
技术分享图片
2.5.监控效果图
监测中-图形,选择前面刚添加的主机Jump Server,便可看到监控图。
技术分享图片
技术分享图片
三、监控windows主机
3.1.下载zabbix-agent
浏览器访问zabbix官网:https://www.zabbix.com/download_agents,选择windows对应的版本下载
技术分享图片
技术分享图片
3.2.安装配置zabbix-agent
解压zabbix_agents_3.4.6.win.zip,会看到bin和conf两个目录,进入到conf目录下,修改zabbix_agentd.win.conf配置文件。
LogFile=D:\zabbix_agents_3.4.6.win\log\zabbix_agentd.log
Server=192.168.2.205
ListenPort=10050
ServerActive=192.168.2.205
Hostname=Xuad Server
以管理员方式运行CMD,执行安装程序

D:\zabbix_agents_3.4.6.win\bin\win64\zabbix_agentd.exe -c D:\zabbix_agents_3.4.6.win\conf\zabbix_agentd.win.conf -i  #加载配置文件
D:\zabbix_agents_3.4.6.win\bin\win64\zabbix_agentd.exe -c D:\zabbix_agents_3.4.6.win\conf\zabbix_agentd.win.conf -s  #添加windows自启动服务

技术分享图片
#确认10050端口已监听
技术分享图片
#卸载zabbix-agent服务
先停止服务,然后以管理员方式运行CMD,执行下面的命令
sc delete "Zabbix Agent"
3.3.防火墙开放10050端口
以管理员方式运行CMD,执行下面命令,添加开放10050端口策略。
netsh advfirewall firewall add rule name="Zabbix_Agent_tcp" dir=in protocol=tcp localport=10050 remoteip=192.168.2.205 action=allow
注:remoteip=192.168.2.205表示只允许192.168.2.205访问10050端口,此为zabbix-server的IP。
3.4.web端添加windows主机
#创建主机群组
配置-主机群组,输入组名称,然后点击“更新”。
技术分享图片
#创建windows主机
配置-主机-创建主机,按下图填写好后,点击“模板”。
技术分享图片
配置-主机-模板,点击“选择”,勾选“Template OS Windows”,点击“选择”,然后点击“添加”,最后点击“更新”。
技术分享图片
技术分享图片
3.5.监控效果图
监测中-图形,选择前面刚添加的主机Xuad Server,便可看到监控图。
技术分享图片
技术分享图片
四、监控apache状态
4.1.启用apache的status功能
$ vim /etc/httpd/conf/httpd.conf
#编辑httpd.conf文件添加如下内容

ExtendedStatus On
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Allow from 192.168.2.204   # apache主机IP
</Location>

#重启apache
$ systemctl restart httpd
浏览器访问http://192.168.2.204/server-status,确认配置生效
技术分享图片
4.2.下载并配置zapache
#下载zapache

$ wget https://github.com/lorf/zapache/archive/master.zip
$ unzip master.zip

文件说明:
httpd-server-status.conf.sample 是用于配置server-status的上个步骤已经配置过了
userparameter_zapache.conf.sample 、zapache 关键的文件
zapache-template-active.xml zapache-template.xml模板文件,这两个文件需要导入到web端
#配置zapache
$ cd zapache-master
将zapache配置文件放到相应目录下

$ cp userparameter_zapache.conf.sample /etc/zabbix/zabbix_agentd.d/
$ cd /etc/zabbix/zabbix_agentd.d/
$ mv userparameter_zapache.conf.sample userparameter_zapache.conf

查看配置userparameter_zapache.conf内容
$ cat /etc/zabbix/zabbix_agentd.d/userparameter_zapache.conf
技术分享图片
可以看到应当把解压出来的zapache文件放到/var/lib/zabbixsrv/externalscripts/目录下,当然也可以修改这个目录位置,改为自定义的,我这里就用默认配置文件里的目录,因此,创建这个目录。

$ mkdir -p /var/lib/zabbixsrv/externalscripts/
$ cp zapache /var/lib/zabbixsrv/externalscripts/
$ chmod +x /var/lib/zabbixsrv/externalscripts/zapache

查看zabbix-agent配置文件,确保zabbix_agentd.d目录开启
Include=/etc/zabbix/zabbix_agentd.d/*.conf
4.3.web端导入模板
配置-模板-导入,点击“浏览”,选择模板文件点击“打开”,点击“导入”即可。
技术分享图片
依次将zapache-template.xml和zapache-template-active.xml两个模板文件都导入进来。
4.4.主机添加监控模板
配置-主机,点击要添加的主机,点击“模板”,点击“选择”,勾选
Template App Apache Web Server zapache,然后点击“添加”,最后点击“更新”。
技术分享图片
4.5.监控效果图
技术分享图片
技术分享图片
五、监控nginx状态
5.1.启用nginx的status功能
$ vim /etc/nginx/nginx.conf
#编辑nginx.conf文件添加如下内容

location /nginx-status {
            stub_status on;
            access_log off;
            allow 127.0.0.1;
            allow 192.168.2.204;   # nginx主机IP
        }

#使配置生效
$ /usr/sbin/nginx -t
技术分享图片
$ /usr/sbin/nginx -s reload
用curl来进行测试,此操作请在zabbix-server主机上操作。
$ curl http://192.168.2.204/nginx-status
技术分享图片
备注:
Active connections –当前活跃的连接数量
server accepts handled requests — 总共处理了8426个连接 , 成功创建 8426次握手, 总共处理了9104个请求
reading — 读取客户端的连接数.
writing — 响应数据到客户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接
5.2.创建监控脚本
$ vim /etc/zabbix/zabbix_agentd.d/nginx_status.sh

#!/bin/bash
##################################
# Zabbix monitoring script
#
# nginx:
# - anything available via nginx stub-status module
#
##################################
# Contact:
# vincent.viallet@gmail.com
# Zabbix requested parameter
ZBX_REQ_DATA="$1"
ZBX_REQ_DATA_URL="$2"
# Nginx defaults
NGINX_STATUS_DEFAULT_URL="192.168.2.204/nginx-status"    #(这里写网站的域名)
WGET_BIN="/usr/bin/wget"
#
# Error handling:
# - need to be displayable in Zabbix (avoid NOT_SUPPORTED)
# - items need to be of type "float" (allow negative + float)
#
ERROR_NO_ACCESS_FILE="-0.9900"
ERROR_NO_ACCESS="-0.9901"
ERROR_WRONG_PARAM="-0.9902"
ERROR_DATA="-0.9903" # either can not connect / bad host / bad port
# Handle host and port if non-default
if [ ! -z "$ZBX_REQ_DATA_URL" ]; then
 URL="$ZBX_REQ_DATA_URL"
else
 URL="$NGINX_STATUS_DEFAULT_URL"
fi
# save the nginx stats in a variable for future parsing
NGINX_STATS=$($WGET_BIN -q $URL -O - 2> /dev/null)
# error during retrieve
if [ $? -ne 0 -o -z "$NGINX_STATS" ]; then
 echo $ERROR_DATA
 exit 1
fi
#
# Extract data from nginx stats
#
case $ZBX_REQ_DATA in
 active_connections) echo "$NGINX_STATS" | head -1 | cut -f3 -d‘ ‘;;
 accepted_connections) echo "$NGINX_STATS" | grep -Ev ‘[a-zA-Z]‘ | cut -f2 -d‘ ‘;;
 handled_connections) echo "$NGINX_STATS" | grep -Ev ‘[a-zA-Z]‘ | cut -f3 -d‘ ‘;;
 handled_requests) echo "$NGINX_STATS" | grep -Ev ‘[a-zA-Z]‘ | cut -f4 -d‘ ‘;;
 reading) echo "$NGINX_STATS" | tail -1 | cut -f2 -d‘ ‘;;
 writing) echo "$NGINX_STATS" | tail -1 | cut -f4 -d‘ ‘;;
 waiting) echo "$NGINX_STATS" | tail -1 | cut -f6 -d‘ ‘;;
 *) echo $ERROR_WRONG_PARAM; exit 1;;
esac
exit 0

给此脚本添加可执行权限
$ chmod +x /etc/zabbix/zabbix_agentd.d/nginx_status.sh
5.3.配置zabbix-agent
$ vim /etc/zabbix/zabbix_agentd.conf
#编辑zabbix_agentd.conf文件,添加下面一行
UserParameter=nginx[*],/etc/zabbix/zabbix_agentd.d/nginx_status.sh "$1"
#重启zabbix-agent
$ systemctl restart zabbix-agent
#在zabbix-server主机上测试,不报错说明测试OK
$ zabbix_get -s 192.168.2.204 -p 10050 -k ‘nginx[reading]‘
技术分享图片
5.4.Web端导入模板
配置-模板-导入,将nginx_template.xml导入进来。
技术分享图片
5.5.主机添加监控模板
配置-主机-模板,添加Template_Nginx模板。
技术分享图片
5.6.监控效果图
技术分享图片
技术分享图片
附:nginx模板

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>2.0</version>
    <date>2013-03-26T04:17:58Z</date>
    <groups>
        <group>
            <name>Templates</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template_Nginx</template>
            <name>Template_Nginx</name>
            <groups>
                <group>
                    <name>Templates</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>Nginx</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Nginx $1</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>nginx[waiting,{$NGINX_STATUS_URL}]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx $1</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>nginx[writing,{$NGINX_STATUS_URL}]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx $1</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>nginx[active_connections,{$NGINX_STATUS_URL}]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx $1</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>nginx[reading,{$NGINX_STATUS_URL}]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx $1/sec</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>nginx[handled_requests,{$NGINX_STATUS_URL}]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>1</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx $1/sec</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>nginx[accepted_connections,{$NGINX_STATUS_URL}]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>1</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Nginx $1/sec</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>nginx[handled_connections,{$NGINX_STATUS_URL}]</key>
                    <delay>60</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>0</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>1</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>Nginx</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Number of $1 process</name>
                    <type>0</type>
                    <snmp_community>public</snmp_community>
                    <multiplier>0</multiplier>
                    <snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.1</snmp_oid>
                    <key>proc.num[nginx]</key>
                    <delay>300</delay>
                    <history>30</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications/>
                    <valuemap/>
                </item>
            </items>
            <discovery_rules/>
            <macros>
                <macro>
                    <macro>{$NGINX_STATUS_URL}</macro>
                    <value>http://127.0.0.1:10061/nginx_status</value>
                </macro>
            </macros>
            <templates/>
            <screens/>
        </template>
    </templates>
    <triggers>
        <trigger>
            <expression>{Template_Nginx:proc.num[nginx].last(0)}=0</expression>
            <name>Nginx is not running on {HOSTNAME}</name>
            <url/>
            <status>0</status>
            <priority>4</priority>
            <description>Nginx is not running.

      It has been stopped / shutdown or has crashed. 
      Check on the server for more details:
        - w / last
        - dmesg logs
        - /var/log/messages
        - nginx error logs</description>
            <type>0</type>
            <dependencies/>
        </trigger>
    </triggers>
    <graphs>
        <graph>
            <name>Nginx - Connections and Requests status</name>
            <width>900</width>
            <height>200</height>
            <yaxismin>0.0000</yaxismin>
            <yaxismax>100.0000</yaxismax>
            <show_work_period>0</show_work_period>
            <show_triggers>0</show_triggers>
            <type>0</type>
            <show_legend>1</show_legend>
            <show_3d>0</show_3d>
            <percent_left>0.0000</percent_left>
            <percent_right>0.0000</percent_right>
            <ymin_type_1>1</ymin_type_1>
            <ymax_type_1>0</ymax_type_1>
            <ymin_item_1>0</ymin_item_1>
            <ymax_item_1>0</ymax_item_1>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <drawtype>1</drawtype>
                    <color>FF9999</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>4</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_Nginx</host>
                        <key>nginx[accepted_connections,{$NGINX_STATUS_URL}]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <drawtype>2</drawtype>
                    <color>990000</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>4</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_Nginx</host>
                        <key>nginx[handled_connections,{$NGINX_STATUS_URL}]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <drawtype>0</drawtype>
                    <color>009900</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>4</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_Nginx</host>
                        <key>nginx[handled_requests,{$NGINX_STATUS_URL}]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
        <graph>
            <name>Nginx - Threads status</name>
            <width>900</width>
            <height>200</height>
            <yaxismin>0.0000</yaxismin>
            <yaxismax>100.0000</yaxismax>
            <show_work_period>0</show_work_period>
            <show_triggers>0</show_triggers>
            <type>1</type>
            <show_legend>1</show_legend>
            <show_3d>0</show_3d>
            <percent_left>0.0000</percent_left>
            <percent_right>0.0000</percent_right>
            <ymin_type_1>1</ymin_type_1>
            <ymax_type_1>0</ymax_type_1>
            <ymin_item_1>0</ymin_item_1>
            <ymax_item_1>0</ymax_item_1>
            <graph_items>
                <graph_item>
                    <sortorder>0</sortorder>
                    <drawtype>1</drawtype>
                    <color>990000</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>4</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_Nginx</host>
                        <key>nginx[writing,{$NGINX_STATUS_URL}]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>1</sortorder>
                    <drawtype>1</drawtype>
                    <color>999900</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>4</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_Nginx</host>
                        <key>nginx[reading,{$NGINX_STATUS_URL}]</key>
                    </item>
                </graph_item>
                <graph_item>
                    <sortorder>2</sortorder>
                    <drawtype>1</drawtype>
                    <color>009900</color>
                    <yaxisside>0</yaxisside>
                    <calc_fnc>4</calc_fnc>
                    <type>0</type>
                    <item>
                        <host>Template_Nginx</host>
                        <key>nginx[waiting,{$NGINX_STATUS_URL}]</key>
                    </item>
                </graph_item>
            </graph_items>
        </graph>
    </graphs>
</zabbix_export>

CentOS 7安装部署zabbix3.4

原文:http://blog.51cto.com/andyxu/2120362

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!