zabbix监控系统使用详解
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix监控系统使用详解相关的知识,希望对你有一定的参考价值。
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案,由zabbix server与可选组件zabbix agent两部门组成,可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视。zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。
zabbix 流程图:
zabbix 逻辑图:
下载地址: http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/
server:
安装:
[[email protected] zabbix]# yum localinstall zabbix-2.4.8-1.el6.x86_64.rpm zabbix-get-2.4.8-1.el6.x86_64.rpm zabbix-server-2.4.8-1.el6.x86_64.rpm zabbix-server-mysql-2.4.8-1.el6.x86_64.rpm zabbix-web-2.4.8-1.el6.noarch.rpm zabbix-web-mysql-2.4.8-1.el6.noarch.rpm
MYSQL初始化:
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL ON zabbix.* TO [email protected]‘192.168.%.%‘ IDENTIFIED BY ‘222222‘; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) [[email protected] zabbix]# mysql -uzabbix -h192.168.1.221 -p222222 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql [[email protected] zabbix]# mysql -uzabbix -h192.168.1.221 -p222222 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql [[email protected] zabbix]# mysql -uzabbix -h192.168.1.221 -p222222 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql
server配置文件:
[[email protected] zabbix]# cd /etc/zabbix/ [[email protected] zabbix]# vim zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_server.pid DBHost=192.168.1.221 DBName=zabbix DBUser=zabbix DBPassword=222222 DBSocket=/var/lib/mysql/mysql.sock SNMPTrapperFile=/var/log/snmptt/snmptt.log AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts
启动:
[[email protected] zabbix]# /etc/init.d/zabbix-server start Starting Zabbix server: [ OK ]
监听端口:10051
web配置文件:
[[email protected] zabbix]# cd /etc/httpd/conf.d/ [[email protected] conf.d]# ls README php.conf welcome.conf zabbix.conf
web 安装:
agent安装:
[[email protected] zabbix]# yum localinstall zabbix-2.4.8-1.el6.x86_64.rpm zabbix-agent-2.4.8-1.el6.x86_64.rpm zabbix-sender-2.4.8-1.el6.x86_64.rpm
配置文件:
[[email protected] zabbix]# cd /etc/zabbix/ [[email protected] zabbix]# ls zabbix_agentd.conf zabbix_agentd.d
[[email protected] zabbix]# vim zabbix_agentd.conf Server=192.168.1.221 #指定server
启动:监听端口:10050
[[email protected] zabbix]#/etc/init.d/zabbix-agent start Starting Zabbix agent: [ OK ]
中文配置:
创建主机:
监控项添加 item:
graphs 图像添加:
图像集合screens:
trigger添加:
email 报警:
[[email protected] zabbix]# postconf -e myhostname=mail.zabbix.example.cn [[email protected] zabbix]# postconf -e myorigin=zabbix.example.cn [[email protected] zabbix]# postconf -e mydomain=zabbix.example.cn [[email protected] zabbix]# postconf -e mydestination=localhost [[email protected] zabbix]# postconf -e mynetworks=127.0.0.0/8 [[email protected] zabbix]# vim /etc/postfix/main.cf #最后 myhostname = mail.zabbix.example.cn myorigin = zabbix.example.cn mydomain = zabbix.example.cn mynetworks = 127.0.0.0/8
自定义key:
agent:
[[email protected] zabbix_agentd.d]# cd /etc/zabbix/zabbix_agentd.d/ #一个文件只能定义一个 [[email protected] zabbix_agentd.d]# vim userparameter_free.conf #key:memory.free command:/usr/bin/free |awk ‘/^-\/+/ {print $4}‘ UserParameter=memory.free,/usr/bin/free |awk ‘/^-\/+/ {print $4}‘
[[email protected] zabbix_agentd.d]# /etc/init.d/zabbix-agent restart Shutting down Zabbix agent: [ OK ] Starting Zabbix agent: [ OK ]
server:
[[email protected] ~]# zabbix_get -h Zabbix get v2.4.8 (revision 59539) (20 April 2016) usage: zabbix_get [-hV] -s <host name or IP> [-p <port>] [-I <IP address>] -k <key> Options: -s --host <host name or IP> Specify host name or IP address of a host -p --port <port number> Specify port number of agent running on the host. Default is 10050 -I --source-address <IP address> Specify source IP address -k --key <key of metric> Specify key of item to retrieve value for -h --help Display help information -V --version Display version number Example: zabbix_get -s 127.0.0.1 -p 10050 -k "system.cpu.load[all,avg1]"
获取数据:
[[email protected] ~]# zabbix_get -s 192.168.1.222 -k "memory.free" 533396
传参模式:
syntax: UserParameter=key[*],command $1 $2 命令原来的要用$$1
[[email protected] zabbix_agentd.d]# vim userparameter_meminfo.conf UserParameter=memory.usage[*],/bin/cat /proc/meminfo |awk ‘/^$1/ {print $$2}‘ [[email protected] zabbix_agentd.d]# /etc/init.d/zabbix-agent restart Shutting down Zabbix agent: [ OK ] Starting Zabbix agent: [ OK ]
[[email protected] ~]# zabbix_get -s 192.168.1.222 -k "memory.usage[MemFree]" 69860
templates使用:
在模板中创建item:
创建图形 graphs:
创建screens:
使用模板:
over
以上是关于zabbix监控系统使用详解的主要内容,如果未能解决你的问题,请参考以下文章