码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix监控系统使用详解

时间:2016-06-09 22:22:07      阅读:542      评论:0      收藏:0      [点我收藏+]

标签: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:

安装:

[root@sherry 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 zabbix@‘192.168.%.%‘ IDENTIFIED BY ‘222222‘;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)


[root@sherry zabbix]# mysql -uzabbix -h192.168.1.221 -p222222 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql 
[root@sherry zabbix]# mysql -uzabbix -h192.168.1.221 -p222222 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql 
[root@sherry zabbix]# mysql -uzabbix -h192.168.1.221 -p222222 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql

server配置文件:

[root@sherry zabbix]# cd /etc/zabbix/
[root@sherry 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

启动:

[root@sherry zabbix]# /etc/init.d/zabbix-server start
Starting Zabbix server:                                    [  OK  ]

监听端口:10051

web配置文件:

[root@sherry zabbix]# cd /etc/httpd/conf.d/
[root@sherry conf.d]# ls
README  php.conf  welcome.conf  zabbix.conf

web 安装:

技术分享

技术分享

技术分享

技术分享

技术分享

agent安装:

[root@martin 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

配置文件:

[root@martin zabbix]# cd /etc/zabbix/
[root@martin zabbix]# ls
zabbix_agentd.conf  zabbix_agentd.d
[root@martin zabbix]# vim zabbix_agentd.conf 
Server=192.168.1.221   #指定server

启动:监听端口:10050

[root@martin zabbix]#/etc/init.d/zabbix-agent start
Starting Zabbix agent:                                     [  OK  ]

中文配置:

技术分享

技术分享


创建主机:

技术分享

技术分享

监控项添加  item:

技术分享

技术分享

技术分享


graphs 图像添加

技术分享

技术分享

技术分享

图像集合screens:

技术分享

技术分享

技术分享

技术分享

trigger添加:

技术分享

技术分享

技术分享

技术分享


email 报警:

[root@sherry zabbix]# postconf -e myhostname=mail.zabbix.example.cn 
[root@sherry zabbix]# postconf -e myorigin=zabbix.example.cn 
[root@sherry zabbix]#  postconf -e mydomain=zabbix.example.cn 
[root@sherry zabbix]# postconf -e mydestination=localhost
[root@sherry zabbix]# postconf -e mynetworks=127.0.0.0/8 


[root@sherry 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:

[root@martin zabbix_agentd.d]# cd /etc/zabbix/zabbix_agentd.d/    #一个文件只能定义一个
[root@martin 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}‘
[root@martin zabbix_agentd.d]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                                [  OK  ]
Starting Zabbix agent:                                     [  OK  ]

server:

[root@sherry ~]# 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]"

获取数据:

[root@sherry ~]# zabbix_get -s 192.168.1.222 -k "memory.free"
533396


传参模式:

syntax:
UserParameter=key[*],command $1 $2   命令原来的要用$$1
[root@martin zabbix_agentd.d]# vim userparameter_meminfo.conf 
UserParameter=memory.usage[*],/bin/cat /proc/meminfo |awk ‘/^$1/ {print $$2}‘

[root@martin zabbix_agentd.d]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:                                [  OK  ]
Starting Zabbix agent:                                     [  OK  ]
[root@sherry ~]# zabbix_get -s 192.168.1.222 -k "memory.usage[MemFree]"
69860

技术分享


templates使用:


技术分享

技术分享

技术分享

在模板中创建item:

技术分享

技术分享

技术分享

技术分享

创建图形 graphs:

技术分享

创建screens:

技术分享

技术分享

技术分享

技术分享

使用模板:

技术分享

技术分享


over

zabbix监控系统使用详解

标签:zabbix 监控系统

原文地址:http://marvin89.blog.51cto.com/9163436/1787689

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!